Merge pull request #2075 from jamesagnew/ft_2020_09_11_term_multi_version_support_loader

Added to support term multi version
This commit is contained in:
Frank Tao 2020-09-14 16:00:27 -04:00 committed by GitHub
commit 64d3e79a37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 16 deletions

View File

@ -52,7 +52,7 @@ public abstract class BaseLoincHandler implements IRecordHandler {
private final List<ValueSet> myValueSets;
private final Map<String, ValueSet> myIdToValueSet = new HashMap<>();
private final Map<String, TermConcept> myCode2Concept;
private final Properties myUploadProperties;
protected final Properties myUploadProperties;
BaseLoincHandler(Map<String, TermConcept> theCode2Concept, List<ValueSet> theValueSets, List<ConceptMap> theConceptMaps, Properties theUploadProperties) {
myValueSets = theValueSets;
@ -115,7 +115,7 @@ public abstract class BaseLoincHandler implements IRecordHandler {
conceptMap.setId(theMapping.getConceptMapId());
conceptMap.setUrl(theMapping.getConceptMapUri());
conceptMap.setName(theMapping.getConceptMapName());
conceptMap.setVersion(myUploadProperties.getProperty(LOINC_CONCEPTMAP_VERSION.getCode()));
conceptMap.setVersion(theMapping.getConceptMapVersion());
conceptMap.setPublisher(REGENSTRIEF_INSTITUTE_INC);
conceptMap.addContact()
.setName(REGENSTRIEF_INSTITUTE_INC)
@ -226,6 +226,7 @@ public abstract class BaseLoincHandler implements IRecordHandler {
private String myCopyright;
private String myConceptMapId;
private String myConceptMapUri;
private String myConceptMapVersion;
private String myConceptMapName;
private String mySourceCodeSystem;
private String mySourceCode;
@ -263,6 +264,15 @@ public abstract class BaseLoincHandler implements IRecordHandler {
return this;
}
String getConceptMapVersion() {
return myConceptMapVersion;
}
ConceptMapping setConceptMapVersion(String theConceptMapVersion) {
myConceptMapVersion = theConceptMapVersion;
return this;
}
String getCopyright() {
return myCopyright;
}

View File

@ -1,5 +1,17 @@
package ca.uhn.fhir.jpa.term.loinc;
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_CONCEPTMAP_VERSION;
import static org.apache.commons.lang3.StringUtils.trim;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.csv.CSVRecord;
import org.hl7.fhir.r4.model.ConceptMap;
import org.hl7.fhir.r4.model.Enumerations;
import org.hl7.fhir.r4.model.ValueSet;
/*-
* #%L
* HAPI FHIR JPA Server
@ -21,18 +33,8 @@ package ca.uhn.fhir.jpa.term.loinc;
*/
import ca.uhn.fhir.jpa.entity.TermConcept;
import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc;
import ca.uhn.fhir.jpa.term.IRecordHandler;
import org.apache.commons.csv.CSVRecord;
import org.hl7.fhir.r4.model.ConceptMap;
import org.hl7.fhir.r4.model.Enumerations;
import org.hl7.fhir.r4.model.ValueSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import static org.apache.commons.lang3.StringUtils.trim;
import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc;
public class LoincIeeeMedicalDeviceCodeHandler extends BaseLoincHandler implements IRecordHandler {
@ -51,6 +53,7 @@ public class LoincIeeeMedicalDeviceCodeHandler extends BaseLoincHandler implemen
@Override
public void accept(CSVRecord theRecord) {
String loincIeeeCmVersion = myUploadProperties.getProperty(LOINC_CONCEPTMAP_VERSION.getCode());
String loincNumber = trim(theRecord.get("LOINC_NUM"));
String longCommonName = trim(theRecord.get("LOINC_LONG_COMMON_NAME"));
String ieeeCode = trim(theRecord.get("IEEE_CF_CODE10"));
@ -63,6 +66,7 @@ public class LoincIeeeMedicalDeviceCodeHandler extends BaseLoincHandler implemen
new ConceptMapping()
.setConceptMapId(LOINC_IEEE_CM_ID)
.setConceptMapUri(LOINC_IEEE_CM_URI)
.setConceptMapVersion(loincIeeeCmVersion)
.setConceptMapName(LOINC_IEEE_CM_NAME)
.setSourceCodeSystem(sourceCodeSystemUri)
.setSourceCode(loincNumber)

View File

@ -33,6 +33,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_CONCEPTMAP_VERSION;
import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.trim;
@ -75,6 +76,9 @@ public class LoincPartRelatedCodeMappingHandler extends BaseLoincHandler impleme
String extCodeSystemVersion = trim(theRecord.get("ExtCodeSystemVersion"));
String extCodeSystemCopyrightNotice = trim(theRecord.get("ExtCodeSystemCopyrightNotice"));
// ConceptMap version from properties files
String loincPartMapVersion = myUploadProperties.getProperty(LOINC_CONCEPTMAP_VERSION.getCode());
Enumerations.ConceptMapEquivalence equivalence;
switch (trim(defaultString(mapType))) {
case "":
@ -130,6 +134,7 @@ public class LoincPartRelatedCodeMappingHandler extends BaseLoincHandler impleme
new ConceptMapping()
.setConceptMapId(loincPartMapId)
.setConceptMapUri(loincPartMapUri)
.setConceptMapVersion(loincPartMapVersion)
.setConceptMapName(loincPartMapName)
.setSourceCodeSystem(ITermLoaderSvc.LOINC_URI)
.setSourceCode(partNumber)

View File

@ -31,6 +31,7 @@ import org.hl7.fhir.r4.model.ValueSet;
import java.util.*;
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_CONCEPTMAP_VERSION;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.trim;
@ -80,6 +81,9 @@ public class LoincRsnaPlaybookHandler extends BaseLoincHandler implements IRecor
String rpid = trim(theRecord.get("RPID"));
String longName = trim(theRecord.get("LongName"));
// ConceptMap version from properties files
String loincRsnaCmVersion = myUploadProperties.getProperty(LOINC_CONCEPTMAP_VERSION.getCode());
// RSNA Codes VS
ValueSet vs;
if (!myIdToValueSet.containsKey(RSNA_CODES_VS_ID)) {
@ -176,6 +180,7 @@ public class LoincRsnaPlaybookHandler extends BaseLoincHandler implements IRecor
new ConceptMapping()
.setConceptMapId(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_ID)
.setConceptMapUri(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_URI)
.setConceptMapVersion(loincRsnaCmVersion)
.setConceptMapName(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_NAME)
.setSourceCodeSystem(ITermLoaderSvc.LOINC_URI)
.setSourceCode(partNumber)
@ -193,6 +198,7 @@ public class LoincRsnaPlaybookHandler extends BaseLoincHandler implements IRecor
new ConceptMapping()
.setConceptMapId(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_ID)
.setConceptMapUri(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_URI)
.setConceptMapVersion(loincRsnaCmVersion)
.setConceptMapName(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_NAME)
.setSourceCodeSystem(ITermLoaderSvc.LOINC_URI)
.setSourceCode(loincNumber)

View File

@ -17,12 +17,10 @@ import ca.uhn.fhir.jpa.term.loinc.LoincTop2000LabResultsUsHandler;
import ca.uhn.fhir.jpa.term.loinc.LoincUniversalOrderSetHandler;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.util.TestUtil;
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.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@ -167,7 +165,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
assertEquals(1, group.getElement().get(0).getTarget().size());
assertEquals("420710006", group.getElement().get(0).getTarget().get(0).getCode());
assertEquals("Interferon beta (substance)", group.getElement().get(0).getTarget().get(0).getDisplay());
// Document Ontology ValueSet
vs = valueSets.get(LoincDocumentOntologyHandler.DOCUMENT_ONTOLOGY_CODES_VS_ID);
assertEquals(LoincDocumentOntologyHandler.DOCUMENT_ONTOLOGY_CODES_VS_NAME, vs.getName());
@ -220,6 +218,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
// RSNA Playbook - LOINC Part -> RadLex RID Mappings
conceptMap = conceptMaps.get(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_ID);
assertEquals(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_URI, conceptMap.getUrl());
assertEquals("Beta.1", conceptMap.getVersion());
assertEquals(LoincPartRelatedCodeMappingHandler.LOINC_PART_TO_RID_PART_MAP_NAME, conceptMap.getName());
assertEquals(1, conceptMap.getGroup().size());
group = conceptMap.getGroupFirstRep();
@ -236,6 +235,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
// RSNA Playbook - LOINC Term -> RadLex RPID Mappings
conceptMap = conceptMaps.get(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_ID);
assertEquals(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_URI, conceptMap.getUrl());
assertEquals("Beta.1", conceptMap.getVersion());
assertEquals(LoincPartRelatedCodeMappingHandler.LOINC_TERM_TO_RPID_PART_MAP_NAME, conceptMap.getName());
assertEquals(1, conceptMap.getGroup().size());
group = conceptMap.getGroupFirstRep();
@ -302,6 +302,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
ourLog.debug(FhirContext.forCached(FhirVersionEnum.R4).newXmlParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
assertEquals(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_NAME, conceptMap.getName());
assertEquals(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_URI, conceptMap.getUrl());
assertEquals("Beta.1", conceptMap.getVersion());
assertEquals(1, conceptMap.getGroup().size());
assertEquals(ITermLoaderSvc.LOINC_URI, conceptMap.getGroup().get(0).getSource());
assertEquals(ITermLoaderSvc.IEEE_11073_10101_URI, conceptMap.getGroup().get(0).getTarget());