private ValidationResult verifyCodeInCodeSystem( CodeSystem cs, String system, String code, String display) throws Exception { ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code); if (cc == null) if (cs.getContent().equals(CodeSystem.CodeSystemContentMode.COMPLETE)) return new ValidationResult( IssueSeverity.ERROR, "Unknown Code " + code + " in " + cs.getUrl()); else if (!cs.getContent().equals(CodeSystem.CodeSystemContentMode.NOTPRESENT)) return new ValidationResult( IssueSeverity.WARNING, "Unknown Code " + code + " in partial code list of " + cs.getUrl()); else return verifyCodeExternal( null, new Coding().setSystem(system).setCode(code).setDisplay(display), false); // // return new ValidationResult(IssueSeverity.WARNING, "A definition was found for // "+cs.getUrl()+", but it has no codes in the definition"); // return new ValidationResult(IssueSeverity.ERROR, "Unknown Code "+code+" in // "+cs.getUrl()); if (display == null) return new ValidationResult(cc); CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (cc.hasDisplay()) { b.append(cc.getDisplay()); if (display.equalsIgnoreCase(cc.getDisplay())) return new ValidationResult(cc); } for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) { b.append(ds.getValue()); if (display.equalsIgnoreCase(ds.getValue())) return new ValidationResult(cc); } return new ValidationResult( IssueSeverity.WARNING, "Display Name for " + code + " must be one of '" + b.toString() + "'", cc); }
@Override public boolean supportsSystem(String system) throws TerminologyServiceException { if (codeSystems.containsKey(system)) return true; else if (nonSupportedCodeSystems.contains(system)) return false; else if (system.startsWith("http://example.org") || system.startsWith("http://acme.com") || system.startsWith("http://hl7.org/fhir/valueset-") || system.startsWith("urn:oid:")) return false; else { if (noTerminologyServer) return false; if (bndCodeSystems == null) { try { log("Terminology server: Check for supported code systems for " + system); bndCodeSystems = txServer.fetchFeed( txServer.getAddress() + "/CodeSystem?content=not-present&_summary=true&_count=1000"); } catch (Exception e) { if (canRunWithoutTerminology) { noTerminologyServer = true; log("==============!! Running without terminology server !!=============="); return false; } else throw new TerminologyServiceException(e); } } if (bndCodeSystems != null) { for (BundleEntryComponent be : bndCodeSystems.getEntry()) { CodeSystem cs = (CodeSystem) be.getResource(); if (!codeSystems.containsKey(cs.getUrl())) { codeSystems.put(cs.getUrl(), null); } } } if (codeSystems.containsKey(system)) return true; } nonSupportedCodeSystems.add(system); return false; }
private String gen(Section section, CodeSystem cs, ValueSet vs) { String bn = getPNameForUri(cs.getUrl()); if (!bn.startsWith("<")) { section.triple(bn + ".system", "a", "fhir:CodeSystem"); if (cs.hasVersion()) section.triple(bn + ".system", "fhir:version", literal(cs.getVersion())); if (vs.hasName()) section.label(bn + ".system", vs.getName()); if (vs.hasDescription()) section.comment( bn + ".system", vs.getDescription() .replace("value set", "code system") .replace("Value Set", "Code System") .replace("Value set", "Code system")); if (vs.hasCopyright()) section.triple(bn + ".system", "dc:rights", literal(vs.getCopyright())); if (vs.hasDate()) section.triple(bn + ".system", "dc:date", literal(vs.getDate().toString())); section.triple(bn, "a", "fhir:Concept"); gen(section, bn, bn, cs.getConcept()); } return bn; }