public org.hl7.fhir.instance.model.Encounter.EncounterClass convertEncounterClass(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { if (src == null || src.isEmpty()) return null; if (src.getSystem().equals("http://hl7.org/fhir/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; }
private boolean hasConcept(org.hl7.fhir.dstu3.model.CodeableConcept cc, String system, String code) { for (org.hl7.fhir.dstu3.model.Coding c : cc.getCoding()) { if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; } return false; }
private String ccSummary(CodeableConcept cc) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (Coding c : cc.getCoding()) b.append(c.getSystem()+"#"+c.getCode()); return b.toString(); }
private void validateAnswerCode(List<ValidationMessage> errors, Element value, NodeStack stack, Questionnaire qSrc, Reference 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 = 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()) rule(errors, 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"); } catch (Exception e) { warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, "Error " + e.getMessage() + " validating Coding against Questionnaire Options"); } } }
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; }
if (isBlank(coding.getCode()) && isBlank(coding.getDisplay()) && isBlank(coding.getSystem())) { rule(theErrors, IssueType.BUSINESSRULE, thePathStack, false, "Answer to question with linkId[{0}] is of type coding, but none of code, system, and display are populated", linkId); continue; } else if (isBlank(coding.getCode()) && isBlank(coding.getSystem())) { if (type != QuestionnaireItemType.OPENCHOICE) { rule(theErrors, IssueType.BUSINESSRULE, thePathStack, false, "Answer to question with linkId[{0}] is of type only has a display populated (no code or system) but question does not allow {1}", linkId, QuestionnaireItemType.OPENCHOICE.name()); continue; } else if (isBlank(coding.getCode()) || isBlank(coding.getSystem())) { rule(theErrors, IssueType.BUSINESSRULE, thePathStack, false, "Answer to question with linkId[{0}] has a coding, but this coding does not contain a code and system (both must be present, or neither as the question allows {1})", linkId, QuestionnaireItemType.OPENCHOICE.name()); continue; if (coding.getCode().equals(next.getCode()) && coding.getSystem().equals(next.getSystem())) { found = true; break; rule(theErrors, IssueType.BUSINESSRULE, thePathStack, found, "Question with linkId[{0}] has answer with system[{1}] and code[{2}] but this is not a valid answer for ValueSet[{3}]", linkId, coding.getSystem(), coding.getCode(), optionsRef);
private void checkMaxValueSet(List<ValidationMessage> errors, String path, Element element, StructureDefinition profile, Reference maxVSUrl, Coding c) { // TODO Auto-generated method stub ValueSet valueset = resolveBindingReference(profile, maxVSUrl, profile.getUrl()); if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, valueset != null, "ValueSet " + describeReference(maxVSUrl) + " not found")) { try { long t = System.nanoTime(); ValidationResult vr = context.validateCode(c, valueset); txTime = txTime + (System.nanoTime() - t); if (!vr.isOk()) { rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The code provided is not in the maximum value set " + describeReference(maxVSUrl) + " (" + valueset.getUrl()+", and a code from this value set is required) (code = "+c.getSystem()+"#"+c.getCode()+")"); } } catch (Exception e) { warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Error "+e.getMessage()+" validating CodeableConcept using maxValueSet"); } } }
public org.hl7.fhir.instance.model.Coding convertCoding(org.hl7.fhir.dstu3.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; }
boolean found = false; for (Coding item : list) { if (ObjectUtil.equals(item.getSystem(), system) && ObjectUtil.equals(item.getCode(), code)) { found = true; break;
@Override public LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, Coding theCoding, RequestDetails theRequestDetails) { boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode()); boolean haveCode = theCode != null && theCode.isEmpty() == false; boolean haveSystem = theSystem != null && theSystem.isEmpty() == false; String system; if (haveCoding) { code = theCoding.getCode(); system = theCoding.getSystem(); } else {
String ss = type.getCoding().get(0).getCode(); if (ss.equals("416098002") || ss.equals("414285001")) ai.setType(AllergyIntoleranceType.ALLERGY);
public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.dstu3.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 boolean hasConcept(org.hl7.fhir.dstu3.model.CodeableConcept cc, String system, String code) { for (org.hl7.fhir.dstu3.model.Coding c : cc.getCoding()) { if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; } return false; }
public static boolean matches(Coding c1, Coding c2, MatchProfile profile) { if (profile != null) throw new NotImplementedException("Not Implemented Yet"); // in the absence of a profile, we ignore version return matches(c1.getSystem(), c2.getSystem(), null) && matches(c1.getCode(), c2.getCode(), null); }
private String summariseCoding(Coding value) { String uri = value.getSystem(); String system = NarrativeGenerator.describeSystem(uri); if (Utilities.isURL(system)) { if (system.equals("http://cap.org/protocols")) system = "CAP Code"; } return system+" "+value.getCode(); }
@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); }
private String ccSummary(CodeableConcept cc) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (Coding c : cc.getCoding()) b.append(c.getSystem()+"#"+c.getCode()); return b.toString(); }
String nextCode = nextCoding.getCode(); String nextSystem = nextCoding.getSystem(); if (isNotBlank(nextCode) && isNotBlank(nextSystem) && context.supportsSystem(nextSystem)) {
public static String getServiceCategory(Encounter encounter) { CodeableConcept cpt = encounter == null ? null : FhirUtil.getFirst(encounter.getType()); Coding coding = cpt == null ? null : FhirUtil.getFirst(cpt.getCoding()); return coding == null ? null : coding.getCode(); }
public org.hl7.fhir.instance.model.Coding convertCoding(org.hl7.fhir.dstu3.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; }