Make LOINC Top2000* files optional in terminology loader.

This commit is contained in:
ianmarshall 2021-02-10 22:30:19 -05:00
parent 772bc9c0ea
commit a383cb94fc
2 changed files with 59 additions and 38 deletions

View File

@ -138,8 +138,6 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc {
uploadProperties.getProperty(LOINC_PART_FILE.getCode(), LOINC_PART_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_PART_RELATED_CODE_MAPPING_FILE.getCode(), LOINC_PART_RELATED_CODE_MAPPING_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_RSNA_PLAYBOOK_FILE.getCode(), LOINC_RSNA_PLAYBOOK_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_UNIVERSAL_LAB_ORDER_VALUESET_FILE.getCode(), LOINC_UNIVERSAL_LAB_ORDER_VALUESET_FILE_DEFAULT.getCode())
);
descriptors.verifyMandatoryFilesExist(mandatoryFilenameFragments);
@ -153,8 +151,10 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc {
List<String> optionalFilenameFragments = Arrays.asList(
uploadProperties.getProperty(LOINC_GROUP_FILE.getCode(), LOINC_GROUP_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_GROUP_TERMS_FILE.getCode(), LOINC_GROUP_TERMS_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_PARENT_GROUP_FILE.getCode(), LOINC_PARENT_GROUP_FILE_DEFAULT.getCode())
);
uploadProperties.getProperty(LOINC_PARENT_GROUP_FILE.getCode(), LOINC_PARENT_GROUP_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE_DEFAULT.getCode()),
uploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE_DEFAULT.getCode())
);
descriptors.verifyOptionalFilesExist(optionalFilenameFragments);
ourLog.info("Beginning LOINC processing");
@ -477,11 +477,11 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc {
// Top 2000 codes - US
handler = new LoincTop2000LabResultsUsHandler(code2concept, valueSets, conceptMaps, theUploadProperties);
iterateOverZipFile(theDescriptors, theUploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE_DEFAULT.getCode()), handler, ',', QuoteMode.NON_NUMERIC, false);
iterateOverZipFileOptional(theDescriptors, theUploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE_DEFAULT.getCode()), handler, ',', QuoteMode.NON_NUMERIC, false);
// Top 2000 codes - SI
handler = new LoincTop2000LabResultsSiHandler(code2concept, valueSets, conceptMaps, theUploadProperties);
iterateOverZipFile(theDescriptors, theUploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE_DEFAULT.getCode()), handler, ',', QuoteMode.NON_NUMERIC, false);
iterateOverZipFileOptional(theDescriptors, theUploadProperties.getProperty(LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE.getCode(), LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE_DEFAULT.getCode()), handler, ',', QuoteMode.NON_NUMERIC, false);
// Universal lab order ValueSet
handler = new LoincUniversalOrderSetHandler(code2concept, valueSets, conceptMaps, theUploadProperties);

View File

