I’m working on RA-1089 which requires me to create a way to delete(essentially void) a patient from the ref app. I’ve been quite successful in the implementation, except for the fact that I can’t pass in the parameter to the ‘void_reason’.
Here is the JS code. I am creating an AJAX in jQuery to make the REST call:
jq.ajax({
url: '/openmrs/ws/rest/v1/patient/'+delPatient.patientUUID,
type: 'DELETE',
body: {
"void_reason": deleteReason //Already obtained input from user
},
success: function() {
emr.successMessage('coreapps.task.deletePatient.deletePatientSuccessful');
jq('#delete-patient-creation-dialog' + ' .icon-spin').css('display', 'inline-block').parent().addClass('disabled');
delPatient.deletePatientCreationDialog.close();
jq(setTimeout(delPatient.goToReturnUrl, 1285)); //Allow the success message to display before redirecting to another page
},
error: function() {
emr.errorMessage("coreapps.task.deletePatient.deletePatientUnsuccessful");
delPatient.deletePatientCreationDialog.close();
}
});
Now, when I make a GET request for the same patient through REST, I don’t see void_reason inserted. All I see is ‘web application request’ or something. How do I resolve this issue?
I’m making the call from the coreapps module. Here is the PR
Not sure what you mean at ‘this point’. I noted the uuid of the patient, deleted him, and then sent a GET request to http://localhost:8080/openmrs/ws/rest/v1/patient/d3adeed6-42b1-4228-ab79-2cc1c74ebc5a?v=full where the voidReason is listed as web service call.
I meant put a breakpoint in the code at the line I linked to and make sure your reason is correctly received.
Are you sure the patient you are trying to void is not already voided, since I can see from the code that we’ll bail out early if they are (and therefore not set the void reason).