Cannot POST Encounter to OpenMRS

Hi everyone,

I have an Encounter in JSON form with the following content:

    "resourceType": "Encounter",
    "encounterDatetime": "2019-10-16 12:08:43",
    "patient": "637d5571-dee2-4e5e-8ece-b65d2d965081",
    "location": "58c57d25-8d39-41ab-8422-108a0c277d98",
          "provider": "f9badd80-ab76-11e2-9e96-0800200c9a66",
          "encounterRole": "a0b03050-c99b-11e0-9572-0800200c9a66"

I want to sink this to the OpenMRS instance from this repo, that has the FHIR Module installed.

When I run the following cURL request:

curl -X POST -u admin:Admin123 -H "Content-Type: application/json+fhir;charset=utf-8"  http://localhost:8099/openmrs/ws/fhir2/R4/Encounter -d @Encounter.json

I get the following error:

    "resourceType": "OperationOutcome",
    "issue": [
            "severity": "error",
            "code": "processing",
            "diagnostics": "Invalid request: The FHIR endpoint on this server does not know how to handle POST operation[Encounter] with parameters [[]]"

I am not sure what the parameter [] is. To setup the JSON, I followed what is in the OpenMRS doc here.

How can I post Encounter FHIR data ?

@ismailo the JSON payload you are posting with curl is wrong, its meant for posting while using the rest module as seen here

Have a look at this for posting Encounter fhir data

what do you mean by this?

Do you want to track the encounter posting with the streaming pipe line of the analytics engine reading your my-sql binlog for the change in the encounter posted to openmrs

@gcliff Sorry for the confusion about the repo, it is independent of the problem. My question is a pure FHIR module question.

Thanks for sharing the links! I tried the Encounter below you shared in the link and I got the same error:

The FHIR endpoint on this server does not know how to handle POST operation[Encounter] with parameters [[]]"

when I ran:

curl -X POST -u admin:Admin123 -H "Content-Type: application/json+fhir;charset=utf-8"  http://localhost:8099/openmrs/ws/fhir2/R4/Encounter -d @Encounter.json

I verified that Paul Walker exists in the server by running:

curl -X GET  -u admin:Admin123 -H "Content-Type: application/json;charset=utf-8"  http://localhost:8099/openmrs/ws/fhir2/R4/Patient?name=Walker

and the patient Id, openmrs id, location, etc matched what is in the Encounter request.

What am I missing in the JSON?

    "resourceType": "Encounter",
    "meta": {
      "lastUpdated": "2021-01-14T12:22:58.000+00:00"
    "text": {
      "status": "generated",
      "div": "<div xmlns=\"\"><table class=\"hapiPropertyTable\"><tbody><tr><td>Id:</td><td>195df5c8-ef0f-4335-b1cf-4958cdd3f015</td></tr><tr><td>Status:</td><td>UNKNOWN</td></tr><tr><td>Class:</td><td> (Details: ) </td></tr><tr><td>Subject:</td><td><a href=\"http://localhost:8080/openmrs/ws/fhir2/R4/Patient/8295eb5b-fba6-4e83-a5cb-2817b135cd27\">Paul Walker (OpenMRS ID: 10000X)</a></td></tr><tr><td>Location:</td><td><table class=\"subPropertyTable\"><tbody><tr><th>-</th><th>Location</th><th>Status</th><th>Physical Type</th><th>Period</th></tr><tr><td>1</td><td><a href=\"http://localhost:8080/openmrs/ws/fhir2/R4/Location/8d6c993e-c2cc-11de-8d13-0010c6dffd0f\">Unknown Location</a></td><td/><td/><td/></tr></tbody></table></td></tr><tr><td>Part Of:</td><td><a href=\"http://localhost:8080/openmrs/ws/fhir2/R4/Encounter/b0dc60c6-7d16-415f-af3f-90dcb538043f\">Encounter/b0dc60c6-7d16-415f-af3f-90dcb538043f</a></td></tr></tbody></table></div>"
    "status": "unknown",
    "class": {
      "system": "",
      "code": "AMB"
    "subject": {
      "reference": "Patient/8295eb5b-fba6-4e83-a5cb-2817b135cd27",
      "type": "Patient",
      "display": "Paul Walker (OpenMRS ID: 10000X)"
    "location": [
        "location": {
          "reference": "Location/8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
          "type": "Location",
          "display": "Unknown Location"
    "partOf": {
      "reference": "Encounter/b0dc60c6-7d16-415f-af3f-90dcb538043f",
      "type": "Encounter"

@ismailo use this payload for posting… Also follow these cautions ;

So note that creating an encounter through the FHIR2 API requires you to have the necessary data already setup in your OpenMRS instance, so, for instance, the Visit that this encounter is partOf needs to already exist, the patient the encounter is for needs to exist, the patient needs to exist, the practitioner referenced needs to exist and be a valid OMRS provider, the location of the encounter needs to exist in your instance, as does the encounterType. That’s probably the issue with the first request. (So, in the context where we actually use that sample request for a test, we have the data shown here loaded into the database)…

Ensure you are using fhir2 module version that has support for posting encounters

@gcliff thanks for the help on this, this was my issue! The FHIR module I was using didn’t have the PR you linked to. Using the openmrs/openmrs-reference-application-distro:nightly image helped resolve the issue :smiley: