public static Coding makeCoding(String code) throws FHIRException { String[] parts = code.split("\\|"); Coding c = new Coding(); if (parts.length == 2) { c.setSystem(parts[0]); c.setCode(parts[1]); } else if (parts.length == 3) { c.setSystem(parts[0]); c.setCode(parts[1]); c.setDisplay(parts[2]); } else throw new FHIRException("Unable to understand the code '"+code+"'. Use the format system|code(|display)"); return c; }
public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); copyElement(src, tgt); if (src.hasSystem()) tgt.setSystem(src.getSystem()); if (src.hasVersion()) tgt.setVersion(src.getVersion()); if (src.hasCode()) tgt.setCode(src.getCode()); if (src.hasDisplay()) tgt.setDisplay(src.getDisplay()); if (src.hasUserSelected()) tgt.setUserSelected(src.getUserSelected()); return tgt; }
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case -887328209: return getSystemElement(); case 351608024: return getVersionElement(); case 3059181: return getCodeElement(); case 1671764162: return getDisplayElement(); case 423643014: return getUserSelectedElement(); default: return super.makeProperty(hash, name); } }
public String summary(Coding code) { return code.getSystem()+"#"+code.getCode()+": \""+code.getDisplay()+"\""; }
/** * Convenience constructor * * @param theSystem The {@link #setSystem(String) code system} * @param theCode The {@link #setCode(String) code} * @param theDisplay The {@link #setDisplay(String) human readable display} */ public Coding(String theSystem, String theCode, String theDisplay) { setSystem(theSystem); setCode(theCode); setDisplay(theDisplay); } /**
private void buildCodeableConceptExpression(ElementDefinition ed, StringBuilder expression, String discriminator, CodeableConcept cc) throws DefinitionException { if (cc.hasText()) throw new DefinitionException("Unsupported CodeableConcept pattern - using text - for discriminator(" + discriminator + ") for slice " + ed.getId()); if (!cc.hasCoding() || cc.getCoding().size() > 1) throw new DefinitionException("Unsupported CodeableConcept pattern - must be just one coding - for discriminator(" + discriminator + ") for slice " + ed.getId()); Coding c = cc.getCodingFirstRep(); if (c.hasExtension() || cc.hasExtension()) throw new DefinitionException("Unsupported CodeableConcept pattern - extensions are not allowed - for discriminator(" + discriminator + ") for slice " + ed.getId()); expression.append(" and " + discriminator + ".coding.where("); boolean first = true; if (c.hasSystem()) { first = false; expression.append("system = '"+c.getSystem()+"'"); } if (c.hasVersion()) { if (first) first = false; else expression.append(" and "); expression.append("version = '"+c.getVersion()+"'"); } if (c.hasCode()) { if (first) first = false; else expression.append(" and "); expression.append("code = '"+c.getCode()+"'"); } if (c.hasDisplay()) { if (first) first = false; else expression.append(" and "); expression.append("display = '"+c.getDisplay()+"'"); } expression.append(").exists()"); }
if (coding.hasCode()) { predicates.add(criteriaBuilder.equal(elementJoin.get("myCode"), coding.getCode())); } else { throw new InvalidRequestException("A code must be provided for translation to occur."); if (coding.hasSystem()) { predicates.add(criteriaBuilder.equal(groupJoin.get("mySource"), coding.getSystem())); if (coding.hasVersion()) { predicates.add(criteriaBuilder.equal(groupJoin.get("mySourceVersion"), coding.getVersion()));
public Base translate(TransformContext context, StructureMap map, Base source, String conceptMapUrl, String fieldToReturn) throws FHIRException { Coding src = new Coding(); if (source.isPrimitive()) { src.setCode(source.primitiveValue()); } else if ("Coding".equals(source.fhirType())) { Base[] b = source.getProperty("system".hashCode(), "system", true); if (b.length == 1) src.setSystem(b[0].primitiveValue()); b = source.getProperty("code".hashCode(), "code", true); if (b.length == 1) src.setCode(b[0].primitiveValue()); } else if ("CE".equals(source.fhirType())) { Base[] b = source.getProperty("codeSystem".hashCode(), "codeSystem", true); if (b.length == 1) src.setSystem(b[0].primitiveValue()); b = source.getProperty("code".hashCode(), "code", true); if (b.length == 1) src.setCode(b[0].primitiveValue()); } else throw new FHIRException("Unable to translate source "+source.fhirType()); String uri = worker.oid2Uri(src.getCode()); if (uri == null) uri = "urn:oid:"+src.getCode(); if ("uri".equals(fieldToReturn)) return new UriType(uri); for (ConceptMapGroupComponent g : cmap.getGroup()) { for (SourceElementComponent e : g.getElement()) { if (!src.hasSystem() && src.getCode().equals(e.getCode()))
public org.hl7.fhir.instance.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Coding tgt = new org.hl7.fhir.instance.model.Coding(); copyElement(src, tgt); tgt.setSystem(src.getSystem()); tgt.setVersion(src.getVersion()); tgt.setCode(src.getCode()); tgt.setDisplay(src.getDisplay()); tgt.setUserSelected(src.getUserSelected()); return tgt; }
public org.hl7.fhir.r4.model.Coding convertEncounterClass(org.hl7.fhir.instance.model.Encounter.EncounterClass src) throws FHIRException { if (src == null) return null; switch (src) { case INPATIENT: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("IMP"); case OUTPATIENT: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("AMB"); case AMBULATORY: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("AMB"); case EMERGENCY: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("EMER"); case HOME: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("HH"); case FIELD: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("FLD"); case DAYTIME: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("SS"); case VIRTUAL: return new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/v3/ActCode").setCode("VR"); default: return null; } }
public ValidationResult validateCode(Coding code) throws FHIRException { // first, we validate the concept itself String system = code.hasSystem() ? code.getSystem() : getValueSetSystem(); if (system == null && !code.hasDisplay()) { // dealing with just a plain code (enum) system = systemForCodeInValueSet(code.getCode()); } CodeSystem cs = context.fetchCodeSystem(system); if (cs == null) throw new FHIRException("Unable to resolve system "+system+" - system is not specified or implicit"); if (cs.getContent() != CodeSystemContentMode.COMPLETE) throw new FHIRException("Unable to resolve system "+system+" - system is not complete"); ValidationResult res = validateCode(code, cs); // then, if we have a value set, we check it's in the value set if (res.isOk() && valueset != null && !codeInValueSet(system, code.getCode())) res.setMessage("Not in value set "+valueset.getUrl()).setSeverity(IssueSeverity.ERROR); return res; }
protected void decorateCoding(Complex t, Coding element) { if (!element.hasSystem()) return; if ("http://snomed.info/sct".equals(element.getSystem())) { t.prefix("sct", "http://snomed.info/sct/"); t.predicate("a", "sct:"+element.getCode()); } else if ("http://snomed.info/sct".equals(element.getSystem())) { t.prefix("loinc", "http://loinc.org/rdf#"); t.predicate("a", "loinc:"+element.getCode()); } }
public boolean hasCode() { if (this.code == null) return false; for (Coding item : this.code) if (!item.isEmpty()) return true; return false; }
private void extractTokensFromCoding(List<String> theSystems, List<String> theCodes, ResourceTable theEntity, Set<BaseResourceIndexedSearchParam> theListToPopulate, RuntimeSearchParam theParameterDef, Coding nextCoding) { if (nextCoding != null && !nextCoding.isEmpty()) { String nextSystem = nextCoding.getSystemElement().getValueAsString(); String nextCode = nextCoding.getCodeElement().getValue(); if (isNotBlank(nextSystem) || isNotBlank(nextCode)) { theSystems.add(nextSystem); theCodes.add(nextCode); } if (!nextCoding.getDisplayElement().isEmpty()) { addStringParam(theEntity, theListToPopulate, theParameterDef, nextCoding.getDisplayElement().getValue()); } } }
public org.hl7.fhir.instance.model.Encounter.EncounterClass convertEncounterClass(org.hl7.fhir.r4.model.Coding src) throws FHIRException { if (src == null || src.isEmpty()) return null; if (src.getSystem().equals("http://terminology.hl7.org/v3/ActCode")) { if (src.getCode().equals("IMP")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.INPATIENT; if (src.getCode().equals("AMB")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.AMBULATORY; if (src.getCode().equals("EMER")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.EMERGENCY; if (src.getCode().equals("HH")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.HOME; if (src.getCode().equals("FLD")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.FIELD; if (src.getCode().equals("")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.DAYTIME; if (src.getCode().equals("VR")) return org.hl7.fhir.instance.model.Encounter.EncounterClass.VIRTUAL; } return org.hl7.fhir.instance.model.Encounter.EncounterClass.NULL; }
public Coding addCode() { //3 Coding t = new Coding(); if (this.code == null) this.code = new ArrayList<Coding>(); this.code.add(t); return t; }
public CacheToken generateValidationToken(Coding code, ValueSet vs) { CacheToken ct = new CacheToken(); if (code.hasSystem()) ct.name = getNameForSystem(code.getSystem()); else ct.name = NAME_FOR_NO_SYSTEM; JsonParser json = new JsonParser(); json.setOutputStyle(OutputStyle.PRETTY); ValueSet vsc = getVSEssense(vs); try { ct.request = "{\"code\" : "+json.composeString(code, "code")+", \"valueSet\" :"+(vsc == null ? "null" : json.composeString(vsc))+"}"; } catch (IOException e) { throw new Error(e); } ct.key = String.valueOf(hashNWS(ct.request)); return ct; }
@Override public int hashCode() { return new HashCodeBuilder(17, 37) .append(getCoding().getCode()) .append(getCoding().getSystem()) .append(getCoding().getVersion()) .append(getResourceId()) .append(getSource()) .append(getTarget()) .append(getTargetSystem()) .toHashCode(); } }