From 476eba676e64369a24f076f7d3c404ea783ac782 Mon Sep 17 00:00:00 2001 From: ianmarshall Date: Wed, 7 Oct 2020 15:07:25 -0400 Subject: [PATCH] Fixed loader so that it now sets source system version for ConceptMap resources. --- .../fhir/jpa/term/loinc/BaseLoincHandler.java | 13 +++++++++- .../LoincIeeeMedicalDeviceCodeHandler.java | 1 + .../LoincPartRelatedCodeMappingHandler.java | 1 + .../term/loinc/LoincRsnaPlaybookHandler.java | 2 ++ .../term/TerminologyLoaderSvcLoincTest.java | 26 +++++++++++++------ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/BaseLoincHandler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/BaseLoincHandler.java index aeb78cf8aca..5e17816f996 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/BaseLoincHandler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/BaseLoincHandler.java @@ -154,6 +154,7 @@ public abstract class BaseLoincHandler implements IRecordHandler { if (group == null) { group = conceptMap.addGroup(); group.setSource(theMapping.getSourceCodeSystem()); + group.setSourceVersion(theMapping.getSourceCodeSystemVersion()); group.setTarget(theMapping.getTargetCodeSystem()); group.setTargetVersion(defaultIfBlank(theMapping.getTargetCodeSystemVersion(), null)); } @@ -188,7 +189,7 @@ public abstract class BaseLoincHandler implements IRecordHandler { ValueSet getValueSet(String theValueSetId, String theValueSetUri, String theValueSetName, String theVersionPropertyName) { - String version = null; + String version; if (isNotBlank(theVersionPropertyName)) { version = myUploadProperties.getProperty(theVersionPropertyName); } else { @@ -231,6 +232,7 @@ public abstract class BaseLoincHandler implements IRecordHandler { private String myConceptMapVersion; private String myConceptMapName; private String mySourceCodeSystem; + private String mySourceCodeSystemVersion; private String mySourceCode; private String mySourceDisplay; private String myTargetCodeSystem; @@ -311,6 +313,15 @@ public abstract class BaseLoincHandler implements IRecordHandler { return this; } + String getSourceCodeSystemVersion() { + return mySourceCodeSystemVersion; + } + + ConceptMapping setSourceCodeSystemVersion(String theSourceCodeSystemVersion) { + mySourceCodeSystemVersion = theSourceCodeSystemVersion; + return this; + } + String getSourceDisplay() { return mySourceDisplay; } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincIeeeMedicalDeviceCodeHandler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincIeeeMedicalDeviceCodeHandler.java index 96d310bd066..ab951be38d5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincIeeeMedicalDeviceCodeHandler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincIeeeMedicalDeviceCodeHandler.java @@ -76,6 +76,7 @@ public class LoincIeeeMedicalDeviceCodeHandler extends BaseLoincHandler implemen .setConceptMapVersion(loincIeeeCmVersion) .setConceptMapName(LOINC_IEEE_CM_NAME) .setSourceCodeSystem(sourceCodeSystemUri) + .setSourceCodeSystemVersion(codeSystemVersionId) .setSourceCode(loincNumber) .setSourceDisplay(longCommonName) .setTargetCodeSystem(targetCodeSystemUri) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincPartRelatedCodeMappingHandler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincPartRelatedCodeMappingHandler.java index bb3f5ac295e..e67a0fef7c7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincPartRelatedCodeMappingHandler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincPartRelatedCodeMappingHandler.java @@ -145,6 +145,7 @@ public class LoincPartRelatedCodeMappingHandler extends BaseLoincHandler impleme .setConceptMapVersion(loincPartMapVersion) .setConceptMapName(loincPartMapName) .setSourceCodeSystem(ITermLoaderSvc.LOINC_URI) + .setSourceCodeSystemVersion(codeSystemVersionId) .setSourceCode(partNumber) .setSourceDisplay(partName) .setTargetCodeSystem(extCodeSystem) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincRsnaPlaybookHandler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincRsnaPlaybookHandler.java index 24b1c1a3daa..831206b62aa 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincRsnaPlaybookHandler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincRsnaPlaybookHandler.java @@ -198,6 +198,7 @@ public class LoincRsnaPlaybookHandler extends BaseLoincHandler implements IRecor .setConceptMapVersion(loincRsnaCmVersion) .setConceptMapName(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_NAME) .setSourceCodeSystem(ITermLoaderSvc.LOINC_URI) + .setSourceCodeSystemVersion(codeSystemVersionId) .setSourceCode(partNumber) .setSourceDisplay(partName) .setTargetCodeSystem(RID_CS_URI) @@ -216,6 +217,7 @@ public class LoincRsnaPlaybookHandler extends BaseLoincHandler implements IRecor .setConceptMapVersion(loincRsnaCmVersion) .setConceptMapName(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_NAME) .setSourceCodeSystem(ITermLoaderSvc.LOINC_URI) + .setSourceCodeSystemVersion(codeSystemVersionId) .setSourceCode(loincNumber) .setSourceDisplay(longCommonName) .setTargetCodeSystem(RPID_CS_URI) 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 7a994b31e25..54ee51eb873 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 @@ -116,7 +116,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { } - private void verifyLoadLoinc() throws Exception { + private void verifyLoadLoinc() { // Actually do the load mySvc.loadLoinc(myFiles.getFiles(), mySrd); @@ -198,14 +198,15 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { // Part Mappings conceptMap = conceptMaps.get(LoincPartRelatedCodeMappingHandler.LOINC_SCT_PART_MAP_ID); - assertEquals(null, conceptMap.getSource()); - assertEquals(null, conceptMap.getTarget()); + assertNull(conceptMap.getSource()); + assertNull(conceptMap.getTarget()); assertEquals(LoincPartRelatedCodeMappingHandler.LOINC_SCT_PART_MAP_URI, conceptMap.getUrl()); 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/. The LOINC Part File, LOINC/SNOMED CT Expression Association and Map Sets File, RELMA database and associated search index files include SNOMED Clinical Terms (SNOMED CT®) which is used by permission of the International Health Terminology Standards Development Organisation (IHTSDO) under license. All rights are reserved. SNOMED CT® was originally created by The College of American Pathologists. “SNOMED” and “SNOMED CT” are registered trademarks of the IHTSDO. Use of SNOMED CT content is subject to the terms and conditions set forth in the SNOMED CT Affiliate License Agreement. It is the responsibility of those implementing this product to ensure they are appropriately licensed and for more information on the license, including how to register as an Affiliate Licensee, please refer to http://www.snomed.org/snomed-ct/get-snomed-ct or info@snomed.org. Under the terms of the Affiliate License, use of SNOMED CT in countries that are not IHTSDO Members is subject to reporting and fee payment obligations. However, IHTSDO agrees to waive the requirements to report and pay fees for use of SNOMED CT content included in the LOINC Part Mapping and LOINC Term Associations for purposes that support or enable more effective use of LOINC. This material includes content from the US Edition to SNOMED CT, which is developed and maintained by the U.S. National Library of Medicine and is available to authorized UMLS Metathesaurus Licensees from the UTS Downloads site at https://uts.nlm.nih.gov.", conceptMap.getCopyright()); assertEquals("Beta.1", conceptMap.getVersion()); assertEquals(1, conceptMap.getGroup().size()); group = conceptMap.getGroup().get(0); assertEquals(ITermLoaderSvc.LOINC_URI, group.getSource()); + assertNull(group.getSourceVersion()); assertEquals(ITermLoaderSvc.SCT_URI, group.getTarget()); assertEquals("http://snomed.info/sct/900000000000207008/version/20170731", group.getTargetVersion()); assertEquals("LP18172-4", group.getElement().get(0).getCode()); @@ -274,6 +275,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { group = conceptMap.getGroupFirstRep(); // all entries have the same source and target so these should be null assertEquals(ITermLoaderSvc.LOINC_URI, group.getSource()); + assertNull(group.getSourceVersion()); assertEquals(LoincRsnaPlaybookHandler.RID_CS_URI, group.getTarget()); assertEquals("LP199995-4", group.getElement().get(0).getCode()); assertEquals("Neck", group.getElement().get(0).getDisplay()); @@ -291,6 +293,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { group = conceptMap.getGroupFirstRep(); // all entries have the same source and target so these should be null assertEquals(ITermLoaderSvc.LOINC_URI, group.getSource()); + assertNull(group.getSourceVersion()); assertEquals(LoincRsnaPlaybookHandler.RPID_CS_URI, group.getTarget()); assertEquals("24531-6", group.getElement().get(0).getCode()); assertEquals("US Retroperitoneum", group.getElement().get(0).getDisplay()); @@ -418,6 +421,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { List loincCM_resources = myConceptMapCaptor.getValue(); for (ConceptMap loincCM : loincCM_resources) { assertEquals("2.67.Beta.1", loincCM.getVersion()); + assertEquals(1, loincCM.getGroup().size()); + ConceptMap.ConceptMapGroupComponent group = loincCM.getGroup().get(0); + assertEquals(ITermLoaderSvc.LOINC_URI, group.getSource()); + assertEquals("2.67", group.getSourceVersion()); } // Update LOINC marked as version 2.67 @@ -439,6 +446,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { loincCM_resources = myConceptMapCaptor.getValue(); for (ConceptMap loincCM : loincCM_resources) { assertEquals("2.67.Beta.1", loincCM.getVersion()); + assertEquals(1, loincCM.getGroup().size()); + ConceptMap.ConceptMapGroupComponent group = loincCM.getGroup().get(0); + assertEquals(ITermLoaderSvc.LOINC_URI, group.getSource()); + assertEquals("2.67", group.getSourceVersion()); } // Load LOINC marked as version 2.68 @@ -460,6 +471,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { loincCM_resources = myConceptMapCaptor.getValue(); for (ConceptMap loincCM : loincCM_resources) { assertEquals("2.68.Beta.1", loincCM.getVersion()); + assertEquals(1, loincCM.getGroup().size()); + ConceptMap.ConceptMapGroupComponent group = loincCM.getGroup().get(0); + assertEquals(ITermLoaderSvc.LOINC_URI, group.getSource()); + assertEquals("2.68", group.getSourceVersion()); } } @@ -554,13 +569,8 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { verify(myTermCodeSystemStorageSvc, times(1)).storeNewCodeSystemVersion(mySystemCaptor.capture(), myCsvCaptor.capture(), any(RequestDetails.class), myValueSetsCaptor.capture(), myConceptMapCaptor.capture()); Map concepts = extractConcepts(); - Map valueSets = extractValueSets(); - Map conceptMaps = extractConceptMaps(); - ConceptMap conceptMap; TermConcept code; - ValueSet vs; - ConceptMap.ConceptMapGroupComponent group; // Normal LOINC code code = concepts.get("10013-1");