public static String present(Coding coding) { if (coding == null) return ""; return coding.getSystem()+"::"+coding.getCode(); }
public static boolean matches(Coding coding, String system, String code) { if (coding == null) return false; return code.equals(coding.getCode()) && system.equals(coding.getSystem()); }
public boolean hasCoding(String system, String code) { for (Coding c : getCoding()) { if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; } return false; }
private boolean hasConcept(org.hl7.fhir.r4.model.CodeableConcept cc, String system, String code) { for (org.hl7.fhir.r4.model.Coding c : cc.getCoding()) { if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; } return false; }
private static String convertConditionClinicalStatus(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { if (src == null) return null; for (org.hl7.fhir.r4.model.Coding c : src.getCoding()) { if ("http://hl7.org/fhir/condition-clinical".equals(c.getSystem())) return c.getCode(); } return null; }
private List<Coding> mergeCodings(List<Coding> left, List<Coding> right) { List<Coding> result = new ArrayList<Coding>(); result.addAll(left); for (Coding c : right) { boolean found = false; for (Coding ct : left) if (Utilities.equals(c.getSystem(), ct.getSystem()) && Utilities.equals(c.getCode(), ct.getCode())) found = true; if (!found) result.add(c); } return result; }
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); }
public String summary(Coding code) { return code.getSystem()+"#"+code.getCode()+": \""+code.getDisplay()+"\""; }
public boolean is(String system, String code) { return hasSystem() && hasCode() && this.getSystem().equals(system) && this.getCode().equals(code); }
@Override public int hashCode() { return new HashCodeBuilder(17, 37) .append(getCoding().getCode()) .append(getCoding().getSystem()) .append(getCoding().getVersion()) .append(getResourceId()) .append(getSource()) .append(getTarget()) .append(getTargetSystem()) .toHashCode(); } }
protected void decorateCoding(Complex t, Coding element) { if (!element.hasSystem()) return; if ("http://snomed.info/sct".equals(element.getSystem())) { t.prefix("sct", "http://snomed.info/sct/"); t.predicate("a", "sct:"+element.getCode()); } else if ("http://snomed.info/sct".equals(element.getSystem())) { t.prefix("loinc", "http://loinc.org/rdf#"); t.predicate("a", "loinc:"+element.getCode()); } }
public org.hl7.fhir.instance.model.Encounter.EncounterClass convertEncounterClass(org.hl7.fhir.r4.model.Coding src) throws FHIRException { if (src == null || src.isEmpty()) return null; if (src.getSystem().equals("http://terminology.hl7.org/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 String ccSummary(CodeableConcept cc) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (Coding c : cc.getCoding()) b.append(c.getSystem()+"#"+c.getCode()); return b.toString(); }
@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); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TranslationQuery)) return false; TranslationQuery that = (TranslationQuery) o; return new EqualsBuilder() .append(getCoding().getCode(), that.getCoding().getCode()) .append(getCoding().getSystem(), that.getCoding().getSystem()) .append(getCoding().getVersion(), that.getCoding().getVersion()) .append(getResourceId(), that.getResourceId()) .append(getSource(), that.getSource()) .append(getTarget(), that.getTarget()) .append(getTargetSystem(), that.getTargetSystem()) .isEquals(); }
private static String renderCoding(Coding code) { if (code == null || code.isEmpty()) return ""; else return "<span title=\""+Utilities.escapeXml(code.getSystem())+"\">"+Utilities.escapeXml(code.getCode())+"</span>"; }
/** * Returns the first tag (if any) that has the given system and code, or returns * <code>null</code> if none */ public Coding getTag(String theSystem, String theCode) { for (Coding next : getTag()) { if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) { return next; } } return null; }
/** * Returns the first security label (if any) that has the given system and code, or returns * <code>null</code> if none */ public Coding getSecurity(String theSystem, String theCode) { for (Coding next : getTag()) { if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) { return next; } } return null; } protected void listChildren(List<Property> children) {
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 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; }