Unable to POST Encounter with FHIR

Application Name: Reference Application

Version Number: 2.13.0-SNAPSHOT (OpenMRS version 2.6.0 SNAPSHOT Build 0)

FHIR2 Module Version: 1.6.0-SNAPSHOT

Hi, I’m trying to POST an Encounter ressource through the FHIR2 module API and I am unable to do so. So far, I’ve been able to POST both visits(on the /Encounter route) and Observation ressources, but not Encounter. I’m also able to GET Encounter (those I created through the application’s frontend), Patient, Observation and visits. I am sure that both my subject (patient) and partOf (visit) references exist in my database.

Error I’m receiving: Failed to call access method: org.hibernate.exception.ConstraintViolationException: could not execute statement

Request Body : https://pastebin.com/WwZYsjVx

Log : https://pastebin.com/gwMu8gmc

In the log I can see : “Caused by: java.sql.SQLIntegrityConstraintViolationException: Column ‘encounter_id’ cannot be null” That seems pretty weird to me, as the id should be created by the back end and not be specified in my json body.

Thanks in advance

If this helps in any way, the ids in the database are skipping over the ids that would’ve been used for the POST requests that fail.

I found that out by POSTing Encounters on the REST API instead of the FHIR API, but since I need to use the FHIR API, this is not really fixing my issue

In other words, I had ids 1 to 4 used already, never deleted any Encounter and the next one was id 21. Then I made another failed FHIR request followed by another REST API request and the last id was 23.

I figured it out by myself, or a work around at the very least. POSTing the Encounter without the “participant” attribute worked. Maybe it’s an attribute that shouldn’t be added at all or maybe it was because the participant was the “Super User”.