use of org.openmrs.api.ObsService in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldNotCreateProblemListObservationWithConceptProposals.
/**
* Tests that a ConceptProposal row can be written by the processor
*
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldNotCreateProblemListObservationWithConceptProposals() throws Exception {
ObsService obsService = Context.getObsService();
ConceptService conceptService = Context.getConceptService();
EncounterService encService = Context.getEncounterService();
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080630094800||ORU^R01|kgWdFt0SVwwClOfJm3pe|P|2.5|1||||||||15^AMRS.ELD.FORMID\r" + "PID|||3^^^^~d3811480^^^^||John3^Doe^||\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20080208|||||||V\r" + "ORC|RE||||||||20080208000000|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBR|1|||1284^PROBLEM LIST^99DCT\r" + "OBX|1|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^SEVERO DOLOR DE CABEZA^99DCT|||||||||20080208";
Message hl7message = parser.parse(hl7String);
router.processMessage(hl7message);
Patient patient = new Patient(3);
// check for any obs
assertEquals("There should not be any obs created for #3", 0, obsService.getObservationsByPerson(patient).size());
// check for a new encounter
assertEquals("There should be 1 new encounter created for #3", 1, encService.getEncountersByPatient(patient).size());
// check for the proposed concept
List<ConceptProposal> proposedConcepts = conceptService.getConceptProposals("SEVERO DOLOR DE CABEZA");
assertEquals("There should be a proposed concept by this name", 1, proposedConcepts.size());
assertEquals(encService.getEncountersByPatient(patient).get(0), proposedConcepts.get(0).getEncounter());
}
use of org.openmrs.api.ObsService in project openmrs-core by openmrs.
the class ORUR01HandlerTest method parseObs_shouldAddMultipleCommentsForAnObservationAsOneComment.
/**
* @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
*/
@Test
public void parseObs_shouldAddMultipleCommentsForAnObservationAsOneComment() 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\r" + "NTE|2|L|that spans two lines\r" + "OBX|2|NM|5497^CD4, BY FACS^99DCT||2|||||||||20080206";
// 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));
// get the new observation with a not-null comment; not interested in
// the other one
Obs newObservation = null;
int thisIndex = 0;
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());
}
Aggregations