How can I use the <markPatientDead> tag optionally?

Platform Version: 1.11.4 OpenMRS Version: 2.3 HTML Form Entry Version: 2.6

Question: I have a hospital discharge form, which asks the outcome. If the outcome is that the patient died, I show additional fields (via JavaScript) to collect the cause of death. I would also like it to in this case, which is also hidden/shown via JavaScript. tries to mark the patient as dead in all situations; like it would be a death form rather than a generic discharge form. I get an error if I try to use it without specifying a cause of death.

Caused by: org.openmrs.api.ValidationException: 'Patient#14' failed to validate with reason: causeOfDeath: Cause of Death is required for people marked as deceased.

Is there a way to make it ignore marking the patient as dead if a cause isn’t specified. Or is there a way that I can not allow the tag to execute based on input from the previous field on the form? I would try putting it in a but I have issues with that too
 RA-932

Any suggestions @mogoodrich?

1 Like

@arbaughj, in what case are you seeing the error above? It seems like, according to the documentation, it should set the cause of death to unknown if you don’t specify a reason.

But, regardless, I don’t think this is your main issue regardless, correct? You want to conditionally mark a patient as dead based on an answer to a previous question? No immediate hacks come to mind to make this work out of the box, though the “correct” functionality, I think, would be to add an attribute to the “markPatientDead” that tells the form instead of alway marking the patient dead, render a checkbox and only mark the patient dead if the checkbox is checked. Then you could potentially auto-set this checkbox based on dispostion.

Anyway, yeah, sounds like a feature request
 :smile:

Take care, Mark

Yes, @mogoodrich, that is exactly what I’m trying to accomplish!

It seemed intuitive to me that if the causeOfDeathFromObs attribute wasn’t set, that the patient hasn’t really died, but I understand and agree with what you’re saying that it should be set as “UNKNOWN”. FYI: the concept.unknown global property mentioned in the documentation doesn’t exist out of the box. concept.otherNonCoded exists.

Showing a check-box would work, but that’s more similar to the ‘exitFromCare’ tag which has a visible component. It seems markPatientDead should be used behind the scenes without direct user interaction.

Perhaps we could optionally add a parameter to specify the ID and value of another obs tag that’s on the form. For example, “doIfId” and “doIfValue”. Or, perhaps we could give the tag an ID attribute that could be controlled via JavaScript. Or perhaps we could somehow make it work with the toggle attribute if the tag was in the toggle. Of course we would have to fix



to get that working.

Anyway you look at it, you and others are the experts, I just know what I need on the field.

I’ve created a ticket.

Just for historical interest, this tag was created specifically for a “Death Certificate” form, which is why it behaves the way it does.