Validate patient identifier on html form

@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