@SuppressWarnings("rawtypes") private String describeValidationParameters(Parameters pin) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (ParametersParameterComponent p : pin.getParameter()) { if (p.hasValue() && p.getValue() instanceof PrimitiveType) { b.append(p.getName() + "=" + ((PrimitiveType) p.getValue()).asStringValue()); } else if (p.hasValue() && p.getValue() instanceof Coding) { b.append("system=" + ((Coding) p.getValue()).getSystem()); b.append("code=" + ((Coding) p.getValue()).getCode()); b.append("display=" + ((Coding) p.getValue()).getDisplay()); } else if (p.hasValue() && p.getValue() instanceof CodeableConcept) { if (((CodeableConcept) p.getValue()).hasCoding()) { Coding c = ((CodeableConcept) p.getValue()).getCodingFirstRep(); b.append("system=" + c.getSystem()); b.append("code=" + c.getCode()); b.append("display=" + c.getDisplay()); } else if (((CodeableConcept) p.getValue()).hasText()) { b.append("text=" + ((CodeableConcept) p.getValue()).getText()); } } else if (p.hasResource() && (p.getResource() instanceof ValueSet)) { b.append("valueset=" + getVSSummary((ValueSet) p.getResource())); } } return b.toString(); }
protected String getLinkedForm(Coding c) { if (c.hasSystem()) { if (c.getSystem().equals("http://loinc.org")) { prefixes.put("loinc", "http://loinc.org/"); return "loinc:" + c.getCode(); } } return null; }
@Override public ValidationResult validateCode(Coding code, ValueSet vs) { if (codeSystems.containsKey(code.getSystem()) && codeSystems.get(code.getSystem()) != null) try { return verifyCodeInCodeSystem( codeSystems.get(code.getSystem()), code.getSystem(), code.getCode(), code.getDisplay()); } catch (Exception e) { return new ValidationResult( IssueSeverity.FATAL, "Error validating code \"" + code + "\" in system \"" + code.getSystem() + "\": " + e.getMessage()); } else if (vs.hasExpansion()) try { return verifyCodeInternal(vs, code.getSystem(), code.getCode(), code.getDisplay()); } catch (Exception e) { return new ValidationResult( IssueSeverity.FATAL, "Error validating code \"" + code + "\" in system \"" + code.getSystem() + "\": " + e.getMessage()); } else try { return verifyCodeExternal(vs, code, true); } catch (Exception e) { return new ValidationResult( IssueSeverity.WARNING, "Error validating code \"" + code + "\" in system \"" + code.getSystem() + "\": " + e.getMessage()); } }
private String cacheId(Coding coding) { return "|" + coding.getSystem() + "|" + coding.getVersion() + "|" + coding.getCode() + "|" + coding.getDisplay(); }
private ValidationResult verifyCodeInternal(ValueSet vs, CodeableConcept code) throws Exception { for (Coding c : code.getCoding()) { ValidationResult res = verifyCodeInternal(vs, c.getSystem(), c.getCode(), c.getDisplay()); if (res.isOk()) return res; } if (code.getCoding().isEmpty()) return new ValidationResult(IssueSeverity.ERROR, "None code provided"); else return new ValidationResult( IssueSeverity.ERROR, "None of the codes are in the specified value set"); }
private ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCodeIsInContains( List<ValueSetExpansionContainsComponent> contains, String theSystem, String theCode, Coding theCoding, CodeableConcept theCodeableConcept) { for (ValueSetExpansionContainsComponent nextCode : contains) { ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult result = validateCodeIsInContains( nextCode.getContains(), theSystem, theCode, theCoding, theCodeableConcept); if (result != null) { return result; } String system = nextCode.getSystem(); String code = nextCode.getCode(); if (isNotBlank(theCode)) { if (theCode.equals(code) && (isBlank(theSystem) || theSystem.equals(system))) { return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay()); } } else if (theCoding != null) { if (StringUtils.equals(system, theCoding.getSystem()) && StringUtils.equals(code, theCoding.getCode())) { return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay()); } } else { for (Coding next : theCodeableConcept.getCoding()) { if (StringUtils.equals(system, next.getSystem()) && StringUtils.equals(code, next.getCode())) { return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay()); } } } } return null; }