@ -97,11 +97,17 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
verifyLoadLoinc();
}
@Test
public void testLoadLoincWithMandatoryFilesOnly() throws Exception {
addLoincMandatoryFilesWithoutTop2000ToZip(myFiles);
verifyLoadLoinc(false);
}
@Test
public void testLoadLoincInvalidPartLinkFiles() throws IOException {
// Missing all PartLinkFiles
addBaseLoincMandatoryFilesToZip(myFiles);
addBaseLoincMandatoryFilesToZip(myFiles, true);
myFiles.addFileZip("/loinc/", LOINC_UPLOAD_PROPERTIES_FILE.getCode());
try {
@ -134,6 +140,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
private void verifyLoadLoinc() {
verifyLoadLoinc(true);
}
private void verifyLoadLoinc(boolean theIncludeTop2000) {
// Actually do the load
mySvc.loadLoinc(myFiles.getFiles(), mySrd);
@ -319,31 +329,33 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
assertEquals("US Retroperitoneum", group.getElement().get(0).getTarget().get(0).getDisplay());
assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, group.getElement().get(0).getTarget().get(0).getEquivalence());
// TOP 2000 - US
vs = valueSets.get(LoincTop2000LabResultsUsHandler.TOP_2000_US_VS_ID);
assertEquals(vs.getName(), LoincTop2000LabResultsUsHandler.TOP_2000_US_VS_NAME);
assertEquals(vs.getUrl(), LoincTop2000LabResultsUsHandler.TOP_2000_US_VS_URI);
assertEquals(1, vs.getCompose().getInclude().size());
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
assertEquals(9, vs.getCompose().getInclude().get(0).getConcept().size());
assertEquals("2160-0", vs.getCompose().getInclude().get(0).getConcept().get(0).getCode());
assertEquals("Creatinine [Mass/volume] in Serum or Plasma", vs.getCompose().getInclude().get(0).getConcept().get(0).getDisplay());
assertEquals("718-7", vs.getCompose().getInclude().get(0).getConcept().get(1).getCode());
assertEquals("Hemoglobin [Mass/volume] in Blood", vs.getCompose().getInclude().get(0).getConcept().get(1).getDisplay());
assertNull(vs.getVersion());
if (theIncludeTop2000) {
// TOP 2000 - US
vs = valueSets.get(LoincTop2000LabResultsUsHandler.TOP_2000_US_VS_ID);
assertEquals(vs.getName(), LoincTop2000LabResultsUsHandler.TOP_2000_US_VS_NAME);
assertEquals(vs.getUrl(), LoincTop2000LabResultsUsHandler.TOP_2000_US_VS_URI);
assertEquals(1, vs.getCompose().getInclude().size());
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
assertEquals(9, vs.getCompose().getInclude().get(0).getConcept().size());
assertEquals("2160-0", vs.getCompose().getInclude().get(0).getConcept().get(0).getCode());
assertEquals("Creatinine [Mass/volume] in Serum or Plasma", vs.getCompose().getInclude().get(0).getConcept().get(0).getDisplay());
assertEquals("718-7", vs.getCompose().getInclude().get(0).getConcept().get(1).getCode());
assertEquals("Hemoglobin [Mass/volume] in Blood", vs.getCompose().getInclude().get(0).getConcept().get(1).getDisplay());
assertNull(vs.getVersion());
// TOP 2000 - SI
vs = valueSets.get(LoincTop2000LabResultsSiHandler.TOP_2000_SI_VS_ID);
assertEquals(vs.getName(), LoincTop2000LabResultsSiHandler.TOP_2000_SI_VS_NAME);
assertEquals(vs.getUrl(), LoincTop2000LabResultsSiHandler.TOP_2000_SI_VS_URI);
assertEquals(1, vs.getCompose().getInclude().size());
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
assertEquals(9, vs.getCompose().getInclude().get(0).getConcept().size());
assertEquals("14682-9", vs.getCompose().getInclude().get(0).getConcept().get(0).getCode());
assertEquals("Creatinine [Moles/volume] in Serum or Plasma", vs.getCompose().getInclude().get(0).getConcept().get(0).getDisplay());
assertEquals("718-7", vs.getCompose().getInclude().get(0).getConcept().get(1).getCode());
assertEquals("Hemoglobin [Mass/volume] in Blood", vs.getCompose().getInclude().get(0).getConcept().get(1).getDisplay());
assertNull(vs.getVersion());
// TOP 2000 - SI
vs = valueSets.get(LoincTop2000LabResultsSiHandler.TOP_2000_SI_VS_ID);
assertEquals(vs.getName(), LoincTop2000LabResultsSiHandler.TOP_2000_SI_VS_NAME);
assertEquals(vs.getUrl(), LoincTop2000LabResultsSiHandler.TOP_2000_SI_VS_URI);
assertEquals(1, vs.getCompose().getInclude().size());
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
assertEquals(9, vs.getCompose().getInclude().get(0).getConcept().size());
assertEquals("14682-9", vs.getCompose().getInclude().get(0).getConcept().get(0).getCode());
assertEquals("Creatinine [Moles/volume] in Serum or Plasma", vs.getCompose().getInclude().get(0).getConcept().get(0).getDisplay());
assertEquals("718-7", vs.getCompose().getInclude().get(0).getConcept().get(1).getCode());
assertEquals("Hemoglobin [Mass/volume] in Blood", vs.getCompose().getInclude().get(0).getConcept().get(1).getDisplay());
assertNull(vs.getVersion());
}
// Universal lab order VS
vs = valueSets.get(LoincUniversalOrderSetHandler.VS_ID_BASE);
@ -581,7 +593,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
@Test
@Disabled
public void testLoadLoincMandatoryFilesOnly() throws IOException {
public void testLoadLoincMandatoryFilesPlusTop2000() throws IOException {
addLoincMandatoryFilesToZip(myFiles);
// Actually do the load
@ -619,13 +631,20 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
}
public static void addLoincMandatoryFilesAndSinglePartLinkToZip(ZipCollectionBuilder theFiles) throws IOException {
addBaseLoincMandatoryFilesToZip(theFiles);
addBaseLoincMandatoryFilesToZip(theFiles, true);
theFiles.addFileZip("/loinc/", "loincupload_singlepartlink.properties");
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_DEFAULT.getCode());
}
public static void addLoincMandatoryFilesToZip(ZipCollectionBuilder theFiles) throws IOException {
addBaseLoincMandatoryFilesToZip(theFiles);
addBaseLoincMandatoryFilesToZip(theFiles, true);
theFiles.addFileZip("/loinc/", LOINC_UPLOAD_PROPERTIES_FILE.getCode());
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_PRIMARY_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_SUPPLEMENTARY_DEFAULT.getCode());
}
public static void addLoincMandatoryFilesWithoutTop2000ToZip(ZipCollectionBuilder theFiles) throws IOException {
addBaseLoincMandatoryFilesToZip(theFiles, false);
theFiles.addFileZip("/loinc/", LOINC_UPLOAD_PROPERTIES_FILE.getCode());
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_PRIMARY_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_SUPPLEMENTARY_DEFAULT.getCode());
@ -635,10 +654,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
theFiles.addFileZip("/loinc/", thePropertiesFile);
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_PRIMARY_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_PART_LINK_FILE_SUPPLEMENTARY_DEFAULT.getCode());
addBaseLoincMandatoryFilesToZip(theFiles);
addBaseLoincMandatoryFilesToZip(theFiles, true);
}
private static void addBaseLoincMandatoryFilesToZip(ZipCollectionBuilder theFiles) throws IOException{
private static void addBaseLoincMandatoryFilesToZip(ZipCollectionBuilder theFiles, Boolean theIncludeTop2000) throws IOException{
theFiles.addFileZip("/loinc/", LOINC_GROUP_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_GROUP_TERMS_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_PARENT_GROUP_FILE_DEFAULT.getCode());
@ -656,8 +675,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
theFiles.addFileZip("/loinc/", LOINC_UNIVERSAL_LAB_ORDER_VALUESET_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_IEEE_MEDICAL_DEVICE_CODE_MAPPING_TABLE_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_IMAGING_DOCUMENT_CODES_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE_DEFAULT.getCode());
if (theIncludeTop2000) {
theFiles.addFileZip("/loinc/", LOINC_TOP2000_COMMON_LAB_RESULTS_SI_FILE_DEFAULT.getCode());
theFiles.addFileZip("/loinc/", LOINC_TOP2000_COMMON_LAB_RESULTS_US_FILE_DEFAULT.getCode());
}
}
@Test