/** * @see Obs#isDirty() */ @Test public void isDirty_shouldReturnTrueWhenAnImmutableFieldIsChangedFromANullToANonNullValueInExistingObs() throws Exception { Obs obs = new Obs(5); assertNull(obs.getComment()); obs.setComment("some non null value"); assertTrue(obs.isDirty()); }
/** * @see Obs#isDirty() */ @Test public void isDirty_shouldReturnTrueWhenAnImmutableFieldIsChangedFromANonNullToANullValueForEditedObs() throws Exception { Obs obs = createObs(2); assertNotNull(obs.getComment()); obs.setComment(null); assertTrue(obs.isDirty()); }
/** * @see Obs#isDirty() */ @Test public void isDirty_shouldReturnFalsWhenAnImmutableFieldIsChangedFromANonNullToANullValueForNewObs() throws Exception { Obs obs = createObs(null); assertNotNull(obs.getComment()); obs.setComment(null); assertFalse(obs.isDirty()); }
/** * @see Obs#isDirty() */ @Test public void isDirty_shouldReturnFalseWhenAnImmutableFieldIsChangedFromANullToANonNullValueInNewObs() throws Exception { Obs obs = new Obs(); assertNull(obs.getComment()); obs.setComment("some non null value"); assertFalse(obs.isDirty()); }
while (newObservation == null && thisIndex < newList.size()) { Obs newObs = newList.get(thisIndex++); if (!oldList.contains(newObs) && !newObs.isObsGrouping() && newObs.getComment() != null) newObservation = newObs; Assert.assertEquals("This is a comment that spans two lines", newObservation.getComment());
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditMovedIndependentObservations() throws Exception { //retrieve patients Patient preferred = patientService.getPatient(999); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); //get an observation for notPreferred and make it independent from any encounter Obs obs = Context.getObsService().getObs(7); obs.setEncounter(null); obs.setComment("this observation is for testing the merge"); Context.getObsService().saveObs(obs, "Reason cannot be blank"); //merge the two patients and retrieve the audit object PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); String uuid = null; List<Obs> observations = Context.getObsService().getObservationsByPerson(preferred); for (Obs o : observations) { if (obs.getComment().equals(o.getComment())) { uuid = o.getUuid(); } } Assert.assertTrue("moving of independent observation was not audited", isValueInList(uuid, audit.getPersonMergeLogData().getMovedIndependentObservations())); }
/** * @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String) */ @Test public void parseObs_shouldAddCommentsToAnObservationGroup() throws Exception { ObsService os = Context.getObsService(); String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||23^FOOD CONSTRUCT^99DCT\r" + "NTE|1|L|This is a comment\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206\r" + "NTE|1|L|This should not be considered :-)"; List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(23)); Message hl7message = parser.parse(hl7string); router.processMessage(hl7message); List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(23)); Obs newObservation = null; for (Obs newObs : newList) { if (!oldList.contains(newObs) && newObs.isObsGrouping()) { newObservation = newObs; } } Assert.assertEquals("This is a comment", newObservation.getComment()); }
/** * @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String) */ @Test public void parseObs_shouldAddCommentsToAnObservationFromNTESegments() throws Exception { ObsService os = Context.getObsService(); String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206\r" + "NTE|1|L|This is a comment"; // the expected question for the obs in the hl7 message has to be // numeric Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName()); List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497)); Message hl7message = parser.parse(hl7string); router.processMessage(hl7message); List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497)); Obs newObservation = null; for (Obs newObs : newList) { if (!oldList.contains(newObs) && !newObs.isObsGrouping()) { newObservation = newObs; } } Assert.assertEquals("This is a comment", newObservation.getComment()); }
sb.append(DEFAULT_COLUMN_SEPARATOR); sb.append(DEFAULT_QUOTE); sb.append((o != null && o.getComment() != null) ? o.getComment():EMPTY); sb.append(DEFAULT_QUOTE);
assertEquals(comment, saved.getComment()); assertEquals(concept, saved.getConcept()); assertEquals(encounter, saved.getEncounter());
newObs.setValueModifier(obsToCopy.getValueModifier()); newObs.setValueText(obsToCopy.getValueText()); newObs.setComment(obsToCopy.getComment()); newObs.setEncounter(obsToCopy.getEncounter()); newObs.setCreator(obsToCopy.getCreator());
context.registerErrorWidget(commentFieldWidget, errorWidget); if (existingObs != null) { commentFieldWidget.setInitialValue(existingObs.getComment());
@Override public void testEditedResults(SubmissionResults results) { results.assertNoErrors();; results.assertProvider(502); results.assertLocation(2); results.assertObsCreatedCount(1); Obs locationObs = results.getEncounterCreated().getObs().iterator().next(); Assert.assertEquals("3", locationObs.getValueText()); Assert.assertNull(locationObs.getValueCoded()); Assert.assertEquals("org.openmrs.Location", locationObs.getComment()); };
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertProvider(502); results.assertLocation(2); results.assertObsCreatedCount(1); Obs locationObs = results.getEncounterCreated().getObs().iterator().next(); Assert.assertEquals("2", locationObs.getValueText()); Assert.assertNull(locationObs.getValueCoded()); Assert.assertEquals("org.openmrs.Location", locationObs.getComment()); } }.run();
} else if (datatype.isText()) { if ("org.openmrs.Location".equals(field.getExistingObs().getComment())) { value = locationService.getLocation(new Integer(field.getExistingObs().getValueText())).getName();
if ("org.openmrs.Location".equals(obs.getComment())) { // string first to make it null-safe try { return Context.getLocationService().getLocation(new Integer(obs.getValueText()));
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropPresent("person"); assertPropPresent("concept"); assertPropPresent("value"); assertPropEquals("obsDatetime", getObject().getObsDatetime()); assertPropEquals("accessionNumber", getObject().getAccessionNumber()); assertPropEquals("obsGroup", getObject().getObsGroup()); assertPropPresent("groupMembers"); assertPropEquals("comment", getObject().getComment()); assertPropPresent("location"); assertPropPresent("order"); assertPropPresent("encounter"); assertPropEquals("voided", getObject().getVoided()); }
@Override public void validateFullRepresentation() throws Exception { super.validateFullRepresentation(); assertPropPresent("person"); assertPropPresent("concept"); assertPropPresent("value"); assertPropEquals("obsDatetime", getObject().getObsDatetime()); assertPropEquals("accessionNumber", getObject().getAccessionNumber()); assertPropEquals("obsGroup", getObject().getObsGroup()); assertPropPresent("groupMembers"); assertPropEquals("comment", getObject().getComment()); assertPropPresent("location"); assertPropPresent("order"); assertPropPresent("encounter"); assertPropEquals("voided", getObject().getVoided()); assertPropPresent("auditInfo"); }