/** * @see Obs#getValueAsBoolean() */ @Test public void getValueAsBoolean_shouldReturnTrueForValue_numericConceptsIfValueIs1() throws Exception { Obs obs = new Obs(); obs.setValueNumeric(1.0); Assert.assertEquals(true, obs.getValueAsBoolean()); }
/** * @see Obs#getValueAsBoolean() */ @Test public void getValueAsBoolean_shouldReturnNullForValue_numericConceptsIfValueIsNeither1Nor0() throws Exception { Obs obs = new Obs(); obs.setValueNumeric(24.8); Assert.assertNull(obs.getValueAsBoolean()); }
/** * @see Obs#getValueAsBoolean() */ @Test public void getValueAsBoolean_shouldReturnFalseForValue_numericConceptsIfValueIs0() throws Exception { Obs obs = new Obs(); obs.setValueNumeric(0.0); Assert.assertEquals(false, obs.getValueAsBoolean()); }
String abbrev = getConcept().getDatatype().getHl7Abbreviation(); if ("BIT".equals(abbrev)) { return getValueAsBoolean() == null ? "" : getValueAsBoolean().toString(); } else if ("CWE".equals(abbrev)) { if (getValueCoded() == null) {
this(obs.getObsDatetime(), null, obs.getValueAsBoolean(), obs.getValueCoded(), obs.getValueDatetime(), obs .getValueNumeric(), obs.getValueText(), obs);
/** * Removes (and returns) an Obs or ObsGroup associated with a specified Concept from existingObs. * Use this version for obs whose concept's datatype is boolean that are checkbox-style. * * @param question - the concept associated with the Obs to remove * @param answer - the boolean value of the Obs * @return */ public Obs removeExistingObs(Concept question, Boolean answer) { List<Obs> list = existingObs.get(question); if (list != null) { for (Iterator<Obs> iter = list.iterator(); iter.hasNext(); ) { Obs test = iter.next(); if (test.getValueAsBoolean() == null) { throw new RuntimeException("Invalid boolean value for concept " + question + "; possibly caused by TRUNK-3150"); } if (answer == test.getValueAsBoolean()) { iter.remove(); if (list.size() == 0) existingObs.remove(question); return test; } } } return null; }
valueWidget.setInitialValue(existingObs.getValueAsBoolean()); } else if (defaultValue != null && Mode.ENTER.equals(context.getMode())) { defaultValue = defaultValue.trim();
MRSObservation convertOpenMRSToMRSObservation(Obs obs) { ConceptDatatype datatype = obs.getConcept().getDatatype(); if (datatype.isAnswerOnly()) { return createMRSObservation(obs, null); } else if (datatype.isBoolean()) { return createMRSObservation(obs, obs.getValueAsBoolean()); } else if (datatype.isDateTime()) { return createMRSObservation(obs, obs.getValueDatetime()); } else if (datatype.isNumeric()) { return createMRSObservation(obs, obs.getValueNumeric()); } else if (datatype.isText()) { return createMRSObservation(obs, obs.getValueText()); } else if (datatype.isCoded()) { return createMRSObservation(obs, new OpenMRSConcept(new OpenMRSConceptName(obs.getValueCoded().getName().getName()))); } else { throw new IllegalArgumentException("Invalid value of the createMRSObservation from DB-" + obs); } }