private boolean hasDescription(Type fixed) { if (fixed instanceof Coding) { return ((Coding) fixed).hasDisplay(); } else if (fixed instanceof CodeableConcept) { CodeableConcept cc = (CodeableConcept) fixed; if (cc.hasText()) return true; for (Coding c : cc.getCoding()) if (c.hasDisplay()) return true; } // (fixed instanceof CodeType) || (fixed instanceof Quantity); return false; }
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()"); }
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; }
private boolean hasDescription(Type fixed) { if (fixed instanceof Coding) { return ((Coding) fixed).hasDisplay(); } else if (fixed instanceof CodeableConcept) { CodeableConcept cc = (CodeableConcept) fixed; if (cc.hasText()) return true; for (Coding c : cc.getCoding()) if (c.hasDisplay()) return true; } // (fixed instanceof CodeType) || (fixed instanceof Quantity); return false; }
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; }
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()"); }
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; }
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; }