From 2edc9910e505218fa52daf1dc17bd2576c6b9517 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 9 Feb 2018 10:29:20 -0500 Subject: [PATCH] Add a test --- .../java/ca/uhn/fhir/parser/JsonParser.java | 11 +++---- .../fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java | 3 ++ ...ceDaoDstu3SearchCustomSearchParamTest.java | 33 +++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java index 975636e0fc8..b8fff2e30d4 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java @@ -618,8 +618,8 @@ public class JsonParser extends BaseParser implements IJsonLikeParser { write(theEventWriter, "resourceType", resDef.getName()); if (theResourceId != null && theResourceId.hasIdPart()) { write(theEventWriter, "id", theResourceId.getIdPart()); - final List extensions = new ArrayList(0); - final List modifierExtensions = new ArrayList(0); + final List extensions = new ArrayList<>(0); + final List modifierExtensions = new ArrayList<>(0); // Undeclared extensions extractUndeclaredExtensions(theResourceId, extensions, modifierExtensions, null, null); boolean haveExtension = false; @@ -707,14 +707,11 @@ public class JsonParser extends BaseParser implements IJsonLikeParser { /** * This is useful only for the two cases where extensions are encoded as direct children (e.g. not in some object * called _name): resource extensions, and extension extensions - * - * @param theChildElem - * @param theParent */ private void extractAndWriteExtensionsAsDirectChild(IBase theElement, JsonLikeWriter theEventWriter, BaseRuntimeElementDefinition theElementDef, RuntimeResourceDefinition theResDef, IBaseResource theResource, CompositeChildElement theChildElem, CompositeChildElement theParent) throws IOException { - List extensions = new ArrayList(0); - List modifierExtensions = new ArrayList(0); + List extensions = new ArrayList<>(0); + List modifierExtensions = new ArrayList<>(0); // Undeclared extensions extractUndeclaredExtensions(theElement, extensions, modifierExtensions, theChildElem, theParent); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java index 93dd9d83c19..949ba8b7b51 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java @@ -132,6 +132,9 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Qualifier("myMedicationRequestDaoDstu3") protected IFhirResourceDao myMedicationRequestDao; @Autowired + @Qualifier("myMedicationStatementDaoDstu3") + protected IFhirResourceDao myMedicationStatementDao; + @Autowired @Qualifier("myNamingSystemDaoDstu3") protected IFhirResourceDao myNamingSystemDao; @Autowired diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java index e90a6f1fc45..47b10e2dc81 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java @@ -8,6 +8,7 @@ import java.util.List; import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus; import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; +import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.*; @@ -156,6 +157,38 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu } + @Test + public void testSearchOnMultivalue() throws FHIRException { + SearchParameter displaySp = new SearchParameter(); + displaySp.addBase("MedicationStatement"); + displaySp.setCode("display"); + displaySp.setType(Enumerations.SearchParamType.STRING); + displaySp.setTitle("Display"); + displaySp.setExpression("MedicationStatement.medication.as(CodeableConcept).coding.display"); + displaySp.setXpathUsage(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL); + displaySp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + mySearchParameterDao.create(displaySp, mySrd); + + mySearchParamRegsitry.forceRefresh(); + + MedicationStatement ms1 = new MedicationStatement(); + ms1.setMedication(new CodeableConcept()); + ms1.getMedicationCodeableConcept().addCoding().setDisplay("AAA"); + String id1 = myMedicationStatementDao.create(ms1).getId().toUnqualifiedVersionless().getValue(); + + MedicationStatement ms2 = new MedicationStatement(); + ms2.setMedication(new CodeableConcept()); + ms2.getMedicationCodeableConcept().addCoding().setDisplay("BBB"); + myMedicationStatementDao.create(ms2).getId().toUnqualifiedVersionless().getValue(); + + SearchParameterMap map = new SearchParameterMap(); + map.setLoadSynchronous(true); + map.add("display", new StringParam("AAA")); + IBundleProvider results = myMedicationStatementDao.search(map); + assertThat(toUnqualifiedVersionlessIdValues(results), contains(id1)); + + } + @Test public void testSearchForExtensionToken() { SearchParameter eyeColourSp = new SearchParameter();