@Test
	public void processMessage_shouldSetValue_CodedMatchingABooleanConceptForObsIfTheAnswerIs0Or1AndQuestionDatatypeIsCoded()
	        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|2|NM|21^CIVIL STATUS^99DCT||1|||||||||20080206";
		// the expected question for the obs in the hl7 message has to be coded
		Assert.assertEquals("Coded", Context.getConceptService().getConcept(21).getDatatype().getName());
		List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(21));
		Message hl7message = parser.parse(hl7string);
		router.processMessage(hl7message);
		// hacky way to get the newly added obs and make tests on it
		List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(21));
		Obs newObservation = null;
		for (Obs newObs : newList) {
			if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
				newObservation = newObs;
			}
		}
		Assert.assertEquals(Context.getConceptService().getTrueConcept(), newObservation.getValueCoded());
	}
@Test
	public void processMessage_shouldSetValue_CodedMatchingABooleanConceptForObsIfTheAnswerIs0Or1AndQuestionDatatypeIsCoded()
	        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|2|NM|21^CIVIL STATUS^99DCT||1|||||||||20080206";
	
		Assert.assertEquals("Coded", Context.getConceptService().getConcept(21).getDatatype().getName());
		List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(21));
		Message hl7message = parser.parse(hl7string);
		router.processMessage(hl7message);
	
		List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(21));
		Obs newObservation = null;
		for (Obs newObs : newList) {
			if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
				newObservation = newObs;
			}
		}
		Assert.assertEquals(Context.getConceptService().getTrueConcept(), newObservation.getValueCoded());
	}
@test public void processmessage_shouldsetvalue_codedmatchingabooleanconceptforobsiftheansweris0or1andquestiondatatypeiscoded() 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|2|nm|21^civil status^99dct||1|||||||||20080206"; assert.assertequals("coded", context.getconceptservice().getconcept(21).getdatatype().getname()); list<obs> oldlist = os.getobservationsbypersonandconcept(new person(7), new concept(21)); message hl7message = parser.parse(hl7string); router.processmessage(hl7message); list<obs> newlist = os.getobservationsbypersonandconcept(new person(7), new concept(21)); obs newobservation = null; for (obs newobs : newlist) { if (!oldlist.contains(newobs) && !newobs.isobsgrouping()) { newobservation = newobs; } } assert.assertequals(context.getconceptservice().gettrueconcept(), newobservation.getvaluecoded()); }