Hello Team,
This attempt has been to create a new Patient by POSTing a JSON payload using an API client (POSTMAN in this case) to a locally running OpenMRS SDK server (2.12.2) with the latest FHIR2 module installed.
The first JSON that was POSTed to the end-point “http://localhost:8080/openmrs/ws/fhir2/R4/Patient” was like below:
{
"resourceType": "Patient",
"identifier": {
"extension": [{
"url": "http://fhir.openmrs.org/ext/patient/identifier#location",
"valueReference": {
"reference": "Location/58c57d25-8d39-41ab-8422-108a0c277d98",
"type": "Location"
}
}],
"use": "official",
"type": {
"text": "OpenMRS ID"
},
"value": "1000GW"
},
"name": [
{
"given": [
"Myname"
],
"family": "MyFam"
}
],
"gender": "male",
"birthDate": "1998-07-08",
"address": [
{
"state": "Mystate",
"city": "MyCity",
"country": "MyCountry"
}
]
}
This was returning a 500 server error: “Failed to call access method: org.hibernate.exception.ConstraintViolationException: could not execute statement”
Next, as suggested by a TALK thread, a randomly generated UUID was added to all the main elements of the JSON like below:
{
"resourceType": "Patient",
"identifier": {
"extension": [{
"url": "http://fhir.openmrs.org/ext/patient/identifier#location",
"valueReference": {
"reference": "Location/58c57d25-8d39-41ab-8422-108a0c277d98",
"type": "Location"
}
}],
"use": "official",
"type": {
"text": "OpenMRS ID"
},
"value": "1000GW",
"id": "7c7e89db-538a-411a-a1e2-4fdff74a3a86"
},
"name": [
{
"given": [
"Myname"
],
"family": "MyFam",
"id": "7c7e89db-538a-411a-a1e2-4fdff74a3a86"
}
],
"gender": "male",
"birthDate": "1998-07-08",
"address": [
{
"state": "Mystate",
"city": "MyCity",
"country": "MyCountry",
"id": "7c7e89db-538a-411a-a1e2-4fdff74a3a86"
}
]
}
The second POST was successful. The question here is regarding the UUID that needs to be added to the JSON: What purpose is it really serving? It never gets used later and does not become a part of the Patient record in any way. To retrieve the newly created Patient the UUID that needs to be used is a totally different one (which gets alloted by the server during POST).
Thank you.