/** * Builds a coded result from an observation * * @param obs */ public Result(Obs obs) { this( obs.getObsDatetime(), null, obs.getValueAsBoolean(), obs.getValueCoded(), obs.getValueDatetime(), obs.getValueNumeric(), obs.getValueText(), obs); Concept concept = obs.getConcept(); ConceptDatatype conceptDatatype = null; if (concept != null) { conceptDatatype = concept.getDatatype(); if (conceptDatatype == null) { return; } if (conceptDatatype.isCoded()) { this.datatype = Datatype.CODED; } else if (conceptDatatype.isNumeric()) { this.datatype = Datatype.NUMERIC; } else if (conceptDatatype.isDate()) { this.datatype = Datatype.DATETIME; } else if (conceptDatatype.isText()) { this.datatype = Datatype.TEXT; } else if (conceptDatatype.isBoolean()) { this.datatype = Datatype.BOOLEAN; } } }
/** * Gets a concept by an identifier (mapping or UUID) * * @param identifier the identifier * @return the concept * @throws org.openmrs.module.metadatadeploy.MissingMetadataException if the concept could not be * found */ public static Concept getConcept(String identifier) { Concept concept; if (identifier.contains(":")) { String[] tokens = identifier.split(":"); concept = Context.getConceptService().getConceptByMapping(tokens[1].trim(), tokens[0].trim()); } else { // Assume it's a UUID concept = Context.getConceptService().getConceptByUuid(identifier); } if (concept == null) { throw new MissingMetadataException(Concept.class, identifier); } // getConcept doesn't always return ConceptNumeric for numeric concepts if (concept.getDatatype().isNumeric() && !(concept instanceof ConceptNumeric)) { concept = Context.getConceptService().getConceptNumeric(concept.getId()); if (concept == null) { throw new MissingMetadataException(ConceptNumeric.class, identifier); } } return concept; }
private void assertMappedCorrectly() { Concept concept = Context.getConceptService().getConceptByUuid("23423a2982236623"); if (concept.isNumeric()) { Assert.fail(); } Assert.assertEquals("N/A", concept.getDatatype().getName()); }
public ConceptSearchResult(Concept con) { this.conceptId = con.getConceptId(); if (con.getName() != null) { this.conceptName = con.getName().getName(); } if (con.getDescription() != null) { this.conceptDescription = con.getDescription().getDescription(); } if (con.getConceptClass() != null) { this.conceptClass = con.getConceptClass().getName(); } if (con.getDatatype() != null) { this.conceptDatatype = con.getDatatype().getName(); } this.otherNames = new Vector<String>(); for (ConceptName cn : con.getNames()) { this.otherNames.add(cn.getName()); } }