/** * @return Returns true if this Obs is complex. * @since 1.5 * @should return true if the concept is complex */ public boolean isComplex() { if (getConcept() != null) { return getConcept().isComplex(); } return false; }
/** * Get the concept description that is tied to the concept name that was used when making this * observation * * @return ConceptDescription the description used */ public ConceptDescription getConceptDescription() { // if we don't have a question for this concept, // then don't bother looking for a description if (getConcept() == null) { return null; } // ABKTOD: description in which locale? return concept.getDescription(); }
log.debug("getConcept() == " + getConcept()); if (getConcept() != null && !StringUtils.isBlank(s)) { String abbrev = getConcept().getDatatype().getHl7Abbreviation(); if ("BIT".equals(abbrev)) { setValueBoolean(Boolean.valueOf(s));
/** * @see org.openmrs.api.ObsService#getHandler(org.openmrs.Obs) */ @Override @Transactional(readOnly = true) public ComplexObsHandler getHandler(Obs obs) throws APIException { if (obs.getConcept().isComplex()) { // Get the ConceptComplex from the ConceptService then return its // handler. if (obs.getConcept() == null) { throw new APIException("Obs.error.unable.get.handler", new Object[] { obs }); } String handlerString = Context.getConceptService().getConceptComplex(obs.getConcept().getConceptId()) .getHandler(); if (handlerString == null) { throw new APIException("Obs.error.unable.get.handler.and.concept", new Object[] { obs, obs.getConcept() }); } return this.getHandler(handlerString); } return null; }
/** * Returns the boolean value if the concept of this obs is of boolean datatype * * @return true or false if value is set otherwise null * @should return true if value coded answer concept is true concept * @should return false if value coded answer concept is false concept */ public Boolean getValueBoolean() { if (getConcept() != null && valueCoded != null && getConcept().getDatatype().isBoolean()) { Concept trueConcept = Context.getConceptService().getTrueConcept(); return trueConcept != null && valueCoded.getId().equals(trueConcept.getId()); } return null; }
/** * Sets the value of this obs to the specified valueBoolean if this obs has a boolean concept. * * @param valueBoolean the boolean value matching the boolean coded concept to set to */ public void setValueBoolean(Boolean valueBoolean) { if (getConcept() != null && getConcept().getDatatype() != null && getConcept().getDatatype().isBoolean()) { if (valueBoolean != null) { setValueCoded(valueBoolean ? Context.getConceptService().getTrueConcept() : Context .getConceptService().getFalseConcept()); } else { setValueCoded(null); } } }
private void handleExistingObsWithComplexConcept(Obs obs) { ComplexData complexData = obs.getComplexData(); Concept concept = obs.getConcept(); if (null != concept && concept.isComplex() && null != complexData && null != complexData.getData()) { // save or update complexData object on this obs // this is done before the database save so that the obs.valueComplex // can be filled in by the handler. ComplexObsHandler handler = getHandler(obs); if (null != handler) { handler.saveObs(obs); } else { throw new APIException("unknown.handler", new Object[] {concept}); } } }
if (getConcept() != null) { String abbrev = getConcept().getDatatype().getHl7Abbreviation(); if ("BIT".equals(abbrev)) { return getValueAsBoolean() == null ? "" : getValueAsBoolean().toString(); return ""; } else { if (getConcept() instanceof ConceptNumeric) { ConceptNumeric cn = (ConceptNumeric) getConcept(); if (!cn.getAllowDecimal()) { double d = getValueNumeric();
/** * @see ObsService#getObs(Integer) */ @Test public void getObs_shouldGetObsMatchingGivenObsId() { ObsService obsService = Context.getObsService(); Obs obs = obsService.getObs(7); Assert.assertEquals(5089, obs.getConcept().getId().intValue()); }
new Object[] { obs.getConcept().getConceptId() }, null)); Concept c = Context.getConceptService().getConcept(obs.getConcept().getConceptId()); obs.setConcept(c); String title = null;
if (groupedConceptIds.contains(obs.getConcept().getConceptId())) { groupedObsCount += 1; assertEquals("All of the parent groups should match", obsGroup, obs.getObsGroup());
@Test public void newInstance_shouldCopyMostFields() throws Exception { Obs obs = new Obs(); obs.setStatus(Obs.Status.PRELIMINARY); obs.setInterpretation(Obs.Interpretation.LOW); obs.setConcept(new Concept()); obs.setValueNumeric(1.2); Obs copy = Obs.newInstance(obs); // these fields are not copied assertThat(copy.getObsId(), nullValue()); assertThat(copy.getUuid(), not(obs.getUuid())); // other fields are copied assertThat(copy.getConcept(), is(obs.getConcept())); assertThat(copy.getValueNumeric(), is(obs.getValueNumeric())); assertThat(copy.getStatus(), is(obs.getStatus())); assertThat(copy.getInterpretation(), is(obs.getInterpretation())); // TODO test that the rest of the fields are set }
.getValueNumeric(), obs.getValueText(), obs); Concept concept = obs.getConcept(); ConceptDatatype conceptDatatype;
@Test public void setValueBoolean_shouldNotSetValueForNonBooleanConcept() throws Exception { Obs obs = createObs(2); ConceptDatatype dataType = new ConceptDatatype(); dataType.setUuid(ConceptDatatype.CODED_UUID); obs.getConcept().setDatatype(dataType); assertNotNull(obs.getValueCoded()); obs.setValueBoolean(null); assertNotNull(obs.getValueCoded()); } }
/** * @see Obs#isDirty() */ @Test public void isDirty_shouldReturnFalseWhenNoChangeHasBeenMade() throws Exception { assertFalse(new Obs().isDirty()); //Should also work if setters are called with same values as the original Obs obs = createObs(2); obs.setGroupMembers(new LinkedHashSet<>()); obs.getConcept().setDatatype(new ConceptDatatype()); assertFalse(obs.isDirty()); BeanUtils.copyProperties(obs, BeanUtils.cloneBean(obs)); assertFalse(obs.isDirty()); obs = createObs(null); obs.setGroupMembers(new LinkedHashSet<>()); obs.getConcept().setDatatype(new ConceptDatatype()); assertFalse(obs.isDirty()); BeanUtils.copyProperties(obs, BeanUtils.cloneBean(obs)); assertFalse(obs.isDirty()); }
/** * Display string for Obs * * @param obs * @return String ConceptName = value */ @PropertyGetter("display") public String getDisplayString(Obs obs) { if (obs.getConcept() == null) return ""; return obs.getConcept().getName() + ": " + obs.getValueAsString(Context.getLocale()); }
private Concept findObsCodedValue(Encounter encounter, Concept concept) { for (Obs candidate : encounter.getAllObs(false)) { if (candidate.getConcept().equals(concept)) { return candidate.getValueCoded(); } } return null; }
Concept c = obs.getConcept(); if (c == null) { errors.rejectValue("concept", "error.null");
assertEquals(patient, saved.getPerson()); assertEquals(comment, saved.getComment()); assertEquals(concept, saved.getConcept()); assertEquals(encounter, saved.getEncounter()); assertEquals(DateUtil.truncateToSeconds(datetime), saved.getObsDatetime());
Obs newObs = new Obs(obsToCopy.getPerson(), obsToCopy.getConcept(), obsToCopy.getObsDatetime(), obsToCopy.getLocation());