Creating a new Encounter via REST

Question: We have created a mobile client for our implementation,i.e, UgandaEMR . Ideally, the mobile client must be able to sync data to and from the facility EMR provided there is a network connection. We have already worked on the synching of data from the EMR to the Mobile device, however, the challenge is sending data back to the EMR from the mobile device.

We are using the endpoint https://demo.openmrs.org/openmrs/ws/rest/v1/encountertype/67a71486-1a54-468f-ac3e-7091a9a79584 for encounters as explained here https://demo.openmrs.org/openmrs/module/webservices/rest/apiDocs.htm.

The Post Body i.e, content to send to the EMR is here https://gist.github.com/solemabrothers/d993c2f73b81fb50786bd451d48e4526

The error message is [obs on class org.openmrs.EncounterType as shown here https://gist.github.com/solemabrothers/695df51a2aa7ff1a758558104bcd5867

I need advice on how to solve this error. Thank you. @dkayiwa @ssmusoke @wyclif @mozzy

hello @solemabrothers

sorry about the error

i see the url end point you are using is for an encountertype, if you are aiming at creating an encounter then the url should be something like this http://localhost:8087/openmrs/ws/rest/v1/encounter and the post payload probably like this

{
  "encounterDatetime": "2019-10-16 12:08:43",
  "patient": "070f0120-0283-4858-885d-a20d967729cf",
  "encounterType": "e22e39fd-7db2-45e7-80f1-60fa0d5a4378",
  "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
  "encounterProviders": [
    {
      "provider": "bb1a7781-7896-40be-aaca-7d1b41d843a6",
      "encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
    }
  ]
}

thats why the obs attribute is not being understood on the class org.openmrs.EncounterType because the EncounterType only takes in name and description attributes …

Feel free to correct me if i have gooten your question wrongly :cowboy_hat_face:

Thanks

1 Like

@gcliff I need to send obs along with the encounter, running the above json body gives this error message

{

    "error": {

        "message": "Invalid Submission",

        "code": "webservices.rest.error.invalid.submission",

        "globalErrors": [],

        "fieldErrors": {

            "patient": [

                {

                    "code": "Encounter.error.patient.required",

                    "message": "Patient is Required"

                }

            ]

        }

    }

}