public static org.hl7.fhir.dstu2016may.model.CodeSystem convertCodeSystem(org.hl7.fhir.dstu3.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()); tgt.setIdentifier(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.dstu3.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.dstu3.model.UsageContext t : src.getUseContext()) if (t.hasValueCodeableConcept()) tgt.addUseContext(convertCodeableConcept(t.getValueCodeableConcept())); for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(convertCodeableConcept(t)); if (src.hasPurpose()) tgt.setRequirements(src.getPurpose());
public static org.hl7.fhir.dstu3.model.CodeSystem convertCodeSystem(org.hl7.fhir.dstu2016may.model.CodeSystem src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.CodeSystem tgt = new org.hl7.fhir.dstu3.model.CodeSystem(); copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrl(src.getUrl()); tgt.setIdentifier(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()) tgt.setPurpose(src.getRequirements());
@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); }
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; }
@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; }
org.hl7.fhir.dstu3.model.CodeSystem tgtcs = new org.hl7.fhir.dstu3.model.CodeSystem(); copyDomainResource(src, tgtcs); tgtcs.setUrl(src.getCodeSystem().getSystem()); tgtcs.setIdentifier(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());
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case 116079: return getUrlElement(); case -1618432855: return getIdentifier(); 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 94851343: return getCountElement(); case -1274492040: return addFilter(); case -993141291: return addProperty(); case 951024232: return addConcept(); default: return super.makeProperty(hash, name);
switch (hash) { case 116079: // url this.url = castToUri(value); // UriType return value; case -1618432855: // identifier this.identifier = 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;
} else { CodeSystem cs = context.fetchCodeSystem(inc.getSystem()); if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(inc.getSystem())) { addCodes(context.expandVS(inc, canBeHeirarchy), params, profile, imports); return; throw new TerminologyServiceException("unable to find code system " + inc.getSystem().toString()); 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, profile, imports); 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) 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())) {
/** * 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()); }
CodeSystem cs = new CodeSystem(); cs.setUrl("http://hl7.org/fhir/sid/icpc2"); cs.setVersion(title.getAttribute("version")); cs.setName(title.getAttribute("name")); identifier = XMLUtil.getNamedChild(doc.getDocumentElement(), "Identifier"); cs.setPublisher(identifier.getAttribute("authority")); cs.setIdentifier(new Identifier().setValue(identifier.getAttribute("uid"))); cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.CLASSIFIEDWITH); authors = new ArrayList<Element>(); XMLUtil.getNamedChildren(XMLUtil.getNamedChild(doc.getDocumentElement(), "Authors"), "Author", authors); for (Element a : authors) if (!a.getAttribute("name").contains("+")) cs.addContact().setName(a.getTextContent()); cs.setCopyright("The copyright of ICPC, both in hard copy and in electronic form, is owned by Wonca. See http://www.kith.no/templates/kith_WebPage____1110.aspx"); cs.setStatus(PublicationStatus.ACTIVE); cs.setDateElement(new DateTimeType(title.getAttribute("date"))); cs.setValueSet(vs.getUrl());
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 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(); }
if (def != null && def.getContent() == CodeSystemContentMode.COMPLETE) { if (!def.getCaseSensitive()) { return codeInDefine(def.getConcept(), code, def.getCaseSensitive());
return addContact(); return addUseContext(); return addJurisdiction(); return addFilter(); return addProperty(); return addConcept();
/** * @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 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; }
@Override public boolean isCodeSystemSupported(FhirContext theContext, String theSystem) { CodeSystem cs = fetchCodeSystem(theContext, theSystem); return cs != null && cs.getContent() != CodeSystemContentMode.NOTPRESENT; }
if (system.hasCaseSensitive()) { caseSensitive = system.getCaseSensitive();