More loinc work

This commit is contained in:
jamesagnew 2018-03-11 19:11:31 -04:00
parent 33554189a1
commit 30cd63b929
19 changed files with 206 additions and 124 deletions

View File

@ -36,32 +36,39 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.primitive.StringDt;
/**
* Utilities for dealing with parameters resources
* Utilities for dealing with parameters resources in a version indepenedent way
*/
public class ParametersUtil {
public static void addParameterToParameters(FhirContext theContext, IBaseResource theTargetResource, Object sourceClientArgument, String theName) {
RuntimeResourceDefinition def = theContext.getResourceDefinition(theTargetResource);
/**
* Add a paratemer value to a Parameters resource
* @param theContext The FhirContext
* @param theParameters The Parameters resource
* @param theName The parametr name
* @param theValue The parameter value (can be a {@link IBaseResource resource} or a {@link IBaseDatatype datatype})
*/
public static void addParameterToParameters(FhirContext theContext, IBaseParameters theParameters, String theName, Object theValue) {
RuntimeResourceDefinition def = theContext.getResourceDefinition(theParameters);
BaseRuntimeChildDefinition paramChild = def.getChildByName("parameter");
BaseRuntimeElementCompositeDefinition<?> paramChildElem = (BaseRuntimeElementCompositeDefinition<?>) paramChild.getChildByName("parameter");
addClientParameter(theContext, sourceClientArgument, theTargetResource, paramChild, paramChildElem, theName);
addClientParameter(theContext, theValue, theParameters, paramChild, paramChildElem, theName);
}
private static void addClientParameter(FhirContext theContext, Object theSourceClientArgument, IBaseResource theTargetResource, BaseRuntimeChildDefinition paramChild, BaseRuntimeElementCompositeDefinition<?> paramChildElem, String theName) {
if (theSourceClientArgument instanceof IBaseResource) {
private static void addClientParameter(FhirContext theContext, Object theValue, IBaseResource theTargetResource, BaseRuntimeChildDefinition paramChild, BaseRuntimeElementCompositeDefinition<?> paramChildElem, String theName) {
if (theValue instanceof IBaseResource) {
IBase parameter = createParameterRepetition(theContext, theTargetResource, paramChild, paramChildElem, theName);
paramChildElem.getChildByName("resource").getMutator().addValue(parameter, (IBaseResource) theSourceClientArgument);
} else if (theSourceClientArgument instanceof IBaseDatatype) {
paramChildElem.getChildByName("resource").getMutator().addValue(parameter, (IBaseResource) theValue);
} else if (theValue instanceof IBaseDatatype) {
IBase parameter = createParameterRepetition(theContext, theTargetResource, paramChild, paramChildElem, theName);
paramChildElem.getChildByName("value[x]").getMutator().addValue(parameter, (IBaseDatatype) theSourceClientArgument);
} else if (theSourceClientArgument instanceof Collection) {
Collection<?> collection = (Collection<?>) theSourceClientArgument;
paramChildElem.getChildByName("value[x]").getMutator().addValue(parameter, (IBaseDatatype) theValue);
} else if (theValue instanceof Collection) {
Collection<?> collection = (Collection<?>) theValue;
for (Object next : collection) {
addClientParameter(theContext, next, theTargetResource, paramChild, paramChildElem, theName);
}
} else {
throw new IllegalArgumentException("Don't know how to handle value of type " + theSourceClientArgument.getClass() + " for paramater " + theName);
throw new IllegalArgumentException("Don't know how to handle value of type " + theValue.getClass() + " for paramater " + theName);
}
}

View File

@ -914,11 +914,11 @@ public class GenericClient extends BaseClient implements IGenericClient {
IBaseParameters parameters = ParametersUtil.newInstance(myContext);
switch (myOperation) {
case ADD:
ParametersUtil.addParameterToParameters(myContext, parameters, myMeta, "meta");
ParametersUtil.addParameterToParameters(myContext, parameters, "meta", myMeta);
invocation = OperationMethodBinding.createOperationInvocation(myContext, myId.getResourceType(), myId.getIdPart(), "$meta-add", parameters, false);
break;
case DELETE:
ParametersUtil.addParameterToParameters(myContext, parameters, myMeta, "meta");
ParametersUtil.addParameterToParameters(myContext, parameters, "meta", myMeta);
invocation = OperationMethodBinding.createOperationInvocation(myContext, myId.getResourceType(), myId.getIdPart(), "$meta-delete", parameters, false);
break;
case GET:

View File

@ -29,6 +29,7 @@ import java.util.Map;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
@ -179,7 +180,7 @@ public class OperationParameter implements IParameter {
sourceClientArgument = myConverter.outgoingClient(sourceClientArgument);
}
ParametersUtil.addParameterToParameters(theContext, theTargetResource, sourceClientArgument, myName);
ParametersUtil.addParameterToParameters(theContext, (IBaseParameters) theTargetResource, myName, sourceClientArgument);
}

View File

@ -70,7 +70,7 @@ public class ValidateMethodBindingDstu2Plus extends OperationMethodBinding {
public static BaseHttpClientInvocation createValidateInvocation(FhirContext theContext, IBaseResource theResource) {
IBaseParameters parameters = (IBaseParameters) theContext.getResourceDefinition("Parameters").newInstance();
ParametersUtil.addParameterToParameters(theContext, parameters, theResource, "resource");
ParametersUtil.addParameterToParameters(theContext, parameters, "resource", theResource);
String resourceName = theContext.getResourceDefinition(theResource).getName();
String resourceId = theResource.getIdElement().getIdPart();

View File

@ -1,7 +1,18 @@
package ca.uhn.fhir.jpa.dao;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.StringType;
import java.util.List;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
/*
* #%L
* HAPI FHIR JPA Server
@ -21,9 +32,6 @@ import java.util.List;
* limitations under the License.
* #L%
*/
import org.hl7.fhir.instance.model.api.*;
import ca.uhn.fhir.rest.api.server.RequestDetails;
public interface IFhirResourceDaoCodeSystem<T extends IBaseResource, CD, CC> extends IFhirResourceDao<T> {
@ -31,7 +39,8 @@ public interface IFhirResourceDaoCodeSystem<T extends IBaseResource, CD, CC> ext
LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, CD theCoding, RequestDetails theRequestDetails);
public class LookupCodeResult {
class LookupCodeResult {
private String myCodeDisplay;
private boolean myCodeIsAbstract;
private String myCodeSystemDisplayName;
@ -39,62 +48,87 @@ public interface IFhirResourceDaoCodeSystem<T extends IBaseResource, CD, CC> ext
private boolean myFound;
private String mySearchedForCode;
private String mySearchedForSystem;
/**
* Constructor
*/
public LookupCodeResult() {
super();
}
public String getCodeDisplay() {
return myCodeDisplay;
}
public String getCodeSystemDisplayName() {
return myCodeSystemDisplayName;
}
public String getCodeSystemVersion() {
return myCodeSystemVersion;
}
public String getSearchedForCode() {
return mySearchedForCode;
}
public String getSearchedForSystem() {
return mySearchedForSystem;
}
public boolean isCodeIsAbstract() {
return myCodeIsAbstract;
}
public boolean isFound() {
return myFound;
}
public void setCodeDisplay(String theCodeDisplay) {
myCodeDisplay = theCodeDisplay;
}
public void setCodeIsAbstract(boolean theCodeIsAbstract) {
myCodeIsAbstract = theCodeIsAbstract;
public String getCodeSystemDisplayName() {
return myCodeSystemDisplayName;
}
public void setCodeSystemDisplayName(String theCodeSystemDisplayName) {
myCodeSystemDisplayName = theCodeSystemDisplayName;
}
public String getCodeSystemVersion() {
return myCodeSystemVersion;
}
public void setCodeSystemVersion(String theCodeSystemVersion) {
myCodeSystemVersion = theCodeSystemVersion;
}
public void setFound(boolean theFound) {
myFound = theFound;
public String getSearchedForCode() {
return mySearchedForCode;
}
public void setSearchedForCode(String theSearchedForCode) {
mySearchedForCode = theSearchedForCode;
}
public String getSearchedForSystem() {
return mySearchedForSystem;
}
public void setSearchedForSystem(String theSearchedForSystem) {
mySearchedForSystem = theSearchedForSystem;
}
public boolean isCodeIsAbstract() {
return myCodeIsAbstract;
}
public void setCodeIsAbstract(boolean theCodeIsAbstract) {
myCodeIsAbstract = theCodeIsAbstract;
}
public boolean isFound() {
return myFound;
}
public void setFound(boolean theFound) {
myFound = theFound;
}
public void throwNotFoundIfAppropriate() {
if (isFound() == false) {
throw new ResourceNotFoundException("Unable to find code[" + getSearchedForCode() + "] in system[" + getSearchedForSystem() + "]");
}
}
public Parameters toParameters() {
Parameters retVal = new Parameters();
retVal.addParameter().setName("name").setValue(new StringType(getCodeSystemDisplayName()));
if (isNotBlank(getCodeSystemVersion())) {
retVal.addParameter().setName("version").setValue(new StringType(getCodeSystemVersion()));
}
retVal.addParameter().setName("display").setValue(new StringType(getCodeDisplay()));
retVal.addParameter().setName("abstract").setValue(new BooleanType(isCodeIsAbstract()));
return retVal;
}
}
}

View File

@ -225,20 +225,13 @@ public class FhirResourceDaoCodeSystemDstu3 extends FhirResourceDaoDstu3<CodeSys
} else if (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == null) {
ourLog.info("CodeSystem {} has a status of {}, going to store concepts in terminology tables", retVal.getIdDt().getValue(), cs.getContentElement().getValueAsString());
TermCodeSystemVersion persCs = myCsvDao.findByCodeSystemResourceAndVersion(codeSystemResourcePid, retVal.getVersion());
if (persCs != null) {
ourLog.info("Code system version already exists in database");
} else {
persCs = new TermCodeSystemVersion();
TermCodeSystemVersion persCs = new TermCodeSystemVersion();
persCs.setResource(retVal);
persCs.getConcepts().addAll(toPersistedConcepts(cs.getConcept(), persCs));
ourLog.info("Code system has {} concepts", persCs.getConcepts().size());
myTerminologySvc.storeNewCodeSystemVersion(codeSystemResourcePid, codeSystemUrl, persCs);
}
}
}
return retVal;

View File

@ -219,7 +219,7 @@ public class FhirResourceDaoCodeSystemR4 extends FhirResourceDaoR4<CodeSystem> i
ourLog.info("CodeSystem {} has a status of {}, going to store concepts in terminology tables", retVal.getIdDt().getValue(), cs.getContentElement().getValueAsString());
Long codeSystemResourcePid = retVal.getId();
TermCodeSystemVersion persCs = myCsvDao.findByCodeSystemResourceAndVersion(codeSystemResourcePid, retVal.getVersion());
TermCodeSystemVersion persCs = myCsvDao.findCurrentVersionForCodeSystemResourcePid(codeSystemResourcePid);
if (persCs != null) {
ourLog.info("Code system version already exists in database");
} else {

View File

@ -39,7 +39,7 @@ public abstract class BaseJpaSystemProviderDstu2Plus<T, MT> extends BaseJpaSyste
IBaseParameters retVal = ParametersUtil.newInstance(getContext());
IPrimitiveType<?> string = ParametersUtil.createString(getContext(), "Marked " + count + " resources");
ParametersUtil.addParameterToParameters(getContext(), retVal, string, "status");
ParametersUtil.addParameterToParameters(getContext(), retVal, "status", string);
return retVal;
}
@ -58,7 +58,7 @@ public abstract class BaseJpaSystemProviderDstu2Plus<T, MT> extends BaseJpaSyste
} else {
string = ParametersUtil.createString(getContext(), "Indexed " + count + " resources");
}
ParametersUtil.addParameterToParameters(getContext(), retVal, string, "status");
ParametersUtil.addParameterToParameters(getContext(), retVal, "status", string);
return retVal;
}

View File

@ -24,6 +24,8 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import javax.servlet.http.HttpServletRequest;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.hl7.fhir.dstu3.model.*;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoCodeSystem;
@ -32,6 +34,7 @@ import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.exceptions.FHIRException;
public class BaseJpaResourceProviderCodeSystemDstu3 extends JpaResourceProviderDstu3<CodeSystem> {
@ -56,17 +59,11 @@ public class BaseJpaResourceProviderCodeSystemDstu3 extends JpaResourceProviderD
try {
IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> dao = (IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept>) getDao();
LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails);
if (result.isFound()==false) {
throw new ResourceNotFoundException("Unable to find code[" + result.getSearchedForCode() + "] in system[" + result.getSearchedForSystem() + "]");
}
Parameters retVal = new Parameters();
retVal.addParameter().setName("name").setValue(new StringType(result.getCodeSystemDisplayName()));
if (isNotBlank(result.getCodeSystemVersion())) {
retVal.addParameter().setName("version").setValue(new StringType(result.getCodeSystemVersion()));
}
retVal.addParameter().setName("display").setValue(new StringType(result.getCodeDisplay()));
retVal.addParameter().setName("abstract").setValue(new BooleanType(result.isCodeIsAbstract()));
return retVal;
result.throwNotFoundIfAppropriate();
org.hl7.fhir.r4.model.Parameters parametersR4 = result.toParameters();
return VersionConvertor_30_40.convertParameters(parametersR4);
} catch (FHIRException e) {
throw new InternalErrorException(e);
} finally {
endRequest(theServletRequest);
}

View File

@ -56,17 +56,8 @@ public class BaseJpaResourceProviderCodeSystemR4 extends JpaResourceProviderR4<C
try {
IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> dao = (IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept>) getDao();
LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails);
if (result.isFound()==false) {
throw new ResourceNotFoundException("Unable to find code[" + result.getSearchedForCode() + "] in system[" + result.getSearchedForSystem() + "]");
}
Parameters retVal = new Parameters();
retVal.addParameter().setName("name").setValue(new StringType(result.getCodeSystemDisplayName()));
if (isNotBlank(result.getCodeSystemVersion())) {
retVal.addParameter().setName("version").setValue(new StringType(result.getCodeSystemVersion()));
}
retVal.addParameter().setName("display").setValue(new StringType(result.getCodeDisplay()));
retVal.addParameter().setName("abstract").setValue(new BooleanType(result.isCodeIsAbstract()));
return retVal;
result.throwNotFoundIfAppropriate();
return result.toParameters();
} finally {
endRequest(theServletRequest);
}

View File

@ -299,8 +299,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc
}
}
private TermConcept fetchLoadedCode(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
TermCodeSystemVersion codeSystem = myCodeSystemVersionDao.findByCodeSystemResourceAndVersion(theCodeSystemResourcePid, theCodeSystemVersionPid);
private TermConcept fetchLoadedCode(Long theCodeSystemResourcePid, String theCode) {
TermCodeSystemVersion codeSystem = myCodeSystemVersionDao.findCurrentVersionForCodeSystemResourcePid(theCodeSystemResourcePid);
return myConceptDao.findByCodeSystemAndCode(codeSystem, theCode);
}
@ -330,7 +330,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc
public Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
StopWatch stopwatch = new StopWatch();
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode);
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCode);
if (concept == null) {
return Collections.emptySet();
}
@ -361,7 +361,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc
public Set<TermConcept> findCodesBelow(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
Stopwatch stopwatch = Stopwatch.createStarted();
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode);
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCode);
if (concept == null) {
return Collections.emptySet();
}

