patient.setDead(true); patient.setDeathDate(deathDate); patient.setCauseOfDeath(cause);
@Test public void validate_shouldFailValidationWhenDeathCauseAndDeathCauseNonCodedAreSet() { Patient pa = new Patient(1); pa.setDead(true); pa.setCauseOfDeathNonCoded("Some text describing Cause of Death"); pa.setCauseOfDeath(new Concept()); Errors errors = new BindException(pa, "patient"); validator.validate(pa, errors); Assert.assertTrue(errors.hasFieldErrors("causeOfDeath")); Assert.assertEquals("Person.dead.shouldHaveOnlyOneCauseOfDeathOrCauseOfDeathNonCodedSet", errors.getFieldError("causeOfDeath").getCode()); }
private void mergeDateOfDeath(Patient preferred, Patient notPreferred, PersonMergeLogData mergedData) { mergedData.setPriorDateOfDeath(preferred.getDeathDate()); if (preferred.getDeathDate() == null) { preferred.setDeathDate(notPreferred.getDeathDate()); } if (preferred.getCauseOfDeath() != null) { mergedData.setPriorCauseOfDeath(preferred.getCauseOfDeath().getUuid()); } if (preferred.getCauseOfDeath() == null) { preferred.setCauseOfDeath(notPreferred.getCauseOfDeath()); } }
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditPriorDateOfDeath() throws Exception { //retrieve preferred patient and set a date of birth GregorianCalendar cDate = new GregorianCalendar(); cDate.setTime(new Date()); //milliseconds are not serialized into the database. they will be ignored in the test cDate.set(Calendar.MILLISECOND, 0); Patient preferred = patientService.getPatient(999); preferred.setDeathDate(cDate.getTime()); preferred.setDead(true); preferred.setCauseOfDeath(Context.getConceptService().getConcept(3)); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertEquals("prior date of death was not audited", cDate.getTime(), audit.getPersonMergeLogData() .getPriorDateOfDeath()); }
patient.setCauseOfDeath(causeOfDeath); this.savePatient(patient); saveCauseOfDeathObs(patient, dateDied, causeOfDeath, otherReason);
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditPriorDateOfDeathEstimated() throws Exception { //retrieve preferred patient and set a date of death GregorianCalendar cDate = new GregorianCalendar(); cDate.setTime(new Date()); Patient preferred = patientService.getPatient(999); preferred.setDeathDate(cDate.getTime()); preferred.setDeathdateEstimated(true); preferred.setCauseOfDeath(Context.getConceptService().getConcept(3)); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertTrue("prior estimated date of death was not audited", audit.getPersonMergeLogData() .getPriorDateOfDeathEstimated()); }
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditPriorCauseOfDeath() throws Exception { //retrieve preferred patient and set a cause of death Patient preferred = patientService.getPatient(999); preferred.setCauseOfDeath(Context.getConceptService().getConcept(3)); preferred.setDeathDate(new Date()); preferred.setDead(true); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); //merge with not preferred Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertEquals("prior cause of death was not audited", Context.getConceptService().getConcept(3).getUuid(), audit.getPersonMergeLogData().getPriorCauseOfDeath()); }
patient.setBirthdateEstimated(true); patient.setDeathDate(new Date()); patient.setCauseOfDeath(new Concept(1)); patient.setGender("male"); List<PatientIdentifierType> patientIdTypes = ps.getAllPatientIdentifierTypes();
patient.setBirthdateEstimated(true); patient.setDeathDate(new Date()); patient.setCauseOfDeath(new Concept()); patient.setGender("male"); patient.setDeathdateEstimated(true);
preferred.setCauseOfDeath(notPreferred.getCauseOfDeath());
patient.setBirthdateEstimated(true); patient.setDeathDate(new Date()); patient.setCauseOfDeath(new Concept()); patient.setGender("male");
/** * Marks a patient as dead with the given date of death and comment * * @param motechId Deceased patient's MOTECH id * @param conceptName Concept name for tracking deceased patients * @param dateOfDeath Patient's date of death * @param comment Additional information for the cause of death * @throws PatientNotFoundException Throws this exception if patient with the given MOTECH id does not exists */ @Override public void deceasePatient(String motechId, String conceptName, Date dateOfDeath, String comment) throws PatientNotFoundException { org.openmrs.Patient patient = getOpenmrsPatientByMotechId(motechId); if (patient == null) { throw new PatientNotFoundException("Patient for the MOTECH ID: " + motechId + " is not found"); } patient.setDeathDate(dateOfDeath); patient.setDead(true); Concept concept = openMrsConceptAdapter.getConceptByName(conceptName); patient.setCauseOfDeath(concept); patientService.savePatient(patient); patientService.saveCauseOfDeathObs(patient, dateOfDeath, concept, comment); eventRelay.sendEventMessage(new MotechEvent(EventKeys.PATIENT_DECEASED_SUBJECT, EventHelper.patientParameters(getMrsPatient(patient)))); }
@Override public void applyAction(FormEntrySession session) { Patient patient = session.getPatient(); Encounter encounter = session.getEncounter(); patient.setDead(true); if (deathDateFromEncounter) { if (patient.getDeathDate() == null || !preserveExistingDeathDate) { patient.setDeathDate(encounter.getEncounterDatetime()); } } if (patient.getCauseOfDeath() == null || !preserveExistingCauseOfDeath) { Concept causeOfDeath = null; if (causeOfDeathFromObs != null) { causeOfDeath = findObsCodedValue(session.getEncounter(), causeOfDeathFromObs); } if (causeOfDeath == null) { // don't overwrite with Unknown, even if we haven't specifically said to preserve existing causeOfDeath = patient.getCauseOfDeath(); } if (causeOfDeath == null) { causeOfDeath = getUnknownConcept(); } patient.setCauseOfDeath(causeOfDeath); } patientService.savePatient(patient); }