Allow term service to return codes

This commit is contained in:
James Agnew 2019-09-26 12:46:41 -04:00
parent ddb5605830
commit 94f87e7282
2 changed files with 22 additions and 0 deletions

View File

@ -5,6 +5,10 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult; import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult;
import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConcept;
import ca.uhn.fhir.jpa.model.entity.ResourceTable; 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.CoverageIgnore;
import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.UrlUtil;
import org.hl7.fhir.instance.model.api.IBaseDatatype; import org.hl7.fhir.instance.model.api.IBaseDatatype;
@ -170,6 +174,13 @@ public class HapiTerminologySvcR4 extends BaseHapiTerminologySvcImpl implements
@CoverageIgnore @CoverageIgnore
@Override @Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) { 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; return null;
} }

View File

@ -5,6 +5,10 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult; import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult;
import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConcept;
import ca.uhn.fhir.jpa.model.entity.ResourceTable; 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.CoverageIgnore;
import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.UrlUtil;
import ca.uhn.fhir.util.ValidateUtil; import ca.uhn.fhir.util.ValidateUtil;
@ -181,6 +185,13 @@ public class HapiTerminologySvcR5 extends BaseHapiTerminologySvcImpl implements
@CoverageIgnore @CoverageIgnore
@Override @Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) { 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; return null;
} }