Need FHIR2 encounter create and update calls

the concept used to track the observation has to be defined in the concept dictionary, though you can search the dictionary to ensure it does not exist, then create one and this will appear in the concept table in the openmrs DB.

Hi @gcliff ,

Thank you for your reply. I understand the point here that I can make a new concept in openmrs for this particular purpose. However, I want to know if the fhir2 module is able to make a new concept for me or not ?

@chughrahul No. We do not create concepts on-the-fly. Concepts have to already exist in the concept dictionary.

Hi @ibacher ,

Thank you for clarifying.

Hi @ibacher @gcliff ,

I’m trying to post an encounter through the /fhir2/R4/Encounter call with the following body -

{
    "resourceType": "Encounter",
    "id": "{{EncounterId}}",
    "meta": {
        "tag": [
            {
                "system": "http://fhir.openmrs.org/ext/encounter-tag",
                "code": "encounter",
                "display": "Encounter"
            }
        ]
    },
    "text": {
        "status": "generated",
        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><table class=\"hapiPropertyTable\"><tbody><tr><td>Id:</td><td>{{EncounterId}}</td></tr><tr><td>Status:</td><td>UNKNOWN</td></tr><tr><td>Class:</td><td> (Details: http://terminology.hl7.org/CodeSystem/v3-ActCode ) </td></tr><tr><td>Type:</td><td> OPConsultation </td></tr><tr><td>Subject:</td><td><a href=\"http://localhost:8080/openmrs/ws/fhir2/R4/Patient/b6926e3f-502e-fe0a-d62e-553cf8abfc51\">Riya Tyagi (EMR Identifier Number: NEW54935)</a></td></tr><tr><td>Participants:</td><td><table class=\"subPropertyTable\"><tbody><tr><th>-</th><th>Type</th><th>Period</th><th>Individual</th></tr><tr><td>1</td><td/><td/><td><a href=\"http://localhost:8080/openmrs/ws/fhir2/R4/Practitioner/844ebcd1-7855-45d3-91ee-0a932663b838\">Abc Tyagi</a></td></tr></tbody></table></td></tr><tr><td>Period:</td><td>2021-05-20 15:24:30.0 - ?</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/6ac8e530-7b14-4caa-918b-eb2884762869\">6415c25b-a17f-48dd-a2a6-5f9997a63a41</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/bcb4f481-e089-4971-9ce7-abd93b042fe9\">Encounter/bcb4f481-e089-4971-9ce7-abd93b042fe9</a></td></tr></tbody></table></div>"
    },
    "status": "unknown",
    "class": {
        "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
        "code": "AMB"
    },
    "type": [
        {
            "coding": [
                {
                    "system": "http://fhir.openmrs.org/code-system/encounter-type",
                    "code": "a3c53fd0-1b9b-11eb-8d14-3c6aa7584049",
                    "display": "OPConsultation"
                }
            ]
        }
    ],
    "subject": {
        "reference": "Patient/b6926e3f-502e-fe0a-d62e-553cf8abfc51",
        "type": "Patient",
        "display": "Riya Tyagi (EMR Identifier Number: NEW54935)"
    },
    "participant": [
        {
            "individual": {
                "reference": "Practitioner/844ebcd1-7855-45d3-91ee-0a932663b838",
                "type": "Practitioner",
                "display": "Abc Tyagi"
            }
        }
    ],
    "period": {
        "start": "2021-07-20T15:24:30+05:30"
    },
    "location": [
        {
            "location": {
                "reference": "Location/6ac8e530-7b14-4caa-918b-eb2884762869",
                "type": "Location",
                "display": "6415c25b-a17f-48dd-a2a6-5f9997a63a41"
            }
        }
    ],
    "partOf": {
        "reference": "Encounter/bcb4f481-e089-4971-9ce7-abd93b042fe9",
        "type": "Encounter"
    }
}

I’m getting this error after posting it -

{
    "resourceType": "OperationOutcome",
    "text": {
        "status": "generated",
        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Failed to call access method: org.hibernate.exception.ConstraintViolationException: could not execute statement</pre></td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
    },
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "Failed to call access method: org.hibernate.exception.ConstraintViolationException: could not execute statement"
        }
    ]
}

It says - Column ‘encounter_id’ cannot be null Here are the complete logs for the same - Sep 15 16:05:41 ip-172-31-1-47 server: ERROR - SqlExceptionHelper.logExceptions( - Pastebin.com

Kindly help me resolving this issue.

@chughrahul could you remove "id": "{{EncounterId}}", and post again to create the encounter … If you are updating an existing encounter then provide the actual id ie "id": "6ae64896-2ec9-4c41-8aae-6731856d6a84",