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); }
@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); }
@Override public ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude) { ValueSetExpansionComponent retVal = new ValueSetExpansionComponent(); 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, wantCodes, concepts); } for (UriType next: theInclude.getValueSet()) { ValueSet vs = myValueSets.get(defaultString(next.getValueAsString())); if (vs != null) { for (ConceptSetComponent nextInclude : vs.getCompose().getInclude()) { ValueSetExpansionComponent contents = expandValueSet(theContext, nextInclude); retVal.getContains().addAll(contents.getContains()); } } } return retVal; }
@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(); Long codeSystemResourcePid = retVal.getId(); if (retVal.getDeleted() != null) { // deleting } else 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()); TermCodeSystemVersion 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; }
public org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.dstu3.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; }
/** * @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 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 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 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); }
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); }
tgt.getCodeSystem().setVersion(srcCS.getVersion()); tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive()); for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent cs : srcCS.getConcept()) processConcept(tgt.getCodeSystem().getConcept(), cs, srcCS);
for (org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent t : src.getProperty()) tgt.addProperty(convertPropertyComponent(t)); for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept()) tgt.addConcept(convertConceptDefinitionComponent(t)); return tgt;
public org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.dstu3.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; }
private static synchronized void loadServiceCategories() { if (serviceCategories == null) { Map<String, CodeableConcept> map = new LinkedHashMap<>(); Bundle bundle = ClientUtil.getFhirClient().search().forResource(ValueSet.class) .where(CodeSystem.NAME.matchesExactly().value("EncounterType")).returnBundle(Bundle.class).execute(); for (CodeSystem cs : FhirUtil.getEntries(bundle, CodeSystem.class)) { UriType system = cs.getUrlElement(); for (ConceptDefinitionComponent concept : cs.getConcept()) { CodeableConcept cc = new CodeableConcept(); Coding coding = cc.addCoding(); coding.setCode(concept.getCode()); coding.setDisplay(concept.getDisplay()); coding.setSystemElement(system); cc.setText(concept.getDefinition()); map.put(coding.getCode(), cc); } } serviceCategories = map; } return; }
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);