/** * Add a new CodeSystem resource which will be available to the validator. Note that * {@link CodeSystem#getUrl() the URL field) in this resource must contain a value as this * value will be used as the logical URL. * <p> * Note that if the URL is a canonical FHIR URL (e.g. http://hl7.org/StructureDefinition/Extension), * it will be stored in three ways: * <ul> * <li>Extension</li> * <li>StructureDefinition/Extension</li> * <li>http://hl7.org/StructureDefinition/Extension</li> * </ul> * </p> */ public void addCodeSystem(CodeSystem theCodeSystem) { Validate.notBlank(theCodeSystem.getUrl(), "theCodeSystem.getUrl() must not return a value"); addToMap(theCodeSystem, myCodeSystems, theCodeSystem.getUrl()); }
@Override protected void preDelete(CodeSystem theResourceToDelete, ResourceTable theEntityToDelete) { super.preDelete(theResourceToDelete, theEntityToDelete); String codeSystemUrl = theResourceToDelete.getUrl(); if (isNotBlank(codeSystemUrl)) { TermCodeSystem persCs = myCsDao.findByCodeSystemUri(codeSystemUrl); if (persCs != null) { myTerminologySvc.deleteCodeSystem(persCs); } } }
@Override @Transactional(propagation = Propagation.REQUIRED) public IIdType storeNewCodeSystemVersion(CodeSystem theCodeSystemResource, TermCodeSystemVersion theCodeSystemVersion, RequestDetails theRequestDetails, List<ValueSet> theValueSets, List<ConceptMap> theConceptMaps) { Validate.notBlank(theCodeSystemResource.getUrl(), "theCodeSystemResource must have a URL"); IIdType csId = createOrUpdateCodeSystem(theCodeSystemResource); ResourceTable resource = (ResourceTable) myCodeSystemResourceDao.readEntity(csId); Long codeSystemResourcePid = resource.getId(); ourLog.info("CodeSystem resource has ID: {}", csId.getValue()); theCodeSystemVersion.setResource(resource); storeNewCodeSystemVersion(codeSystemResourcePid, theCodeSystemResource.getUrl(), theCodeSystemResource.getName(), theCodeSystemVersion); myDeferredConceptMaps.addAll(theConceptMaps); myDeferredValueSets.addAll(theValueSets); return csId; }
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(); }
CodeSystem nextValueSet = (CodeSystem) next.getResource(); nextValueSet.getText().setDivAsString(""); String system = nextValueSet.getUrl(); if (isNotBlank(system)) { theCodeSystems.put(system, nextValueSet);
@Override protected IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource) { if (isBlank(theCodeSystemResource.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(theCodeSystemResource, matchUrl).getId(); } else { return myCodeSystemResourceDao.update(theCodeSystemResource).getId(); } }
@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 protected IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource) { CodeSystem resourceToStore; try { resourceToStore = VersionConvertor_30_40.convertCodeSystem(theCodeSystemResource); } catch (FHIRException e) { throw new InternalErrorException(e); } if (isBlank(resourceToStore.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(resourceToStore, matchUrl).getId(); } else { return myCodeSystemResourceDao.update(resourceToStore).getId(); } }
if (theResource instanceof CodeSystem) { CodeSystem cs = (CodeSystem) theResource; useSystem = cs.getUrl();
public static void markStatus(CodeSystem cs, String wg, StandardsStatus status, String pckage, String fmm, String normativeVersion) throws FHIRException { if (wg != null) { if (!ToolingExtensions.hasExtension(cs, ToolingExtensions.EXT_WORKGROUP) || (Utilities.existsInList(ToolingExtensions.readStringExtension(cs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && !Utilities.existsInList(wg, "fhir", "vocab"))) { ToolingExtensions.setCodeExtension(cs, ToolingExtensions.EXT_WORKGROUP, wg); } } if (status != null) { StandardsStatus ss = ToolingExtensions.getStandardsStatus(cs); if (ss == null || ss.isLowerThan(status)) ToolingExtensions.setStandardsStatus(cs, status, normativeVersion); if (pckage != null) { if (!cs.hasUserData("ballot.package")) cs.setUserData("ballot.package", pckage); else if (!pckage.equals(cs.getUserString("ballot.package"))) if (!"infrastructure".equals(cs.getUserString("ballot.package"))) System.out.println("Code System "+cs.getUrl()+": ownership clash "+pckage+" vs "+cs.getUserString("ballot.package")); } if (status == StandardsStatus.NORMATIVE) { cs.setExperimental(false); cs.setStatus(PublicationStatus.ACTIVE); } } if (fmm != null) { String sfmm = ToolingExtensions.readStringExtension(cs, ToolingExtensions.EXT_FMM_LEVEL); if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm)) ToolingExtensions.setIntegerExtension(cs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm)); } }
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; }
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); }
throw new TerminologyServiceException("Code system " + inc.getSystem().toString() + " is incomplete"); if (cs.hasVersion()) if (!existsInParams(params, "version", new UriType(cs.getUrl() + "|" + cs.getVersion()))) params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(cs.getUrl() + "|" + cs.getVersion())));
@Override protected void preDelete(CodeSystem theResourceToDelete, ResourceTable theEntityToDelete) { super.preDelete(theResourceToDelete, theEntityToDelete); String codeSystemUrl = theResourceToDelete.getUrl(); if (isNotBlank(codeSystemUrl)) { TermCodeSystem persCs = myCsDao.findByCodeSystemUri(codeSystemUrl); if (persCs != null) { myTerminologySvc.deleteCodeSystem(persCs); } } }
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(); }
srcCS = advisor.getCodeSystem(src); if (srcCS != null) { tgt.getCodeSystem().setSystem(srcCS.getUrl()); tgt.getCodeSystem().setVersion(srcCS.getVersion()); tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive()); tgt.setCompose(convertValueSetComposeComponent(src.getCompose(), srcCS == null ? null : srcCS.getUrl())); tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion())); return tgt;
@Override protected IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource) { if (isBlank(theCodeSystemResource.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(theCodeSystemResource, matchUrl).getId(); } else { return myCodeSystemResourceDao.update(theCodeSystemResource).getId(); } }
copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrl(src.getUrl()); if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifierFirstRep()));
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; }
advisor.handleCodeSystem(tgtcs, tgt); tgt.setUserData("r2-cs", tgtcs); tgt.getCompose().addInclude().setSystem(tgtcs.getUrl());