From 54100426434b5feb9d99f41965ad8c5fbe6b91e7 Mon Sep 17 00:00:00 2001 From: Frank Tao Date: Mon, 7 Sep 2020 10:43:58 -0400 Subject: [PATCH] Multi-version supported for ConceptMap $translate operation --- .../ca/uhn/fhir/i18n/hapi-messages.properties | 2 + ...aseJpaResourceProviderConceptMapDstu3.java | 15 ++ .../BaseJpaResourceProviderConceptMapR4.java | 14 ++ .../BaseJpaResourceProviderConceptMapR5.java | 14 ++ .../fhir/jpa/term/BaseTermReadSvcImpl.java | 4 +- .../ResourceProviderDstu3ConceptMapTest.java | 103 +++++++++- .../r4/ResourceProviderR4ConceptMapTest.java | 188 +++++++++++++++++- .../r5/ResourceProviderR5ConceptMapTest.java | 109 ++++++++++ 8 files changed, 439 insertions(+), 10 deletions(-) create mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ConceptMapTest.java diff --git a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties index 71aee0c17e2..ea6f163b24e 100644 --- a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties +++ b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties @@ -125,6 +125,8 @@ ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoConceptMapDstu3.matchesFound=Matches fo ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoConceptMapDstu3.noMatchesFound=No matches found! ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoConceptMapR4.matchesFound=Matches found! ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoConceptMapR4.noMatchesFound=No matches found! +ca.uhn.fhir.jpa.dao.r5.FhirResourceDaoConceptMapR5.matchesFound=Matches found! +ca.uhn.fhir.jpa.dao.r5.FhirResourceDaoConceptMapR5.noMatchesFound=No matches found! ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoSearchParameterR4.invalidSearchParamExpression=The expression "{0}" can not be evaluated and may be invalid: {1} ca.uhn.fhir.jpa.dao.predicate.PredicateBuilderToken.textModifierDisabledForSearchParam=The :text modifier is disabled for this search parameter diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java index bcc7cf17e60..d965649fd00 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java @@ -54,6 +54,8 @@ public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderD public Parameters translate( HttpServletRequest theServletRequest, @IdParam(optional = true) IdType theId, + @OperationParam(name = "url", min = 0, max = 1) UriType theUrl, + @OperationParam(name = "conceptMapVersion", min = 0, max = 1) StringType theConceptMapVersion, @OperationParam(name = "code", min = 0, max = 1) CodeType theSourceCode, @OperationParam(name = "system", min = 0, max = 1) UriType theSourceCodeSystem, @OperationParam(name = "version", min = 0, max = 1) StringType theSourceCodeSystemVersion, @@ -65,6 +67,10 @@ public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderD @OperationParam(name = "reverse", min = 0, max = 1) BooleanType theReverse, RequestDetails theRequestDetails ) { + boolean haveUrl = theUrl != null + && theUrl.hasValue(); + boolean haveConceptMapVersion = theConceptMapVersion != null + && theConceptMapVersion.hasValue(); boolean haveSourceCode = theSourceCode != null && theSourceCode.hasValue(); boolean haveSourceCodeSystem = theSourceCodeSystem != null @@ -93,6 +99,15 @@ public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderD TranslationRequest translationRequest = new TranslationRequest(); try { + + if (haveUrl) { + translationRequest.setUrl(VersionConvertor_30_40.convertUri(theUrl)); + } + + if (haveConceptMapVersion) { + translationRequest.setConceptMapVersion(VersionConvertor_30_40.convertString(theConceptMapVersion)); + } + // Convert from DSTU3 to R4 if (haveSourceCode) { translationRequest.getCodeableConcept().addCoding().setCodeElement(VersionConvertor_30_40.convertCode(theSourceCode)); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderConceptMapR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderConceptMapR4.java index eb6f7715e32..3bd1b673007 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderConceptMapR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderConceptMapR4.java @@ -49,6 +49,8 @@ public class BaseJpaResourceProviderConceptMapR4 extends JpaResourceProviderR4