/** * @return The first repetition of repeating field {@link #concept}, creating it if it does not already exist */ public ConceptDefinitionComponent getConceptFirstRep() { if (getConcept().isEmpty()) { addConcept(); } return getConcept().get(0); }
private void findCodesAbove(CodeSystem theSystem, String theSystemString, String theCode, List<VersionIndependentConcept> theListToPopulate) { List<ConceptDefinitionComponent> conceptList = theSystem.getConcept(); for (ConceptDefinitionComponent next : conceptList) { addTreeIfItContainsCode(theSystemString, next, theCode, theListToPopulate); } }
private ConceptDefinitionComponent getCodeDefinition(CodeSystem cs, String code) { for (ConceptDefinitionComponent c : cs.getConcept()) { ConceptDefinitionComponent r = getCodeDefinition(c, code); if (r != null) return r; } return null; }
private void findCodesBelow(CodeSystem theSystem, String theSystemString, String theCode, List<VersionIndependentConcept> theListToPopulate) { List<ConceptDefinitionComponent> conceptList = theSystem.getConcept(); findCodesBelow(theSystemString, theCode, theListToPopulate, conceptList); }
public static String getCodeDefinition(CodeSystem cs, String code) { return getCodeDefinition(cs.getConcept(), code); }
private void checkCodesUnique(CodeSystem cs, List<ValidationMessage> errors) { Set<String> codes = new HashSet<String>(); checkCodes(codes, cs.getConcept(), "CodeSystem["+cs.getId()+"]", errors); }
public static boolean isInactive(CodeSystem cs, String code) throws FHIRException { ConceptDefinitionComponent def = findCode(cs.getConcept(), code); if (def == null) return true; return isInactive(cs, def); }
private String getCodeDisplay(CodeSystem cs, String code) throws TerminologyServiceException { ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), code); if (def == null) throw new TerminologyServiceException("Unable to find code '" + code + "' in code system " + cs.getUrl()); return def.getDisplay(); }
@Override public CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem, String theCode, String theDisplay) { CodeSystem cs = fetchCodeSystem(theContext, theCodeSystem); if (cs != null) { boolean caseSensitive = true; if (cs.hasCaseSensitive()) { caseSensitive = cs.getCaseSensitive(); } CodeValidationResult retVal = testIfConceptIsInList(theCode, cs.getConcept(), caseSensitive); if (retVal != null) { return retVal; } } return new CodeValidationResult(IssueSeverity.WARNING, "Unknown code: " + theCodeSystem + " / " + theCode); }
this.getProperty().add((PropertyComponent) value); } else if (name.equals("concept")) { this.getConcept().add((ConceptDefinitionComponent) value); } else return super.setProperty(name, value);
@Override protected ResourceTable updateEntity(RequestDetails theRequest, IBaseResource theResource, ResourceTable theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion, Date theUpdateTime, boolean theForceUpdate, boolean theCreateNewHistoryEntry) { ResourceTable retVal = super.updateEntity(theRequest, theResource, theEntity, theDeletedTimestampOrNull, thePerformIndexing, theUpdateVersion, theUpdateTime, theForceUpdate, theCreateNewHistoryEntry); CodeSystem cs = (CodeSystem) theResource; if (cs != null && isNotBlank(cs.getUrl())) { String codeSystemUrl = cs.getUrl(); if (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == null) { ourLog.info("CodeSystem {} has a status of {}, going to store concepts in terminology tables", retVal.getIdDt().getValue(), cs.getContentElement().getValueAsString()); Long codeSystemResourcePid = retVal.getId(); TermCodeSystemVersion persCs = myCsvDao.findCurrentVersionForCodeSystemResourcePid(codeSystemResourcePid); if (persCs != null) { ourLog.info("Code system version already exists in database"); } else { persCs = new TermCodeSystemVersion(); persCs.setResource(retVal); persCs.getConcepts().addAll(toPersistedConcepts(cs.getConcept(), persCs)); ourLog.info("Code system has {} concepts", persCs.getConcepts().size()); myTerminologySvc.storeNewCodeSystemVersion(codeSystemResourcePid, codeSystemUrl, cs.getName(), persCs); } } } return retVal; }
@Override public ValueSetExpander.ValueSetExpansionOutcome expandValueSet(FhirContext theContext, ConceptSetComponent theInclude) { ValueSetExpander.ValueSetExpansionOutcome retVal = new ValueSetExpander.ValueSetExpansionOutcome(new ValueSet()); Set<String> wantCodes = new HashSet<>(); for (ConceptReferenceComponent next : theInclude.getConcept()) { wantCodes.add(next.getCode()); } CodeSystem system = fetchCodeSystem(theContext, theInclude.getSystem()); if (system != null) { List<ConceptDefinitionComponent> concepts = system.getConcept(); addConcepts(theInclude, retVal.getValueset().getExpansion(), wantCodes, concepts); } for (UriType next : theInclude.getValueSet()) { ValueSet vs = myValueSets.get(defaultString(next.getValueAsString())); if (vs != null) { for (ConceptSetComponent nextInclude : vs.getCompose().getInclude()) { ValueSetExpander.ValueSetExpansionOutcome contents = expandValueSet(theContext, nextInclude); retVal.getValueset().getExpansion().getContains().addAll(contents.getValueset().getExpansion().getContains()); } } } return retVal; }
private CodeSystem convertCodeSystem(ValueSet theFetched) { CodeSystem retVal = new CodeSystem(); retVal.setUrl(theFetched.getCodeSystem().getSystem()); retVal.setVersion(theFetched.getVersion()); List<ValueSet.ConceptDefinitionComponent> sourceConceptList = theFetched.getCodeSystem().getConcept(); List<CodeSystem.ConceptDefinitionComponent> targetConceptList = retVal.getConcept(); convertConceptList(sourceConceptList, targetConceptList); return retVal; }
private boolean inComponent(ConceptSetComponent vsi, String system, String code, boolean only) throws FHIRException { for (UriType uri : vsi.getValueSet()) { if (inImport(uri.getValue(), system, code)) return true; } if (!vsi.hasSystem()) return false; if (only && system == null) { // whether we know the system or not, we'll accept the stated codes at face value for (ConceptReferenceComponent cc : vsi.getConcept()) if (cc.getCode().equals(code)) return true; } if (!system.equals(vsi.getSystem())) return false; if (vsi.hasFilter()) throw new FHIRException("Filters - not done yet"); CodeSystem def = context.fetchCodeSystem(system); if (def.getContent() != CodeSystemContentMode.COMPLETE) throw new FHIRException("Unable to resolve system "+vsi.getSystem()+" - system is not complete"); List<ConceptDefinitionComponent> list = def.getConcept(); return validateCodeInConceptList(code, def, list); }
public org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent(); copyElement(src, tgt); tgt.setSystem(src.getUrl()); tgt.setVersion(src.getVersion()); tgt.setCaseSensitive(src.getCaseSensitive()); for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); return tgt; }
ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code); if (cc != null) { if (sys == null)
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); }
tgt.getCodeSystem().setVersion(srcCS.getVersion()); tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive()); for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cs : srcCS.getConcept()) processConcept(tgt.getCodeSystem().getConcept(), cs, srcCS);
for (org.hl7.fhir.r4.model.CodeSystem.PropertyComponent t : src.getProperty()) tgt.addProperty(convertPropertyComponent(t)); for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept()) tgt.addConcept(convertConceptDefinitionComponent(t)); return tgt;
tgtcs.setCaseSensitive(src.getCodeSystem().getCaseSensitive()); for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent cs : src.getCodeSystem().getConcept()) processConcept(tgtcs.getConcept(), cs, tgtcs); advisor.handleCodeSystem(tgtcs, tgt); tgt.setUserData("r2-cs", tgtcs);