A patient is enrolled in a program. How do I transition a patient through the states of the workflow, using the REST API?
Firstly, what rules are applied in the background regarding states? For example:
Some states are designated as initial
and some as terminal
. I see that the UI uses this to filter the state list that is shown to the user. I also see that the backend will terminate an enrollment (patient_program) if it reaches a terminal state. Is any other business logic applied regarding initial
vs terminal
vs other state, or can I just change the state of an enrollment in any way I wish by posting an update to programenrollment/{uuid}/state
?
Secondly, when I post a state update, I want to specify the startDate explicitly. However, I get an error: Some properties are not allowed to be set: startDate’. I have to omit the ‘startDate’ and then it defaults it to today’s date. not what I want. Is there a workaround?
Thirdly, I include the initial state with the creation of the new enrollment. However, after that I want to post individual state changes, but I can’t get the state change to take effect. I’m posting a change of state to the existing enrollment with UUID 173e5d32-eea6-44e4-af67-4efa35a5da66
. The workflow state UUID is ca632b9d-4317-41e4-8ee8-48b54e553b06
:
- POST to URL:
programenrollment/173e5d32-eea6-44e4-af67-4efa35a5da66/state
- Request body:
{ "state":"ca632b9d-4317-41e4-8ee8-48b54e553b06" }
I don’t see this state change applied. Am I missing something?