diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincAnswerListHandler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincAnswerListHandler.java index 55605dc66e6..118f4ee98f7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincAnswerListHandler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/loinc/LoincAnswerListHandler.java @@ -63,9 +63,6 @@ public class LoincAnswerListHandler extends BaseLoincHandler { String extCodeSystem = trim(theRecord.get("ExtCodeSystem")); String extCodeSystemVersion = trim(theRecord.get("ExtCodeSystemVersion")); - if (isBlank(answerString)) { - return; - } // Answer list code if (!myCode2Concept.containsKey(answerListId)) { @@ -74,16 +71,6 @@ public class LoincAnswerListHandler extends BaseLoincHandler { myCode2Concept.put(answerListId, concept); } - // Answer code - if (!myCode2Concept.containsKey(answerString)) { - TermConcept concept = new TermConcept(myCodeSystemVersion, answerString); - concept.setDisplay(displayText); - if (isNotBlank(sequenceNumber) && sequenceNumber.matches("^[0-9]$")) { - concept.setSequence(Integer.parseInt(sequenceNumber)); - } - myCode2Concept.put(answerString, concept); - } - // Answer list ValueSet ValueSet vs = getValueSet(answerListId, "http://loinc.org/vs/" + answerListId, answerListName, "answerlist.version"); if (vs.getIdentifier().isEmpty()) { @@ -92,13 +79,28 @@ public class LoincAnswerListHandler extends BaseLoincHandler { .setValue("urn:oid:" + answerListOid); } - vs - .getCompose() - .getIncludeFirstRep() - .setSystem(IHapiTerminologyLoaderSvc.LOINC_URI) - .addConcept() - .setCode(answerString) - .setDisplay(displayText); + if (isNotBlank(answerString)) { + + // Answer code + if (!myCode2Concept.containsKey(answerString)) { + TermConcept concept = new TermConcept(myCodeSystemVersion, answerString); + concept.setDisplay(displayText); + if (isNotBlank(sequenceNumber) && sequenceNumber.matches("^[0-9]$")) { + concept.setSequence(Integer.parseInt(sequenceNumber)); + } + myCode2Concept.put(answerString, concept); + } + + vs + .getCompose() + .getIncludeFirstRep() + .setSystem(IHapiTerminologyLoaderSvc.LOINC_URI) + .addConcept() + .setCode(answerString) + .setDisplay(displayText); + + } + } } 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 99080fa6619..2169febd229 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 @@ -156,6 +156,10 @@ public class TerminologyLoaderSvcLoincTest { assertEquals("LA6270-8", vs.getCompose().getInclude().get(0).getConcept().get(0).getCode()); assertEquals("Never", vs.getCompose().getInclude().get(0).getConcept().get(0).getDisplay()); + // External AnswerList + vs = valueSets.get("LL1892-0"); + assertEquals(0, vs.getCompose().getIncludeFirstRep().getConcept().size()); + // Part code = concepts.get("LP101394-7"); assertEquals("LP101394-7", code.getCode()); diff --git a/hapi-fhir-jpaserver-base/src/test/resources/loinc/AnswerList.csv b/hapi-fhir-jpaserver-base/src/test/resources/loinc/AnswerList.csv index 8af66cca178..a448cf80f2d 100644 --- a/hapi-fhir-jpaserver-base/src/test/resources/loinc/AnswerList.csv +++ b/hapi-fhir-jpaserver-base/src/test/resources/loinc/AnswerList.csv @@ -1,11 +1,12 @@ -"AnswerListId","AnswerListName" ,"AnswerListOID" ,"ExtDefinedYN","ExtDefinedAnswerListCodeSystem","ExtDefinedAnswerListLink","AnswerStringId","LocalAnswerCode","LocalAnswerCodeSystem","SequenceNumber","DisplayText" ,"ExtCodeId","ExtCodeDisplayName" ,"ExtCodeSystem" ,"ExtCodeSystemVersion" ,"ExtCodeSystemCopyrightNotice" ,"SubsequentTextPrompt","Description","Score" -"LL1000-0" ,"PhenX05_13_30D bread amt","1.3.6.1.4.1.12009.10.1.165","N" , , ,"LA13825-7" ,"1" , ,1 ,"1 slice or 1 dinner roll" , , , , , , , , -"LL1000-0" ,"PhenX05_13_30D bread amt","1.3.6.1.4.1.12009.10.1.165","N" , , ,"LA13838-0" ,"2" , ,2 ,"2 slices or 2 dinner rolls" , , , , , , , , -"LL1000-0" ,"PhenX05_13_30D bread amt","1.3.6.1.4.1.12009.10.1.165","N" , , ,"LA13892-7" ,"3" , ,3 ,"More than 2 slices or 2 dinner rolls", , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA6270-8" ,"00" , ,1 ,"Never" , , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA13836-4" ,"01" , ,2 ,"1-3 times per month" , , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA13834-9" ,"02" , ,3 ,"1-2 times per week" , , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA13853-9" ,"03" , ,4 ,"3-4 times per week" , , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA13860-4" ,"04" , ,5 ,"5-6 times per week" , , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA13827-3" ,"05" , ,6 ,"1 time per day" , , , , , , , , -"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166","N" , , ,"LA4389-8" ,"97" , ,11 ,"Refused" ,"443390004","Refused (qualifier value)","http://snomed.info/sct","http://snomed.info/sct/900000000000207008/version/20170731","This material includes SNOMED Clinical Terms® (SNOMED CT®) which is used by permission of the International Health Terminology Standards Development Organisation (IHTSDO) under license. All rights reserved. SNOMED CT® was originally created by The College", , , +"AnswerListId","AnswerListName" ,"AnswerListOID" ,"ExtDefinedYN","ExtDefinedAnswerListCodeSystem","ExtDefinedAnswerListLink" ,"AnswerStringId","LocalAnswerCode","LocalAnswerCodeSystem","SequenceNumber","DisplayText" ,"ExtCodeId","ExtCodeDisplayName" ,"ExtCodeSystem" ,"ExtCodeSystemVersion" ,"ExtCodeSystemCopyrightNotice" ,"SubsequentTextPrompt","Description","Score" +"LL1000-0" ,"PhenX05_13_30D bread amt","1.3.6.1.4.1.12009.10.1.165" ,"N" , , ,"LA13825-7" ,"1" , ,1 ,"1 slice or 1 dinner roll" , , , , , , , , +"LL1000-0" ,"PhenX05_13_30D bread amt","1.3.6.1.4.1.12009.10.1.165" ,"N" , , ,"LA13838-0" ,"2" , ,2 ,"2 slices or 2 dinner rolls" , , , , , , , , +"LL1000-0" ,"PhenX05_13_30D bread amt","1.3.6.1.4.1.12009.10.1.165" ,"N" , , ,"LA13892-7" ,"3" , ,3 ,"More than 2 slices or 2 dinner rolls", , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA6270-8" ,"00" , ,1 ,"Never" , , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA13836-4" ,"01" , ,2 ,"1-3 times per month" , , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA13834-9" ,"02" , ,3 ,"1-2 times per week" , , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA13853-9" ,"03" , ,4 ,"3-4 times per week" , , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA13860-4" ,"04" , ,5 ,"5-6 times per week" , , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA13827-3" ,"05" , ,6 ,"1 time per day" , , , , , , , , +"LL1001-8" ,"PhenX05_14_30D freq amts","1.3.6.1.4.1.12009.10.1.166" ,"N" , , ,"LA4389-8" ,"97" , ,11 ,"Refused" ,"443390004","Refused (qualifier value)","http://snomed.info/sct","http://snomed.info/sct/900000000000207008/version/20170731","This material includes SNOMED Clinical Terms® (SNOMED CT®) which is used by permission of the International Health Terminology Standards Development Organisation (IHTSDO) under license. All rights reserved. SNOMED CT® was originally created by The College", , , +"LL1892-0" ,"ICD-9_ICD-10" ,"1.3.6.1.4.1.12009.10.1.1069","Y" , ,"http://www.cdc.gov/nchs/icd.htm", , , , , , , , , , , , ,