PatientProgam "voidLastState" object

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

Also, related to this, PatientProgram has the folllowing utility method to transition to a new state (which the REST module delegates to when adding new states):

public void transitionToState(ProgramWorkflowState programWorkflowState, Date onDate)

This method will set the end date of the current “last” state to the “onDate”, and then create a the new state with startDate = onDAte, and endDate = null.

In this case, do we want to set the endDate to the dateCompleted if the program is completed?

Or, as I’m thinking it through, maybe it is that we don’t want to allow a state transition (or voiding a state) after a program has been completed?

Take care, Mark

@burke do you have any thoughts on this?

So, as an update, although I do thing this is a bug, or at least a feature that should be implemented, the current behavior (not to set the end date of the most recent state in a workflow, regardless of whether the program has been completed or not) seems well established, so I was reluctant to change it and backport it. I created tickets for further discussion and shelved my current work in a branch, see:

Take care! Mark

@mogoodrich how about a design call?

I’m willing if others are interested… probably shouldn’t take a whole design call though… not a blocker on my part.

Take care, Mark

@jthomas what do you think?

Hey @mogoodrich were are on a design call now and do not seem to have any topic. Are you available?

Oops, sorry… just got this now… did anyone have any thoughts on it? :slight_smile:

@mogoodrich we decided to reschedule the discussion for some time when you could join.

@mogoodrich this was not discussed on today’s design forum would Wednesday work for you?

Wednesday would work for me, thanks!

1 Like