[SOLVED] Creating new Patients from HTML Form

I am wondering how to create new patients from within an HTML Form.

Scenario: As part of registering a patient in ART care, it is necessary to add members of the household with names, DOB, and one or so attributes plus a relationship between the main patient and the members of the household.

I am wondering, is this possible and if so how has it been done? Is there a workaround to having to register each member of the household on their own as that becomes too tedious.

Our Rwanda team created and use the “patient” htmlform entry tag:


@ssmusoke - You ask so many awesome questions. I love that.

@ball Thank you, well I am learning alot as we strive to improve a complex deployment.

The challenge with the patient tag is that it uses the current patient in the context so cannot be integrated into an existing form say for a parent, to show the members of the household.

How did the Rwanda team use it to create new patients? Is it in popup? Then how is the information linked to the current form being filled?

hi Musoke, …we don’t use the patient tag for creating new patients. We mainly create new patients using the Rwanda Primary Care module and use HTML Forms for adding/editing patient data like encounters, obs,… . I don’t know a workaround to this in your case but I would try to create new persons/patients using the normal openmrs UI and use the relationship tag in HTML Form to create the required relationships.

1 Like

@ssmusoke i see you creating a ticket for this. :slight_smile:

@dkayiwa you know me too well https://issues.openmrs.org/browse/HTML-645

@mogoodrich Do you have any advice on how to approach updating the patient tag to create new patients. High level thoughts:

  1. Maybe create a new tag registerPatient which takes the following options:
  • First Name, Last Name or unknown patient (this is for babies who do not have names at the time)
  • DOB: actual date
  • Age: estimated years and months
  • Gender
  • Identifier: which is required - at least one using the id or uuid of the patient identifier type
  • Relationship: with the active patient in the form so that the two are linked

Not sure about edit mode here - maybe this can be done through the relationship tag

@mogoodrich @mseaton any ideas or constraints that you foresee?

@ssmusoke, not sure if you saw @rubailly’s post above, but I believe the relationship tag is what was created and is used for the use case you describe.


Will this meet your needs?


@mseaton the relationships tag will not cut it. The use case if for a labor and delivery scenario in the image below, the form being displayed is for the mother, and there is need to register the babies born in a single shot rather than go through the process of registering each one separately.

Which is why I am looking even at the possibility of adding a new tag for this use case which is very common in MCH settings

@ssmusoke the “registerPatient” option you lay out seems like a reasonable approach, though I would check to see if the existing “patient” tag could be multi-purposed to do any of this.

For editing, if you could get away without doing editing in the first pass, that would be a good way to simplify things.

Take care, Mark

@ssmusoke, I see. That would be a useful feature to have. But it definitely gets complicated as you are basically talking about editing the attributes (and potentially even encounters and observations) of multiple patients on the same form.

One approach I might recommend you try would be to:

  • Capture the above data as Obs in the mother’s encounter (1 obs group per baby)
  • Implement a postSubmissionAction that inspects these Obs Groups, and creates (and potentially updates) new patient records based on the submitted data.

An additional benefit of this is that you capture and preserve the fidelity of what was entered on this form for these fields, even if the baby’s patient record is later updated (i.e. they would be observations in the mother’s encounter, and then the post submission action would also make them observations or other attributes if desired in the child’s record).

It also means that you could make decisions like “only register a new patient if the infant is born alive” that are embedded in your postSubmissionAction rule. So, if a baby is born alive, create a new record for them in the system. Otherwise, just retain the information as observational history in the mother’s record.


1 Like

@mseaton Thanks that really looks like a plan, breaking the problem into distinct steps … Will work it out and let you know how it goes

@mseaton FYI I was able to get this working along with unit tests etc, I am trying to find a way to make it generic for others to build upon