public String summary(Coding code) { return code.getSystem()+"#"+code.getCode()+": \""+code.getDisplay()+"\""; }
@Override public ValidationResult validateCode(Coding theCode, ValueSet theVs) { String system = theCode.getSystem(); String code = theCode.getCode(); String display = theCode.getDisplay(); return validateCode(system, code, display, theVs); }
} else if (o instanceof Coding) { Coding t = (Coding)o; val = (t.getSystem()==null ? "" : t.getSystem()) + (t.getCode()==null ? "" : "#" + t.getCode()) + (t.getDisplay()==null ? "" : " (" + t.getDisplay() + ")"); } else if (o instanceof ElementDefinitionConstraintComponent) { ElementDefinitionConstraintComponent c = (ElementDefinitionConstraintComponent)o;
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()"); }
private ValidationResult validateCode(Coding code, CodeSystem cs) { ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code.getCode()); if (cc == null) return new ValidationResult(IssueSeverity.ERROR, "Unknown Code "+code+" in "+cs.getUrl()); if (code.getDisplay() == null) return new ValidationResult(cc); CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (cc.hasDisplay()) { b.append(cc.getDisplay()); if (code.getDisplay().equalsIgnoreCase(cc.getDisplay())) return new ValidationResult(cc); } for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) { b.append(ds.getValue()); if (code.getDisplay().equalsIgnoreCase(ds.getValue())) return new ValidationResult(cc); } return new ValidationResult(IssueSeverity.WARNING, "Display Name for "+code+" must be one of '"+b.toString()+"'", cc); }
private Piece describeCoded(HierarchicalTableGenerator gen, Type fixed) { if (fixed instanceof Coding) { Coding c = (Coding) fixed; ValidationResult vr = context.validateCode(c.getSystem(), c.getCode(), c.getDisplay()); if (vr.getDisplay() != null) return gen.new Piece(null, " ("+vr.getDisplay()+")", null).addStyle("color: darkgreen"); } else if (fixed instanceof CodeableConcept) { CodeableConcept cc = (CodeableConcept) fixed; for (Coding c : cc.getCoding()) { ValidationResult vr = context.validateCode(c.getSystem(), c.getCode(), c.getDisplay()); if (vr.getDisplay() != null) return gen.new Piece(null, " ("+vr.getDisplay()+")", null).addStyle("color: darkgreen"); } } return null; }
private void validateAnswerCode(List<ValidationMessage> errors, Element value, NodeStack stack, Questionnaire qSrc, String ref, boolean theOpenChoice) { ValueSet vs = resolveBindingReference(qSrc, ref, qSrc.getUrl()); if (warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), vs != null, "ValueSet " + describeReference(ref) + " not found")) { try { Coding c = ObjectConverter.readAsCoding(value); if (isBlank(c.getCode()) && isBlank(c.getSystem()) && isNotBlank(c.getDisplay())) { if (theOpenChoice) { return; } } long t = System.nanoTime(); ValidationResult res = context.validateCode(c, vs); txTime = txTime + (System.nanoTime() - t); if (!res.isOk()) { txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, "The value provided (" + c.getSystem() + "::" + c.getCode() + ") is not in the options value set in the questionnaire"); } else if (res.getSeverity() != null) { super.addValidationMessage(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), res.getMessage(), res.getSeverity(), Source.TerminologyEngine); } } catch (Exception e) { warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, "Error " + e.getMessage() + " validating Coding against Questionnaire Options"); } } }
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 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; }
public String summary(Coding code) { return code.getSystem()+"#"+code.getCode()+": \""+code.getDisplay()+"\""; }
@Override public ValidationResult validateCode(Coding theCode, ValueSet theVs) { String system = theCode.getSystem(); String code = theCode.getCode(); String display = theCode.getDisplay(); return validateCode(system, code, display, theVs); }
} else if (o instanceof Coding) { Coding t = (Coding)o; val = (t.getSystem()==null ? "" : t.getSystem()) + (t.getCode()==null ? "" : "#" + t.getCode()) + (t.getDisplay()==null ? "" : " (" + t.getDisplay() + ")"); } else if (o instanceof ElementDefinitionConstraintComponent) { ElementDefinitionConstraintComponent c = (ElementDefinitionConstraintComponent)o;
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()"); }
private ValidationResult validateCode(Coding code, CodeSystem cs) { ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code.getCode()); if (cc == null) return new ValidationResult(IssueSeverity.ERROR, "Unknown Code "+code+" in "+cs.getUrl()); if (code.getDisplay() == null) return new ValidationResult(cc); CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (cc.hasDisplay()) { b.append(cc.getDisplay()); if (code.getDisplay().equalsIgnoreCase(cc.getDisplay())) return new ValidationResult(cc); } for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) { b.append(ds.getValue()); if (code.getDisplay().equalsIgnoreCase(ds.getValue())) return new ValidationResult(cc); } return new ValidationResult(IssueSeverity.WARNING, "Display Name for "+code+" must be one of '"+b.toString()+"'", cc); }
private Piece describeCoded(HierarchicalTableGenerator gen, Type fixed) { if (fixed instanceof Coding) { Coding c = (Coding) fixed; ValidationResult vr = context.validateCode(c.getSystem(), c.getCode(), c.getDisplay()); if (vr.getDisplay() != null) return gen.new Piece(null, " ("+vr.getDisplay()+")", null).addStyle("color: darkgreen"); } else if (fixed instanceof CodeableConcept) { CodeableConcept cc = (CodeableConcept) fixed; for (Coding c : cc.getCoding()) { ValidationResult vr = context.validateCode(c.getSystem(), c.getCode(), c.getDisplay()); if (vr.getDisplay() != null) return gen.new Piece(null, " ("+vr.getDisplay()+")", null).addStyle("color: darkgreen"); } } return null; }
private void validateAnswerCode(List<ValidationMessage> errors, Element value, NodeStack stack, Questionnaire qSrc, String ref, boolean theOpenChoice) { ValueSet vs = resolveBindingReference(qSrc, ref, qSrc.getUrl()); if (warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), vs != null, "ValueSet " + describeReference(ref) + " not found")) { try { Coding c = ObjectConverter.readAsCoding(value); if (isBlank(c.getCode()) && isBlank(c.getSystem()) && isNotBlank(c.getDisplay())) { if (theOpenChoice) { return; } } long t = System.nanoTime(); ValidationResult res = context.validateCode(c, vs); txTime = txTime + (System.nanoTime() - t); if (!res.isOk()) { txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, "The value provided (" + c.getSystem() + "::" + c.getCode() + ") is not in the options value set in the questionnaire"); } else if (res.getSeverity() != null) { super.addValidationMessage(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), res.getMessage(), res.getSeverity(), Source.TerminologyEngine); } } catch (Exception e) { warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, "Error " + e.getMessage() + " validating Coding against Questionnaire Options"); } } }
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 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; }