I am using hapi-fhir sdk in Android. I got ResourceVersionConflictException
for Patient
update. From api doc
Represents an HTTP 409 Conflict response. This exception should be thrown in methods which accept a version (e.g. Update, Delete) when the operation fails because of a version conflict as specified in the FHIR specification.
how is version conflict happening here. I am just updating Given
name and calling client.update()
Here is my sample code;
Patient read:
val patient = client.read()
.resource(Patient::class.java)
.withId(id)
.encodedJson()
.execute()
Update:
val newName = .....
val humanName = if (patient.name == null){
patient.addName()
}else{
if (patient.name.isEmpty()){ patient.addName() } else patient.name[0]
}
// updating given name
if (humanName.given.isEmpty()){
humanName.addGiven(newName)
}else{
humanName.given[0].value = newName
}
// update api call
client.update()
.resource(patient)
.encodedJson()
.execute()
I am getting ResourceVersionConflictException
for this update call. I am missing something. How can i update patient?
Thanks in advance.