public static org.hl7.fhir.dstu2016may.model.CodeSystem convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.CodeSystem tgt = new org.hl7.fhir.dstu2016may.model.CodeSystem(); copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrl(src.getUrl()); if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifierFirstRep())); if (src.hasVersion()) tgt.setVersion(src.getVersion()); if (src.hasName()) tgt.setName(src.getName()); tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); if (src.hasExperimental()) tgt.setExperimental(src.getExperimental()); if (src.hasPublisher()) tgt.setPublisher(src.getPublisher()); for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) tgt.addContact(convertCodeSystemContactComponent(t)); if (src.hasDate()) tgt.setDate(src.getDate()); if (src.hasDescription()) tgt.setDescription(src.getDescription()); for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) if (t.hasValueCodeableConcept()) tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(convertCodeableConcept(t)); if (src.hasPurpose())
public static org.hl7.fhir.r4.model.CodeSystem convertCodeSystem(org.hl7.fhir.dstu2016may.model.CodeSystem src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.CodeSystem tgt = new org.hl7.fhir.r4.model.CodeSystem(); copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrl(src.getUrl()); if (src.hasIdentifier()) tgt.addIdentifier(convertIdentifier(src.getIdentifier())); if (src.hasVersion()) tgt.setVersion(src.getVersion()); if (src.hasName()) tgt.setName(src.getName()); tgt.setStatus(convertConformanceResourceStatus(src.getStatus())); if (src.hasExperimental()) tgt.setExperimental(src.getExperimental()); if (src.hasPublisher()) tgt.setPublisher(src.getPublisher()); for (org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemContactComponent t : src.getContact()) tgt.addContact(convertCodeSystemContactComponent(t)); if (src.hasDate()) tgt.setDate(src.getDate()); if (src.hasDescription()) tgt.setDescription(src.getDescription()); for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext()) if (isJurisdiction(t)) tgt.addJurisdiction(convertCodeableConcept(t)); else tgt.addUseContext(convertCodeableConceptToUsageContext(t)); if (src.hasRequirements())
/** * @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); }
/** * @return The first repetition of repeating field {@link #property}, creating it if it does not already exist */ public PropertyComponent getPropertyFirstRep() { if (getProperty().isEmpty()) { addProperty(); } return getProperty().get(0); }
org.hl7.fhir.r4.model.CodeSystem tgtcs = new org.hl7.fhir.r4.model.CodeSystem(); copyDomainResource(src, tgtcs); tgtcs.setUrl(src.getCodeSystem().getSystem()); tgtcs.addIdentifier(convertIdentifier(src.getIdentifier())); tgtcs.setVersion(src.getCodeSystem().getVersion()); tgtcs.setName(src.getName()+" Code System"); tgtcs.setStatus(convertConformanceResourceStatus(src.getStatus())); if (src.hasExperimental()) tgtcs.setExperimental(src.getExperimental()); tgtcs.setPublisher(src.getPublisher()); for (org.hl7.fhir.instance.model.ValueSet.ValueSetContactComponent t : src.getContact()) tgtcs.addContact(convertValueSetContactComponent(t)); if (src.hasDate()) tgtcs.setDate(src.getDate()); tgtcs.setDescription(src.getDescription()); for (org.hl7.fhir.instance.model.CodeableConcept t : src.getUseContext()) if (isJurisdiction(t)) tgtcs.addJurisdiction(convertCodeableConcept(t)); else tgtcs.addUseContext(convertCodeableConceptToUsageContext(t)); tgtcs.setPurpose(src.getRequirements()); tgtcs.setCopyright(src.getCopyright()); tgtcs.setContent(CodeSystemContentMode.COMPLETE); 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); tgt.getCompose().addInclude().setSystem(tgtcs.getUrl());
switch (hash) { case 116079: // url this.url = castToUri(value); // UriType return value; case -1618432855: // identifier this.getIdentifier().add(castToIdentifier(value)); // Identifier return value; case 351608024: // version this.version = castToString(value); // StringType return value; case 3373707: // name this.name = castToString(value); // StringType return value; case 110371416: // title this.title = castToString(value); // StringType return value; case -892481550: // status value = new PublicationStatusEnumFactory().fromType(castToCode(value)); this.status = (Enumeration) value; // Enumeration<PublicationStatus> return value; case -404562712: // experimental this.experimental = castToBoolean(value); // BooleanType return value; case 3076014: // date this.date = castToDateTime(value); // DateTimeType return value; case 1447404028: // publisher this.publisher = castToString(value); // StringType return value;
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case 116079: return getUrlElement(); case -1618432855: return addIdentifier(); case 351608024: return getVersionElement(); case 3373707: return getNameElement(); case 110371416: return getTitleElement(); case -892481550: return getStatusElement(); case -404562712: return getExperimentalElement(); case 3076014: return getDateElement(); case 1447404028: return getPublisherElement(); case 951526432: return addContact(); case -1724546052: return getDescriptionElement(); case -669707736: return addUseContext(); case -507075711: return addJurisdiction(); case -220463842: return getPurposeElement(); case 1522889671: return getCopyrightElement(); case -35616442: return getCaseSensitiveElement(); case -1410174671: return getValueSetElement(); case 1913078280: return getHierarchyMeaningElement(); case 1248023381: return getCompositionalElement(); case 617270957: return getVersionNeededElement(); case 951530617: return getContentElement(); case -596951334: return getSupplementsElement(); case 94851343: return getCountElement(); case -1274492040: return addFilter(); case -993141291: return addProperty(); case 951024232: return addConcept(); default: return super.makeProperty(hash, name);
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; }
cs.checkNoModifiers("Code System", "expanding"); if (cs.getContent() != CodeSystemContentMode.COMPLETE) 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()))); for (ConceptDefinitionComponent def : cs.getConcept()) { addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null); ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); if (def == null) throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); ConceptDefinitionComponent defEx = getConceptForCode(cs.getConcept(), fc.getValue()); if (defEx == null) throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); for (ConceptDefinitionComponent def : cs.getConcept()) { addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx); ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); if (def == null) throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); if (def != null) { if (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) {
@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; }
return addIdentifier(); return addContact(); return addUseContext(); return addJurisdiction(); return addFilter(); return addProperty(); return addConcept();
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 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(); }
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)); } }
CodeSystem cs = new org.hl7.fhir.r4.model.CodeSystem(); cs.setUrl(SCT_URI); cs.setName("SNOMED CT"); cs.setContent(CodeSystem.CodeSystemContentMode.NOTPRESENT); IIdType target = storeCodeSystem(theRequestDetails, codeSystemVersion, cs, null, 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); } }
/** * 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 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 boolean isCodeSystemSupported(FhirContext theContext, String theSystem) { CodeSystem cs = fetchCodeSystem(theContext, theSystem); return cs != null && cs.getContent() != CodeSystemContentMode.NOTPRESENT; }