From 0ee15874ca773e4afe36f011e4c481dcd8fc0b98 Mon Sep 17 00:00:00 2001 From: Diederik Muylwyk Date: Mon, 26 Aug 2019 16:42:37 -0400 Subject: [PATCH] loinc-all ValueSet is now created automatically when loading LOINC terminology. --- .../jpa/term/TerminologyLoaderSvcImpl.java | 20 +++++++++++++++++++ .../term/TerminologyLoaderSvcLoincTest.java | 16 +++++++++++++++ .../jpa/term/TerminologySvcImplR4Test.java | 9 +-------- src/changes/changes.xml | 5 +++++ 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImpl.java index 5c3ec5d20a8..af8110b43bb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImpl.java @@ -32,6 +32,7 @@ import org.apache.commons.lang3.Validate; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.ConceptMap; +import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.ValueSet; import org.springframework.beans.factory.annotation.Autowired; @@ -556,6 +557,8 @@ public class TerminologyLoaderSvcImpl implements IHapiTerminologyLoaderSvc { IOUtils.closeQuietly(theDescriptors); + valueSets.add(getValueSetLoincAll()); + for (Entry next : code2concept.entrySet()) { TermConcept nextConcept = next.getValue(); if (nextConcept.getParents().isEmpty()) { @@ -573,6 +576,23 @@ public class TerminologyLoaderSvcImpl implements IHapiTerminologyLoaderSvc { return new UploadStatistics(conceptCount, target); } + private ValueSet getValueSetLoincAll() { + ValueSet retVal = new ValueSet(); + + retVal.setId("loinc-all"); + retVal.setUrl("http://loinc.org/fhir/ValueSet/loinc-all"); + retVal.setVersion("1.0.0"); + retVal.setName("All LOINC codes"); + retVal.setStatus(Enumerations.PublicationStatus.ACTIVE); + retVal.setDate(new Date()); + retVal.setPublisher("Regenstrief Institute, Inc."); + retVal.setDescription("A value set that includes all LOINC codes"); + retVal.setCopyright("This content from LOINC® is copyright © 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at https://loinc.org/license/"); + retVal.getCompose().addInclude().setSystem(IHapiTerminologyLoaderSvc.LOINC_URI); + + return retVal; + } + private UploadStatistics processSnomedCtFiles(LoadedFileDescriptors theDescriptors, RequestDetails theRequestDetails) { final TermCodeSystemVersion codeSystemVersion = new TermCodeSystemVersion(); final Map id2concept = new HashMap<>(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java index d2d3dba5d71..60fced8db94 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java @@ -255,6 +255,22 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { assertEquals("42176-8", vs.getCompose().getInclude().get(0).getConcept().get(0).getCode()); assertEquals("1,3 beta glucan [Mass/volume] in Serum", vs.getCompose().getInclude().get(0).getConcept().get(0).getDisplay()); + // All LOINC codes + assertTrue(valueSets.containsKey("loinc-all")); + vs = valueSets.get("loinc-all"); + assertEquals("http://loinc.org/fhir/ValueSet/loinc-all", vs.getUrl()); + assertEquals("1.0.0", vs.getVersion()); + assertEquals("All LOINC codes", vs.getName()); + assertEquals(Enumerations.PublicationStatus.ACTIVE, vs.getStatus()); + assertTrue(vs.hasDate()); + assertEquals("Regenstrief Institute, Inc.", vs.getPublisher()); + assertEquals("A value set that includes all LOINC codes", vs.getDescription()); + assertEquals("This content from LOINC® is copyright © 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at https://loinc.org/license/", vs.getCopyright()); + assertTrue(vs.hasCompose()); + assertTrue(vs.getCompose().hasInclude()); + assertEquals(1, vs.getCompose().getInclude().size()); + assertEquals(IHapiTerminologyLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem()); + // IEEE Medical Device Codes conceptMap = conceptMaps.get(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_ID); ourLog.debug(FhirContext.forR4().newXmlParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java index 22a42682d9e..f87145ce9f1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java @@ -29,6 +29,7 @@ import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.Nonnull; import java.io.IOException; +import java.util.Date; import java.util.List; import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; @@ -606,14 +607,6 @@ public class TerminologySvcImplR4Test extends BaseJpaR4Test { loadAndPersistCodeSystem(); } - @Test - public void testTest() { - ourLog.info("as is: {}", TermValueSetPreExpansionStatusEnum.EXPANSION_IN_PROGRESS); - ourLog.info("toString: {}", TermValueSetPreExpansionStatusEnum.EXPANSION_IN_PROGRESS.toString()); - ourLog.info("name: {}", TermValueSetPreExpansionStatusEnum.EXPANSION_IN_PROGRESS.name()); - ourLog.info("getCode: {}", TermValueSetPreExpansionStatusEnum.EXPANSION_IN_PROGRESS.getCode()); - } - @Test public void testDuplicateConceptMapUrls() { createAndPersistConceptMap(); diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 00136dd85d2..cabe1a4dd78 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -82,6 +82,11 @@ LOINC concepts now include multiaxial hierarchical properties (e.g. parent]]> and child]]>, which identify parent and child concepts. + + When loading LOINC terminology, a new ValueSet is automatically created with a single include element that + identifies the LOINC CodeSystem in ValueSet.compose.include.system]]>. This ValueSet + includes all LOINC codes. +