In core, the PatientState domain object has a “voidLastState(ProgramWorkflow)” utility method that voided the last (most recent) patient state for that patient within the specified workflow. This is what the REST module delegates to when deleting a state RESTfully.
There’s some business logic built int the method, namely that it sets the end date of the “next-to-last” patient state to null, which is generally the “right” behavior. That is if you have:
Pre-ART: Oct 1, 2017 to Oct 5, 2017 On ART: Oct 5 to Present
And delete, “On ART”, you end up with:
Pre-ART: Oct 1, 2017 to Present
The case when this doesn’t seem right is when a program is completed… for instance, say you have:
Program Completion Date: Oct 20, 2017 Pre-ART: Oct 1, 2017 to Oct 5, 2017 On ART: Oct 5 to Octo 20, 2017
If you delete the “On ART” in this case, you end up with:
Program Completion Date: Oct 20, 2017 Pre-ART: Oct 1, 2017 to Present
I would say the correct logic is to set the end date of the next-to-last state to “null” if the program has not been completed, but, if not, set it to the completion date of the program?
Thoughts? And if people agree this should be changed, is this considered a bug and/or something we could backport all the way to 1.10.x?
Should be possible for me to just work around this in program widgets we are building in coreapps, but if people think it’s work changing in core, I’m willing to backport.
Take care, Mark