/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void purge(Patient patient, RequestContext context) throws ResponseException { if (patient == null) { // DELETE is idempotent, so we return success here return; } Context.getPatientService().purgePatient(patient); }
@SkipBaseSetup @Test public void purgePatient_shouldDeletePatientFromDatabase() throws Exception { initializeInMemoryDatabase(); executeDataSet(FIND_PATIENTS_XML); authenticate(); // verify patient with ID 2 exists in database Patient patientToPurge = patientService.getPatient(2); assertNotNull(patientToPurge); // purge the patient patientService.purgePatient(patientToPurge); // if the patient doesn't exist in the database, getPatient should // return null now assertNull(patientService.getPatient(2)); }
@Override public void deletePatient(MRSPatient patient) throws PatientNotFoundException { Patient existingOpenMrsPatient = getOpenmrsPatientByMotechId(patient.getMotechId()); if (existingOpenMrsPatient == null) { throw new PatientNotFoundException("The patient by motech Id: " + patient.getMotechId() + " was not found in the database."); } else { patientService.purgePatient(existingOpenMrsPatient); eventRelay.sendEventMessage(new MotechEvent(EventKeys.DELETED_PATIENT_SUBJECT, EventHelper.patientParameters(patient))); } } }
patient.addIdentifier(ident3); patientService.savePatient(patient); patientService.purgePatient(patient); patient.removeIdentifier(ident3); ident4.setPreferred(true);