Validate patient identifier on html form

I need to build an html form that would take in patient identifier and that field should be able to validate if the identifier exists for another patient before submiting.

Any clue as to how I could do this on openmrs html form module is much appreciated.

Are you using this to register new patients?

No I am not, the patient would be registered before the form would be filled, the field is just a way of collecting additional ID for that patient.

Can you describe the exact use case in detail?

take for example a client needs to be tested for HIV via the client intake form.

step 1: register the client as a patient on openmrs. step 2: fill the client intake form for the patient.

Note: The client intake form for HTS contains two(2) additional IDs for the patient namely: client code and recency Id. so I need to capture these IDs as patient identifier for that patient…not as concepts.

What I have achieve so far: on the form I could use the patient tag to capture the data for client code and that works but when I try to use another patient tag to capture the recency ID that breaks the form…and it refuse to submit.

Did you evaluate registering the patient using this form? https://uat-refapp.openmrs.org/openmrs/registrationapp/registerPatient.page?appId=referenceapplication.registrationapp.registerPatient

Or this? https://uat-refapp.openmrs.org/openmrs/admin/patients/shortPatientForm.form?addName=Moris+Somesingi&addBirthdate=&addAge=88&addGender=M

Yes Daniel, that was what I meant by step 1. so the patient first be registered using https://uat-refapp.openmrs.org/openmrs/registrationapp/registerPatient.page?appId=referenceapplication.registrationapp.registerPatient

then from the patient dashboard the client intake form would be filled.

How about using this to add more identifiers? https://uat-refapp.openmrs.org/openmrs/admin/patients/shortPatientForm.form?patientId=57

Where can I find the source code for that form, I need to verify the form tags used on the form.

@dkayiwa Is this url will work as an api for other client because create patient bypassing my custom registration app. So Can I use this url as an api to register the patient.

Is this of help? OpenMRS Docs

1 Like

Thanks for the response @dkayiwa , Actually /patient bypassing my custom registration app If I use / patient api through postman or on android client LBAC not seems to be working with /patient api. That’s the reason I am looking for the api which should gone through my custom registration app.

Issue is I am not able to see the created patient with non admin user even both the user and patient belong to the same location and the same patient can be viewed by admin If I update the location of patient through Reff App then the patient become visible to non admin user of that location.

PLEASE have look to my issue I am struggling since a week. Thanks.

@atiq At a guess, the real problem is that the LBAC module is working, but because it only hooks into the registration app, you’ll need to take extra steps when creating a patient via REST.

On the Wiki page on the LBAC module, there are instructions for setting up the registration app which essentially boils down to adding this to the registration app configuration:

{
    "id": "accesslocation-info",
    "label": "Access Location",
    "questions": [
                  {
                      "legend": "Patient Location ",
                      "id": "patientLocationLabel",
                      "fields": [
                        {
                         "type": "personAttribute",
                         "label": "Select Location",
                         "formFieldName": "locationId",
                         "uuid": "0a93cbc6-5d65-4886-8091-47a25d3df944",
                         "widget": {
                                    "providerName": "locationbasedaccess",
                                    "fragmentId": "field/locations"
                                   }
                         }
                        ]
                  }
    ]
}

This adds a field to select the locaiton that the patient belongs to (and is visible from). Notice that this value is stored in a personAttribute with type UUID of 0a93cbc6-5d65-4886-8091-47a25d3df944. The value stored in that attribute is the UUID of the location the person belongs to. So, to work with the LBAC module, your calls to the REST API will also need to create the patient with a person attribute with the appropriate value.

Something like this might work:

{
  person: {
    "names": [{
      "givenName": "Mohit",
      "familyName": "Kumar"
    }],
    "gender": "M",
    "birthdate": "1997-09-02",
    "attributes": [{
      "attributeType": "0a93cbc6-5d65-4886-8091-47a25d3df944"
      "value": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f"
    }]
  }
  identifiers: [{
      "identifier": "1003EY",
      "identifierType": "05a29f94-c0ed-11e2-94be-8c13b969e334",
      "location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
      "preferred": false
  }]
}

Essentially, this just populates the expected attribute with a location. Of course, you’d need to look up the relevant location uuid for your particular installation. (I’ve mostly just stolen from the examples on https://rest.openmrs.org)

2 Likes

Thanks a Ton @ibacher . Really appreciate the the solution and good news is that It works succesfully. Again Thanks A lot. :slightly_smiling_face: