From 94f87e72820aeb1a742d4637293c030d0c67269e Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 26 Sep 2019 12:46:41 -0400 Subject: [PATCH] Allow term service to return codes --- .../ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java | 11 +++++++++++ .../ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java index 06378a6cd10..dd794f8a566 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java @@ -5,6 +5,10 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.model.entity.ResourceTable; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; +import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.param.StringParam; +import ca.uhn.fhir.rest.param.UriParam; import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.UrlUtil; import org.hl7.fhir.instance.model.api.IBaseDatatype; @@ -170,6 +174,13 @@ public class HapiTerminologySvcR4 extends BaseHapiTerminologySvcImpl implements @CoverageIgnore @Override public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) { + SearchParameterMap map = new SearchParameterMap(); + map.add(CodeSystem.SP_URL, new UriParam(theSystem)); + map.setLoadSynchronousUpTo(1); + IBundleProvider outcome = myCodeSystemResourceDao.search(map); + if (outcome.size() > 0) { + return (CodeSystem) outcome.getResources(0, 1).get(0); + } return null; } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java index 457094eee71..74f8d6a85e2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java @@ -5,6 +5,10 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.model.entity.ResourceTable; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; +import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.param.StringParam; +import ca.uhn.fhir.rest.param.UriParam; import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.ValidateUtil; @@ -181,6 +185,13 @@ public class HapiTerminologySvcR5 extends BaseHapiTerminologySvcImpl implements @CoverageIgnore @Override public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) { + SearchParameterMap map = new SearchParameterMap(); + map.add(org.hl7.fhir.r5.model.CodeSystem.SP_URL, new UriParam(theSystem)); + map.setLoadSynchronousUpTo(1); + IBundleProvider outcome = myCodeSystemResourceDao.search(map); + if (outcome.size() > 0) { + return (org.hl7.fhir.r5.model.CodeSystem) outcome.getResources(0, 1).get(0); + } return null; }