View File

@ -15,7 +15,7 @@ import static org.apache.commons.lang3.StringUtils.trim;
public class LoincDocumentOntologyHandler extends BaseHandler implements IRecordHandler {
public static final String DOCUMENT_ONTOLOGY_CODES_VS_ID = "DOCUMENT_ONTOLOGY_CODES_VS";
public static final String DOCUMENT_ONTOLOGY_CODES_VS_ID = "DOCUMENT-ONTOLOGY-CODES-VS";
public static final String DOCUMENT_ONTOLOGY_CODES_VS_URI = "http://loinc.org/document-ontology-codes";
public static final String DOCUMENT_ONTOLOGY_CODES_VS_NAME = "LOINC Document Ontology Codes";
private final Map<String, TermConcept> myCode2Concept;

View File

@ -20,7 +20,7 @@ import static org.apache.commons.lang3.StringUtils.trim;
public class LoincPartRelatedCodeMappingHandler implements IRecordHandler {
public static final String LOINC_TO_SNOMED_CM_ID = "LOINC_TO_SNOMED_CM";
public static final String LOINC_TO_SNOMED_CM_ID = "LOINC-TO-SNOMED-CM";
private static final Logger ourLog = LoggerFactory.getLogger(LoincPartRelatedCodeMappingHandler.class);
private final Map<String, TermConcept> myCode2Concept;
private final TermCodeSystemVersion myCodeSystemVersion;

View File

@ -18,14 +18,14 @@ import static org.apache.commons.lang3.StringUtils.trim;
public class LoincRsnaPlaybookHandler implements IRecordHandler {
public static final String RSNA_CODES_VS_ID = "RSNA_LOINC_CODES_VS";
public static final String RSNA_CODES_VS_ID = "RSNA-LOINC-CODES-VS";
public static final String RSNA_CODES_VS_URI = "http://loinc.org/rsna-codes";
public static final String RSNA_CODES_VS_NAME = "RSNA Playbook";
public static final String RID_MAPPING_CM_ID = "LOINC_TO_RID_CODES_CM";
public static final String RID_MAPPING_CM_ID = "LOINC-TO-RID-CODES-CM";
public static final String RID_MAPPING_CM_URI = "http://loinc.org/rid-codes";
public static final String RID_MAPPING_CM_NAME = "RSNA Playbook RID Codes Mapping";
public static final String RID_CS_URI = "http://rid";
public static final String RPID_MAPPING_CM_ID = "LOINC_TO_RPID_CODES_CM";
public static final String RPID_MAPPING_CM_ID = "LOINC-TO-RPID-CODES-CM";
public static final String RPID_MAPPING_CM_URI = "http://loinc.org/rpid-codes";
public static final String RPID_MAPPING_CM_NAME = "RSNA Playbook RPID Codes Mapping";
public static final String RPID_CS_URI = "http://rpid";

View File

@ -8,7 +8,7 @@ import java.util.Map;
public class LoincTop2000LabResultsSiHandler extends BaseLoincTop2000LabResultsHandler {
public static final String TOP_2000_SI_VS_ID = "TOP_2000_SI_VS_ID";
public static final String TOP_2000_SI_VS_ID = "TOP-2000-LABRESULTS-SI";
public static final String TOP_2000_SI_VS_URI = "http://loinc.org/top-2000-lab-results-si";
public static final String TOP_2000_SI_VS_NAME = "Top 2000 Lab Results SI";

View File

@ -8,7 +8,7 @@ import java.util.Map;
public class LoincTop2000LabResultsUsHandler extends BaseLoincTop2000LabResultsHandler {
public static final String TOP_2000_US_VS_ID = "TOP_2000_LABRESULTS_US";
public static final String TOP_2000_US_VS_ID = "TOP-2000-LABRESULTS-US";
public static final String TOP_2000_US_VS_URI = "http://loinc.org/top-2000-lab-results-us";
public static final String TOP_2000_US_VS_NAME = "Top 2000 Lab Results US";

View File

@ -1,34 +1,92 @@
package ca.uhn.fhir.jpa.term;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoCodeSystem;
import ca.uhn.fhir.jpa.dao.dstu3.BaseJpaDstu3Test;
import ca.uhn.fhir.util.TestUtil;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.Parameters;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;
public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test {
private static final Logger ourLog = LoggerFactory.getLogger(TerminologyLoaderSvcIntegrationDstu3Test.class);
@Autowired
private TerminologyLoaderSvcImpl myLoader;
private IHapiTerminologyLoaderSvc myLoader;
@After
public void after() {
myDaoConfig.setDeferIndexingForCodesystemsOfSize(new DaoConfig().getDeferIndexingForCodesystemsOfSize());
}
@Before
public void before() {
myDaoConfig.setDeferIndexingForCodesystemsOfSize(20000);
}
@Test
public void testExpandWithProperty() throws Exception {
ZipCollectionBuilder files = new ZipCollectionBuilder();
TerminologyLoaderSvcLoincTest.createLoincBundle(files);
myLoader.loadLoinc(files.getFiles(), mySrd);
ValueSet input = new ValueSet();
input
.getCompose()
.addInclude()
.setSystem(IHapiTerminologyLoaderSvc.LOINC_URL)
.addFilter()
.setProperty("SCALE_TYP")
.setOp(ValueSet.FilterOperator.EQUAL)
.setValue("Ord");
ValueSet expanded = myValueSetDao.expand(input, null);
Set<String> codes = toExpandedCodes(expanded);
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded));
assertThat(codes, containsInAnyOrder("1001-7", "61438-8"));
}
@Test
public void testLookupWithProperties() throws Exception {
ZipCollectionBuilder files = new ZipCollectionBuilder();
TerminologyLoaderSvcLoincTest.createLoincBundle(files);
myLoader.loadLoinc(files.getFiles(), mySrd);
IFhirResourceDaoCodeSystem.LookupCodeResult result = myCodeSystemDao.lookupCode(new StringType("10013-1"), new StringType(IHapiTerminologyLoaderSvc.LOINC_URL), null, mySrd);
org.hl7.fhir.r4.model.Parameters parametersR4 = result.toParameters();
Parameters parameters = VersionConvertor_30_40.convertParameters(parametersR4);
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters));
}
private Set<String> toExpandedCodes(ValueSet theExpanded) {
return theExpanded
.getExpansion()
.getContains()
.stream()
.map(ValueSet.ValueSetExpansionContainsComponent::getCode)
.collect(Collectors.toSet());
}
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@Test
public void testLoadAndStoreLoinc() throws Exception {
ZipCollectionBuilder files = new ZipCollectionBuilder();
TerminologyLoaderSvcLoincTest.createLoincBundle(files);
myLoader.loadLoinc(files.getFiles(), mySrd);
Thread.sleep(120000);
}
}

View File

@ -70,6 +70,15 @@ public class TerminologyLoaderSvcLoincTest {
mySvc.loadLoinc(myFiles.getFiles(), details);
verify(myTermSvcDstu3, times(1)).storeNewCodeSystemVersion(mySystemCaptor.capture(), myCsvCaptor.capture(), any(RequestDetails.class), myValueSetsCaptor.capture(), myConceptMapCaptor.capture());
ValueSet input = new ValueSet();
input
.getCompose()
.addInclude()
.setSystem(IHapiTerminologyLoaderSvc.LOINC_URL)
.addFilter()
.setProperty("SCALE_TYP")
.setOp(ValueSet.FilterOperator.EQUAL)
.setValue("Ord");
TermCodeSystemVersion ver = myCsvCaptor.getValue();

12
pom.xml
View File

@ -1114,18 +1114,10 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<!--
We compile the unit tests at Java 8. Might as well since they
need Java 8 in order to run (Jetty needs 8) so this way we can
use nice java 8 features in tests at least
-->
<testSource>1.8</testSource>
<testTarget>1.8</testTarget>
<source>1.8</source>
<target>1.8</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<encoding>UTF-8</encoding>
<fork>true</fork>
<meminitial>500m</meminitial>
<maxmem>2000m</maxmem>