diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/LocationReferenceTranslator.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/LocationReferenceTranslator.java new file mode 100644 index 0000000000..17af105418 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/LocationReferenceTranslator.java @@ -0,0 +1,36 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.fhir2.api.translators; + +import javax.annotation.Nonnull; + +import org.hl7.fhir.r4.model.Reference; +import org.openmrs.Location; + +public interface LocationReferenceTranslator extends OpenmrsFhirTranslator { + + /** + * Maps an {@link Location} to a FHIR reference + * + * @param location the location to translate + * @return the corresponding FHIR reference + */ + @Override + Reference toFhirResource(@Nonnull Location location); + + /** + * Maps a FHIR reference to a {@link Location} + * + * @param locationReference the location reference to translate + * @return the corresponding location + */ + @Override + Location toOpenmrsType(@Nonnull Reference locationReference); +} diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ImmunizationTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ImmunizationTranslatorImpl.java index bfc3b5d405..08adc24a7f 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ImmunizationTranslatorImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ImmunizationTranslatorImpl.java @@ -46,6 +46,7 @@ import org.openmrs.module.fhir2.api.translators.ConceptTranslator; import org.openmrs.module.fhir2.api.translators.EncounterReferenceTranslator; import org.openmrs.module.fhir2.api.translators.ImmunizationTranslator; +import org.openmrs.module.fhir2.api.translators.LocationReferenceTranslator; import org.openmrs.module.fhir2.api.translators.ObservationValueTranslator; import org.openmrs.module.fhir2.api.translators.PatientReferenceTranslator; import org.openmrs.module.fhir2.api.translators.PractitionerReferenceTranslator; @@ -99,6 +100,9 @@ public class ImmunizationTranslatorImpl implements ImmunizationTranslator { @Autowired private ConceptTranslator conceptTranslator; + @Autowired + private LocationReferenceTranslator locationReferenceTranslator; + @Autowired private PractitionerReferenceTranslator practitionerReferenceTranslator; @@ -163,6 +167,12 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization } Location location = visit.getLocation(); + if (fhirImmunization.hasLocation()) { + Location recordedLocation = locationReferenceTranslator.toOpenmrsType(fhirImmunization.getLocation()); + if (recordedLocation != null) { + location = recordedLocation; + } + } if (!patient.equals(visit.getPatient())) { throw createImmunizationRequestValidationError( @@ -177,11 +187,12 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization .max(Comparator.comparing(Encounter::getEncounterDatetime)); final Provider encounterProvider = provider; + final Location finalLocation = location; Encounter encounter = existingEncounter.orElseGet(() -> { final EncounterRole encounterRole = helper.getAdministeringEncounterRole(); final Encounter newEncounter = new Encounter(); newEncounter.setVisit(visit); - newEncounter.setLocation(location); + newEncounter.setLocation(finalLocation); newEncounter.setEncounterType(encounterType); newEncounter.setPatient(patient); if (encounterProvider != null) { @@ -202,7 +213,7 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization openmrsImmunization.setEncounter(encounter); openmrsImmunization.getGroupMembers().forEach(obs -> { obs.setPerson(patient); - obs.setLocation(location); + obs.setLocation(finalLocation); obs.setEncounter(encounter); }); @@ -235,6 +246,10 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization } } + if (!fhirImmunization.hasOccurrenceDateTimeType() || !fhirImmunization.getOccurrenceDateTimeType().hasValue()) { + throw createImmunizationRequestValidationError("An Immunization must have a valid occurrenceDateTime value"); + } + { Obs obs = members.get(CIEL_1410); if (obs == null) { @@ -282,6 +297,8 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization } } } + } else { + openmrsImmunization.removeGroupMember(members.get(CIEL_1418)); } if (fhirImmunization.hasManufacturer() && fhirImmunization.getManufacturer().hasDisplay()) { @@ -303,6 +320,8 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization } } } + } else { + openmrsImmunization.removeGroupMember(members.get(CIEL_1419)); } if (fhirImmunization.hasLotNumber()) { @@ -324,6 +343,8 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization } } } + } else { + openmrsImmunization.removeGroupMember(members.get(CIEL_1420)); } if (fhirImmunization.hasExpirationDate()) { @@ -345,6 +366,8 @@ public Obs toOpenmrsType(@Nonnull Obs openmrsImmunization, @Nonnull Immunization } } } + } else { + openmrsImmunization.removeGroupMember(members.get(CIEL_165907)); } return openmrsImmunization; diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationReferenceTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationReferenceTranslatorImpl.java new file mode 100644 index 0000000000..5f00db8470 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationReferenceTranslatorImpl.java @@ -0,0 +1,53 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.fhir2.api.translators.impl; + +import javax.annotation.Nonnull; + +import lombok.AccessLevel; +import lombok.Setter; +import org.hl7.fhir.r4.model.Reference; +import org.openmrs.Location; +import org.openmrs.module.fhir2.FhirConstants; +import org.openmrs.module.fhir2.api.dao.FhirLocationDao; +import org.openmrs.module.fhir2.api.translators.LocationReferenceTranslator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Setter(AccessLevel.PACKAGE) +public class LocationReferenceTranslatorImpl extends BaseReferenceHandlingTranslator implements LocationReferenceTranslator { + + @Autowired + private FhirLocationDao locationDao; + + @Override + public Reference toFhirResource(@Nonnull Location location) { + if (location == null || location.getRetired()) { + return null; + } + + return createLocationReference(location); + } + + @Override + public Location toOpenmrsType(@Nonnull Reference locationReference) { + if (locationReference == null || !locationReference.hasReference()) { + return null; + } + + if (getReferenceType(locationReference).map(ref -> !ref.equals(FhirConstants.LOCATION)).orElse(true)) { + throw new IllegalArgumentException( + "Reference must be to a Location not a " + getReferenceType(locationReference).orElse("")); + } + + return getReferenceId(locationReference).map(uuid -> locationDao.get(uuid)).orElse(null); + } +} diff --git a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupResourceProviderIntegrationTest.java b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupResourceProviderIntegrationTest.java index f1e2d34364..a0e988f9c6 100644 --- a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupResourceProviderIntegrationTest.java +++ b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupResourceProviderIntegrationTest.java @@ -169,7 +169,7 @@ public void shouldCreateNewGroupAsXML() throws Exception { } // create group - MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContext(xmlGroup).go(); + MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContent(xmlGroup).go(); // verify created correctly assertThat(response, isCreated()); @@ -268,7 +268,7 @@ public void shouldUpdateExistingGroupAsXML() throws Exception { } //Update - response = put("/Group/" + COHORT_UUID).xmlContext(xmlGroup).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + COHORT_UUID).xmlContent(xmlGroup).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -302,7 +302,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsXML() throw group.setId(BAD_COHORT_UUID); // send the update to the server - response = put("/Group/" + COHORT_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + COHORT_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -324,7 +324,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentGroupAsXML() throws Excep group.setId(BAD_COHORT_UUID); // send the update to the server - response = put("/Group/" + BAD_COHORT_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + BAD_COHORT_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java index 1277aeee4c..eeaed25095 100644 --- a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java +++ b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java @@ -265,7 +265,7 @@ public void shouldCreateNewObservationAsXML() throws Exception { } // create obs - MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContext(xmlObs).go(); + MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContent(xmlObs).go(); // verify created correctly assertThat(response, isCreated()); diff --git a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupResourceProviderIntegrationTest.java b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupResourceProviderIntegrationTest.java index 8c86865e56..e7f5e9295f 100644 --- a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupResourceProviderIntegrationTest.java +++ b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupResourceProviderIntegrationTest.java @@ -182,7 +182,7 @@ public void shouldCreateNewGroupAsXML() throws Exception { } // create group - MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContext(xmlGroup).go(); + MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContent(xmlGroup).go(); // verify created correctly assertThat(response, isCreated()); @@ -293,7 +293,7 @@ public void shouldUpdateExistingGroupAsXML() throws Exception { } //Update - response = put("/Group/" + GROUP_UUID).xmlContext(xmlGroup).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + GROUP_UUID).xmlContent(xmlGroup).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -331,7 +331,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsXML() throw group.setId(BAD_GROUP_UUID); // send the update to the server - response = put("/Group/" + GROUP_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + GROUP_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -353,7 +353,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentGroupAsXML() throws Excep group.setId(BAD_GROUP_UUID); // send the update to the server - response = put("/Group/" + BAD_GROUP_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + BAD_GROUP_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java index 917a21fdae..edb56ef8de 100644 --- a/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java +++ b/integration-tests-2.1/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java @@ -264,7 +264,7 @@ public void shouldCreateNewObservationAsXML() throws Exception { } // create obs - MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContext(xmlObs).go(); + MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContent(xmlObs).go(); // verify created correctly assertThat(response, isCreated()); diff --git a/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r3/ConditionResourceProviderIntegrationTest.java b/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r3/ConditionResourceProviderIntegrationTest.java index 86ce645a73..12d55929cc 100644 --- a/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r3/ConditionResourceProviderIntegrationTest.java +++ b/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r3/ConditionResourceProviderIntegrationTest.java @@ -210,7 +210,7 @@ public void shouldCreateNewConditionAsXML() throws Exception { assertThat(xmlCondition, notNullValue()); } - MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContext(xmlCondition).go(); + MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContent(xmlCondition).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/Condition/")); @@ -338,7 +338,7 @@ public void shouldUpdateExistingConditionAsXML() throws Exception { condition.setVerificationStatus(Condition.ConditionVerificationStatus.PROVISIONAL); - response = put("/Condition/" + CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -373,7 +373,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchConditionIdAsXML() t condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -397,7 +397,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentConditionAsXML() throws E condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r4/ConditionResourceProviderIntegrationTest.java b/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r4/ConditionResourceProviderIntegrationTest.java index 128fb9ea72..2a84f9438c 100644 --- a/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r4/ConditionResourceProviderIntegrationTest.java +++ b/integration-tests-2.2/src/test/java/org/openmrs/module/fhir2/provider/r4/ConditionResourceProviderIntegrationTest.java @@ -209,7 +209,7 @@ public void shouldCreateNewConditionAsXML() throws Exception { assertThat(xmlCondition, notNullValue()); } - MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContext(xmlCondition).go(); + MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContent(xmlCondition).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/Condition/")); @@ -336,7 +336,7 @@ public void shouldUpdateExistingConditionAsXML() throws Exception { condition.getVerificationStatus().getCodingFirstRep().setCode("provisional"); - response = put("/Condition/" + CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -371,7 +371,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchConditionIdAsXML() t condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -395,7 +395,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentConditionAsXML() throws E condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/BaseFhirIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/BaseFhirIntegrationTest.java index ee2f541993..35444cdaaf 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/BaseFhirIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/BaseFhirIntegrationTest.java @@ -366,7 +366,7 @@ public FhirRequestBuilder jsonContent(@Nonnull String json) { return this; } - public FhirRequestBuilder xmlContext(@Nonnull String xml) { + public FhirRequestBuilder xmlContent(@Nonnull String xml) { request.addHeader(CONTENT_TYPE, FhirMediaTypes.XML.toString()); request.setContent(xml.getBytes(StandardCharsets.UTF_8)); return this; diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProviderIntegrationTest.java index 5ba5976e86..66748efabc 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProviderIntegrationTest.java @@ -174,7 +174,7 @@ public void shouldCreateNewAllergyAsXML() throws Exception { } // create allergy - MockHttpServletResponse response = post("/AllergyIntolerance").accept(FhirMediaTypes.XML).xmlContext(jsonAllergy) + MockHttpServletResponse response = post("/AllergyIntolerance").accept(FhirMediaTypes.XML).xmlContent(jsonAllergy) .go(); // verify created correctly @@ -300,7 +300,7 @@ public void shouldUpdateExistingAllergyAsXML() throws Exception { allergy.getCategory().set(0, category); // send the update to the server - response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContext(toXML(allergy)).accept(FhirMediaTypes.XML).go(); + response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -331,7 +331,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchAllergyIdAsXML() thr allergy.setId(UNKNOWN_ALLERGY_UUID); // send the update to the server - response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContext(toXML(allergy)).accept(FhirMediaTypes.XML).go(); + response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -353,7 +353,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentAllergyAsXML() throws Exc allergy.setId(UNKNOWN_ALLERGY_UUID); // send the update to the server - response = put("/AllergyIntolerance/" + UNKNOWN_ALLERGY_UUID).xmlContext(toXML(allergy)).accept(FhirMediaTypes.XML) + response = put("/AllergyIntolerance/" + UNKNOWN_ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML) .go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/BaseFhirR3IntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/BaseFhirR3IntegrationTest.java index 4538944a49..1de31ae2a3 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/BaseFhirR3IntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/BaseFhirR3IntegrationTest.java @@ -215,23 +215,23 @@ public void describeTo(Description description) { .appendValue(max).appendText(" distinct observation times"); } } - + protected static Matcher> hasCorrectResources(Integer resourceCount, - Set validResources) { + Set validResources) { return new HasCorrectResources(resourceCount, validResources); } - + private static class HasCorrectResources extends TypeSafeDiagnosingMatcher> { - + private int resourcesCount; - + private Set validResources; - + HasCorrectResources(int resourcesCount, Set validResources) { this.resourcesCount = resourcesCount; this.validResources = validResources; } - + @Override protected boolean matchesSafely(List entries, Description mismatchDescription) { int count = 0; @@ -243,24 +243,24 @@ protected boolean matchesSafely(List entries, Descr return false; } } - + if (entries.size() < resourcesCount) { if (count != entries.size()) { mismatchDescription.appendText("Expected ").appendValue(entries.size()) - .appendText(" resources, but result has ").appendValue(count).appendText(" resources."); + .appendText(" resources, but result has ").appendValue(count).appendText(" resources."); return false; } return true; } - + if (count != resourcesCount) { mismatchDescription.appendText("Expected ").appendValue(resourcesCount) - .appendText(" resources, but result has ").appendValue(count).appendText(" resources."); + .appendText(" resources, but result has ").appendValue(count).appendText(" resources."); return false; } return true; } - + @Override public void describeTo(Description description) { description.appendText("Result all valid resources."); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProviderIntegrationTest.java index f0f3948361..1ff7160455 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProviderIntegrationTest.java @@ -186,7 +186,7 @@ public void shouldCreateNewConditionAsXML() throws Exception { assertThat(xmlCondition, notNullValue()); } - MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContext(xmlCondition).go(); + MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContent(xmlCondition).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/Condition/")); @@ -273,7 +273,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchConditionIdAsXML() t condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -297,7 +297,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentConditionAsXML() throws E condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportResourceProviderIntegrationTest.java index 1eec0aee1c..1bfb962e75 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportResourceProviderIntegrationTest.java @@ -235,7 +235,7 @@ public void shouldCreateNewDiagnosticReportAsXML() throws Exception { xmlReport = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/DiagnosticReport").accept(FhirMediaTypes.XML).xmlContext(xmlReport).go(); + MockHttpServletResponse response = post("/DiagnosticReport").accept(FhirMediaTypes.XML).xmlContent(xmlReport).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/DiagnosticReport/")); @@ -367,7 +367,7 @@ public void shouldUpdateExistingDiagnosticReportAsXML() throws Exception { diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.FINAL); // send the update to the server - response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContext(toXML(diagnosticReport)) + response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); @@ -400,7 +400,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPatientIdAsXML() thr diagnosticReport.setId(WRONG_DIAGNOSTIC_REPORT_UUID); // send the update to the server - response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContext(toXML(diagnosticReport)) + response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); @@ -424,7 +424,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentPatientAsXML() throws Exc diagnosticReport.setId(WRONG_DIAGNOSTIC_REPORT_UUID); // send the update to the server - response = put("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).xmlContext(toXML(diagnosticReport)) + response = put("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderIntegrationTest.java index 4ec646ef10..e980f7e60d 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderIntegrationTest.java @@ -438,7 +438,7 @@ public void shouldCreateEncounterFromOpenMrsEncounterAsXML() throws Exception { xmlEncounter = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContext(xmlEncounter).go(); + MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContent(xmlEncounter).go(); assertThat(response, isCreated()); assertThat(response.getContentType(), is((FhirMediaTypes.XML.toString()))); @@ -504,7 +504,7 @@ public void shouldCreateEncounterFromOpenMrsVisitAsXML() throws Exception { xmlEncounter = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContext(xmlEncounter).go(); + MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContent(xmlEncounter).go(); assertThat(response, isCreated()); assertThat(response.getContentType(), is((FhirMediaTypes.XML.toString()))); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderIntegrationTest.java index f777fd39a9..eba2b3869b 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderIntegrationTest.java @@ -158,7 +158,7 @@ public void shouldCreateNewGroupAsXML() throws Exception { } // create group - MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContext(xmlGroup).go(); + MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContent(xmlGroup).go(); // verify created correctly assertThat(response, isCreated()); @@ -251,7 +251,7 @@ public void shouldUpdateExistingGroupAsXML() throws Exception { } //Update - response = put("/Group/" + COHORT_UUID).xmlContext(xmlGroup).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + COHORT_UUID).xmlContent(xmlGroup).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -285,7 +285,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsXML() throw group.setId(BAD_COHORT_UUID); // send the update to the server - response = put("/Group/" + COHORT_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + COHORT_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -307,7 +307,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentGroupAsXML() throws Excep group.setId(BAD_COHORT_UUID); // send the update to the server - response = put("/Group/" + BAD_COHORT_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + BAD_COHORT_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderIntegrationTest.java index bd2f803800..083d3e85d6 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderIntegrationTest.java @@ -166,7 +166,7 @@ public void shouldCreateNewLocationAsXML() throws Exception { } // create location - MockHttpServletResponse response = post("/Location").accept(FhirMediaTypes.XML).xmlContext(xmlLocation).go(); + MockHttpServletResponse response = post("/Location").accept(FhirMediaTypes.XML).xmlContent(xmlLocation).go(); // verify created correctly assertThat(response, isCreated()); @@ -278,7 +278,7 @@ public void shouldUpdateExistingLocationAsXML() throws Exception { location.getAddress().setCountry("France"); // send the update to the server - response = put("/Location/" + LOCATION_UUID).xmlContext(toXML(location)).accept(FhirMediaTypes.XML).go(); + response = put("/Location/" + LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -309,7 +309,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchLocationIdAsXML() th location.setId(UNKNOWN_LOCATION_UUID); // send the update to the server - response = put("/Location/" + LOCATION_UUID).xmlContext(toXML(location)).accept(FhirMediaTypes.XML).go(); + response = put("/Location/" + LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -331,7 +331,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentLocationAsXML() throws Ex location.setId(UNKNOWN_LOCATION_UUID); // send the update to the server - response = put("/Location/" + UNKNOWN_LOCATION_UUID).xmlContext(toXML(location)).accept(FhirMediaTypes.XML).go(); + response = put("/Location/" + UNKNOWN_LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderIntegrationTest.java index f1122219b2..6bf6d62c41 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderIntegrationTest.java @@ -160,7 +160,7 @@ public void shouldCreateNewMedicationAsXml() throws Exception { } // create medication - MockHttpServletResponse response = post("/Medication").accept(FhirMediaTypes.XML).xmlContext(xmlMedication).go(); + MockHttpServletResponse response = post("/Medication").accept(FhirMediaTypes.XML).xmlContent(xmlMedication).go(); // verify created correctly assertThat(response, isCreated()); @@ -303,7 +303,7 @@ public void shouldUpdateExistingMedicationAsXml() throws Exception { } //Update - response = put("/Medication/" + MEDICATION_UUID).xmlContext(xmlMedication).accept(FhirMediaTypes.XML).go(); + response = put("/Medication/" + MEDICATION_UUID).xmlContent(xmlMedication).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -339,7 +339,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchMedicationIdAsXML() medication.setId(WRONG_MEDICATION_UUID); // send the update to the server - response = put("/Medication/" + MEDICATION_UUID).xmlContext(toXML(medication)).accept(FhirMediaTypes.XML).go(); + response = put("/Medication/" + MEDICATION_UUID).xmlContent(toXML(medication)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -361,7 +361,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentMedicationAsXML() throws medication.setId(WRONG_MEDICATION_UUID); // send the update to the server - response = put("/Medication/" + WRONG_MEDICATION_UUID).xmlContext(toXML(medication)).accept(FhirMediaTypes.XML).go(); + response = put("/Medication/" + WRONG_MEDICATION_UUID).xmlContent(toXML(medication)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java index 4b8af758c0..8146d96784 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderIntegrationTest.java @@ -271,7 +271,7 @@ public void shouldCreateNewObservationAsXML() throws Exception { } // create obs - MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContext(xmlObs).go(); + MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContent(xmlObs).go(); // verify created correctly assertThat(response, isCreated()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java index 0c3070f6aa..3f8b7df5db 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java @@ -60,35 +60,35 @@ public class PatientFhirResourceProviderIntegrationTest extends BaseFhirR3Integr private static final String PATIENT_UUID = "30e2aa2a-4ed1-415d-84c5-ba29016c14b7"; private static final String WRONG_PATIENT_UUID = "f090747b-459b-4a13-8c1b-c0567d8aeb63"; - + private static final String PATIENT_UUID_2 = "ca17fcc5-ec96-487f-b9ea-42973c8973e3"; - + private static final String OBSERVATION_UUID_1 = "99b92980-db62-40cd-8bca-733357c48126"; - + private static final String OBSERVATION_UUID_2 = "f6ec1267-8eac-415f-a3f0-e47be2c8bb67"; - + private static final String OBSERVATION_UUID_3 = "be48cdcb-6a76-47e3-9f2e-2635032f3a9a"; - + private static final String OBSERVATION_UUID_4 = "1ce473c8-3fac-440d-9f92-e10facab194f"; - + private static final String OBSERVATION_UUID_5 = "b6521c32-47b6-47da-9c6f-3673ddfb74f9"; - + private static final String OBSERVATION_UUID_6 = "2ed1e57d-9f18-41d3-b067-2eeaf4b30fb0"; - + private static final String OBSERVATION_UUID_7 = "2f616900-5e7c-4667-9a7f-dcb260abf1de"; - + private static final String OBSERVATION_UUID_8 = "39fb7f47-e80a-4056-9285-bd798be13c63"; - + private static final String OBSERVATION_UUID_9 = "e26cea2c-1b9f-4afe-b211-f3ef6c88af6f"; - + private static final String ENCOUNTER_UUID_1 = "e403fafb-e5e4-42d0-9d11-4f52e89d148c"; - + private static final String ENCOUNTER_UUID_2 = "6519d653-393b-4118-9c83-a3715b82d4ac"; - + private static final String ENCOUNTER_UUID_3 = "eec646cb-c847-45a7-98bc-91c8c4f70add"; - + private static final String MEDICATION_REQUEST_UUID_1 = "e1f95924-697a-11e3-bd76-0800271c1b75"; - + private static final String MEDICATION_REQUEST_UUID_2 = "921de0a3-05c4-444a-be03-e01b4c4b9142"; @Getter(AccessLevel.PUBLIC) @@ -217,7 +217,7 @@ public void shouldCreateNewPatientAsXML() throws Exception { } // create patient - MockHttpServletResponse response = post("/Patient").accept(FhirMediaTypes.XML).xmlContext(xmlPatient).go(); + MockHttpServletResponse response = post("/Patient").accept(FhirMediaTypes.XML).xmlContent(xmlPatient).go(); // verify created correctly assertThat(response, isCreated()); @@ -338,7 +338,7 @@ public void shouldUpdateExistingPatientAsXML() throws Exception { patient.setBirthDate(birthDate); // send the update to the server - response = put("/Patient/" + PATIENT_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Patient/" + PATIENT_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -369,7 +369,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPatientIdAsXML() thr patient.setId(WRONG_PATIENT_UUID); // send the update to the server - response = put("/Patient/" + PATIENT_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Patient/" + PATIENT_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -391,7 +391,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentPatientAsXML() throws Exc patient.setId(WRONG_PATIENT_UUID); // send the update to the server - response = put("/Patient/" + WRONG_PATIENT_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Patient/" + WRONG_PATIENT_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -565,11 +565,11 @@ public void shouldReturnPatientEverythingAsJson() throws Exception { assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET)); assertThat(result, hasProperty("total", equalTo(15))); assertThat(result.getEntry(), hasSize(15)); - + List entries = result.getEntry(); - + assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/")))); - + assertThat(entries, hasCorrectResources(15, getValidResources())); } @@ -588,11 +588,11 @@ public void shouldReturnForPatientEverythingWhenCountIsSpecifiedAsJson() throws assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET)); assertThat(result, hasProperty("total", equalTo(15))); assertThat(result.getEntry(), hasSize(5)); - + List entries = result.getEntry(); - + assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/")))); - + assertThat(entries, hasCorrectResources(5, getValidResources())); } @@ -611,11 +611,11 @@ public void shouldReturnPatientEverythingAsXml() throws Exception { assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET)); assertThat(result, hasProperty("total", equalTo(15))); assertThat(result.getEntry(), hasSize(15)); - + List entries = result.getEntry(); - + assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/")))); - + assertThat(entries, hasCorrectResources(15, getValidResources())); } @@ -634,14 +634,14 @@ public void shouldReturnForPatientEverythingWhenCountIsSpecifiedAsXml() throws E assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET)); assertThat(result, hasProperty("total", equalTo(15))); assertThat(result.getEntry(), hasSize(5)); - + List entries = result.getEntry(); - + assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/")))); - + assertThat(entries, hasCorrectResources(5, getValidResources())); } - + private Set getValidResources() { Set validResources = new HashSet<>(); validResources.add(PATIENT_UUID_2); @@ -659,7 +659,7 @@ private Set getValidResources() { validResources.add(ENCOUNTER_UUID_3); validResources.add(MEDICATION_REQUEST_UUID_1); validResources.add(MEDICATION_REQUEST_UUID_2); - + return validResources; } } diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderIntegrationTest.java index f8e3e2a703..520a78741b 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderIntegrationTest.java @@ -169,7 +169,7 @@ public void shouldCreateNewPersonAsXML() throws Exception { } // create person - MockHttpServletResponse response = post("/Person").accept(FhirMediaTypes.XML).xmlContext(xmlPerson).go(); + MockHttpServletResponse response = post("/Person").accept(FhirMediaTypes.XML).xmlContent(xmlPerson).go(); // verify created correctly assertThat(response, isCreated()); @@ -290,7 +290,7 @@ public void shouldUpdateExistingPersonAsXML() throws Exception { person.setBirthDate(birthDate); // send the update to the server - response = put("/Person/" + PERSON_UUID).xmlContext(toXML(person)).accept(FhirMediaTypes.XML).go(); + response = put("/Person/" + PERSON_UUID).xmlContent(toXML(person)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -321,7 +321,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPersonIdAsXML() thro person.setId(WRONG_PERSON_UUID); // send the update to the server - response = put("/Person/" + PERSON_UUID).xmlContext(toXML(person)).accept(FhirMediaTypes.XML).go(); + response = put("/Person/" + PERSON_UUID).xmlContent(toXML(person)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderIntegrationTest.java index 012c0c61a9..9e06ca9edf 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderIntegrationTest.java @@ -179,7 +179,7 @@ public void shouldCreateNewPractitionerAsXML() throws Exception { } // create practitioner - MockHttpServletResponse response = post("/Practitioner").accept(FhirMediaTypes.XML).xmlContext(xmlPractitioner).go(); + MockHttpServletResponse response = post("/Practitioner").accept(FhirMediaTypes.XML).xmlContent(xmlPractitioner).go(); // verify created correctly assertThat(response, isCreated()); @@ -303,7 +303,7 @@ public void shouldUpdateExistingPractitionerAsXML() throws Exception { practitioner.setBirthDate(birthDate); // send the update to the server - response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContext(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); + response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -334,7 +334,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPractitionerIdAsXML( practitioner.setId(WRONG_PRACTITIONER_UUID); // send the update to the server - response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContext(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); + response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -356,7 +356,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentPractitionerAsXML() throw practitioner.setId(WRONG_PRACTITIONER_UUID); // send the update to the server - response = put("/Practitioner/" + WRONG_PRACTITIONER_UUID).xmlContext(toXML(practitioner)).accept(FhirMediaTypes.XML) + response = put("/Practitioner/" + WRONG_PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML) .go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/TaskFhirResourceIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/TaskFhirResourceIntegrationTest.java index 1f523b6206..bd69139cc2 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/TaskFhirResourceIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/TaskFhirResourceIntegrationTest.java @@ -177,7 +177,7 @@ public void shouldCreateNewTaskAsXML() throws Exception { xmlTask = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/Task").accept(FhirMediaTypes.XML).xmlContext(xmlTask).go(); + MockHttpServletResponse response = post("/Task").accept(FhirMediaTypes.XML).xmlContent(xmlTask).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/Task/")); @@ -298,7 +298,7 @@ public void shouldUpdateExistingTaskAsXML() throws Exception { task.setStatus(Task.TaskStatus.COMPLETED); - response = put("/Task/" + TASK_UUID).xmlContext(toXML(task)).accept(FhirMediaTypes.XML).go(); + response = put("/Task/" + TASK_UUID).xmlContent(toXML(task)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -330,7 +330,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchTaskIdAsXML() throws task.setId(WRONG_TASK_UUID); - response = put("/Task/" + TASK_UUID).xmlContext(toXML(task)).accept(FhirMediaTypes.XML).go(); + response = put("/Task/" + TASK_UUID).xmlContent(toXML(task)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -352,7 +352,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentTaskAsXML() throws Except patient.setId(WRONG_TASK_UUID); - response = put("/Task/" + WRONG_TASK_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Task/" + WRONG_TASK_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/AllergyIntoleranceFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/AllergyIntoleranceFhirResourceProviderIntegrationTest.java index 955d75516b..57d1170584 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/AllergyIntoleranceFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/AllergyIntoleranceFhirResourceProviderIntegrationTest.java @@ -180,7 +180,7 @@ public void shouldCreateNewAllergyAsXML() throws Exception { } // create allergy - MockHttpServletResponse response = post("/AllergyIntolerance").accept(FhirMediaTypes.XML).xmlContext(jsonAllergy) + MockHttpServletResponse response = post("/AllergyIntolerance").accept(FhirMediaTypes.XML).xmlContent(jsonAllergy) .go(); // verify created correctly @@ -312,7 +312,7 @@ public void shouldUpdateExistingAllergyAsXML() throws Exception { allergy.getCategory().set(0, category); // send the update to the server - response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContext(toXML(allergy)).accept(FhirMediaTypes.XML).go(); + response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -343,7 +343,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchAllergyIdAsXML() thr allergy.setId(UNKNOWN_ALLERGY_UUID); // send the update to the server - response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContext(toXML(allergy)).accept(FhirMediaTypes.XML).go(); + response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -365,7 +365,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentAllergyAsXML() throws Exc allergy.setId(UNKNOWN_ALLERGY_UUID); // send the update to the server - response = put("/AllergyIntolerance/" + UNKNOWN_ALLERGY_UUID).xmlContext(toXML(allergy)).accept(FhirMediaTypes.XML) + response = put("/AllergyIntolerance/" + UNKNOWN_ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML) .go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ConditionFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ConditionFhirResourceProviderIntegrationTest.java index 7e5442846b..ffb1f97d84 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ConditionFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ConditionFhirResourceProviderIntegrationTest.java @@ -182,7 +182,7 @@ public void shouldCreateNewConditionAsXML() throws Exception { assertThat(xmlCondition, notNullValue()); } - MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContext(xmlCondition).go(); + MockHttpServletResponse response = post("/Condition").accept(FhirMediaTypes.XML).xmlContent(xmlCondition).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/Condition/")); @@ -268,7 +268,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchConditionIdAsXML() t condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -292,7 +292,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentConditionAsXML() throws E condition.setId(WRONG_CONDITION_UUID); - response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContext(toXML(condition)).accept(FhirMediaTypes.XML).go(); + response = put("/Condition/" + WRONG_CONDITION_UUID).xmlContent(toXML(condition)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/DiagnosticReportResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/DiagnosticReportResourceProviderIntegrationTest.java index 04a38581ae..bcc2442da6 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/DiagnosticReportResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/DiagnosticReportResourceProviderIntegrationTest.java @@ -238,7 +238,7 @@ public void shouldCreateNewDiagnosticReportAsXML() throws Exception { xmlReport = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/DiagnosticReport").accept(FhirMediaTypes.XML).xmlContext(xmlReport).go(); + MockHttpServletResponse response = post("/DiagnosticReport").accept(FhirMediaTypes.XML).xmlContent(xmlReport).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/DiagnosticReport/")); @@ -371,7 +371,7 @@ public void shouldUpdateExistingDiagnosticReportAsXML() throws Exception { diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.FINAL); // send the update to the server - response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContext(toXML(diagnosticReport)) + response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); @@ -404,7 +404,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPatientIdAsXML() thr diagnosticReport.setId(WRONG_DIAGNOSTIC_REPORT_UUID); // send the update to the server - response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContext(toXML(diagnosticReport)) + response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); @@ -428,7 +428,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentPatientAsXML() throws Exc diagnosticReport.setId(WRONG_DIAGNOSTIC_REPORT_UUID); // send the update to the server - response = put("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).xmlContext(toXML(diagnosticReport)) + response = put("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/EncounterFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/EncounterFhirResourceProviderIntegrationTest.java index 3e33b7a131..1cdcd45bce 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/EncounterFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/EncounterFhirResourceProviderIntegrationTest.java @@ -440,7 +440,7 @@ public void shouldCreateEncounterFromOpenMrsEncounterAsXML() throws Exception { xmlEncounter = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContext(xmlEncounter).go(); + MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContent(xmlEncounter).go(); assertThat(response, isCreated()); assertThat(response.getContentType(), is((FhirMediaTypes.XML.toString()))); @@ -509,7 +509,7 @@ public void shouldCreateEncounterFromOpenMrsVisitAsXML() throws Exception { xmlEncounter = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContext(xmlEncounter).go(); + MockHttpServletResponse response = post("/Encounter").accept(FhirMediaTypes.XML).xmlContent(xmlEncounter).go(); assertThat(response, isCreated()); assertThat(response.getContentType(), is((FhirMediaTypes.XML.toString()))); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupFhirResourceProviderIntegrationTest.java index f7cded70e2..1f27a9b537 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/GroupFhirResourceProviderIntegrationTest.java @@ -162,7 +162,7 @@ public void shouldCreateNewGroupAsXML() throws Exception { } // create group - MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContext(xmlGroup).go(); + MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.XML).xmlContent(xmlGroup).go(); // verify created correctly assertThat(response, isCreated()); @@ -263,7 +263,7 @@ public void shouldUpdateExistingGroupAsXML() throws Exception { } //Update - response = put("/Group/" + COHORT_UUID).xmlContext(xmlGroup).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + COHORT_UUID).xmlContent(xmlGroup).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -301,7 +301,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsXML() throw group.setId(BAD_COHORT_UUID); // send the update to the server - response = put("/Group/" + COHORT_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + COHORT_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -323,7 +323,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentGroupAsXML() throws Excep group.setId(BAD_COHORT_UUID); // send the update to the server - response = put("/Group/" + BAD_COHORT_UUID).xmlContext(toXML(group)).accept(FhirMediaTypes.XML).go(); + response = put("/Group/" + BAD_COHORT_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ImmunizationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ImmunizationFhirResourceProviderIntegrationTest.java index c1c37afa99..63813c3df6 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ImmunizationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ImmunizationFhirResourceProviderIntegrationTest.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.time.LocalDate; import java.time.ZonedDateTime; import java.util.Calendar; import java.util.Date; @@ -49,8 +50,12 @@ public class ImmunizationFhirResourceProviderIntegrationTest extends BaseFhirR4I private static final String JSON_CREATE_IMMUNIZATION_DOCUMENT = "org/openmrs/module/fhir2/providers/ImmunizationWebTest_create.json"; + private static final String JSON_CREATE_PARTIAL_IMMUNIZATION_DOCUMENT = "org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.json"; + private static final String XML_CREATE_IMMUNIZATION_DOCUMENT = "org/openmrs/module/fhir2/providers/ImmunizationWebTest_create.xml"; + private static final String XML_CREATE_PARTIAL_IMMUNIZATION_DOCUMENT = "org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.xml"; + private static final String IMMUNIZATION_UUID = "28668ca0-d7d7-4314-8a67-70f083bcf8ba"; private static final String UNKNOWN_IMMUNIZATION_UUID = "46fc09a6-3368-4579-849f-98875a7c2d5a"; @@ -177,6 +182,54 @@ public void shouldCreateNewImmunizationAsJson() throws Exception { assertThat(newImmunization.getId(), equalTo(immunization.getId())); } + @Test + public void shouldCreateNewImmunizationWithoutSomeOptionalMembersAsJSON() throws Exception { + // read JSON record + String jsonImmunization; + try (InputStream is = this.getClass().getClassLoader() + .getResourceAsStream(JSON_CREATE_PARTIAL_IMMUNIZATION_DOCUMENT)) { + Objects.requireNonNull(is); + jsonImmunization = IOUtils.toString(is, StandardCharsets.UTF_8); + } + + // create IMMUNIZATION + MockHttpServletResponse response = post("/Immunization").accept(FhirMediaTypes.JSON).jsonContent(jsonImmunization) + .go(); + + // verify created correctly + assertThat(response, isCreated()); + assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString())); + assertThat(response.getContentAsString(), notNullValue()); + + Immunization immunization = readResponse(response); + + assertThat(immunization, notNullValue()); + assertThat(immunization.getResourceType().toString(), equalTo("Immunization")); + assertThat(immunization.getStatus().toCode(), equalTo("completed")); + assertThat(immunization.getVaccineCode().getCodingFirstRep().getCode(), + equalTo("15f83cd6-64e9-4e06-a5f9-364d3b14a43d")); + assertThat(immunization.getPatient().getReferenceElement().getIdPart(), + equalTo("8d703ff2-c3e2-4070-9737-73e713d5a50d")); + assertThat(immunization.getOccurrenceDateTimeType().getValueAsCalendar().getTime(), + sameInstant(Date.from(ZonedDateTime.parse("2020-07-08T18:30:00.000Z").toInstant()))); + assertThat(immunization.hasManufacturer(), is(true)); + assertThat(immunization.getManufacturer().getDisplay(), equalTo("Pfizer")); + assertThat(immunization.getLotNumber(), equalTo("22")); + assertThat(immunization.getExpirationDate(), sameDay(LocalDate.parse("2021-07-28"))); + assertThat(immunization.getPerformer().get(0).getActor().getReferenceElement().getIdPart(), + equalTo("6f763a67-2bd1-451c-93b9-95caeb36cc24")); + assertThat(immunization, validResource()); + + // try to get new immunization + response = get("/Immunization/" + immunization.getIdElement().getIdPart()).accept(FhirMediaTypes.JSON).go(); + + assertThat(response, isOk()); + + Immunization newImmunization = readResponse(response); + + assertThat(newImmunization.getId(), equalTo(immunization.getId())); + } + @Test public void shouldCreateNewImmunizationAsXML() throws Exception { // read XML record @@ -187,7 +240,7 @@ public void shouldCreateNewImmunizationAsXML() throws Exception { } // create IMMUNIZATION - MockHttpServletResponse response = post("/Immunization").accept(FhirMediaTypes.XML).xmlContext(xmlImmunization).go(); + MockHttpServletResponse response = post("/Immunization").accept(FhirMediaTypes.XML).xmlContent(xmlImmunization).go(); // verify created correctly assertThat(response, isCreated()); @@ -224,6 +277,53 @@ public void shouldCreateNewImmunizationAsXML() throws Exception { assertThat(newImmunization.getId(), equalTo(immunization.getId())); } + @Test + public void shouldCreateNewImmunizationWithoutSomeOptionalMembersAsXML() throws Exception { + // read XML record + String xmlImmunization; + try (InputStream is = this.getClass().getClassLoader() + .getResourceAsStream(XML_CREATE_PARTIAL_IMMUNIZATION_DOCUMENT)) { + Objects.requireNonNull(is); + xmlImmunization = IOUtils.toString(is, StandardCharsets.UTF_8); + } + + // create IMMUNIZATION + MockHttpServletResponse response = post("/Immunization").accept(FhirMediaTypes.XML).xmlContent(xmlImmunization).go(); + + // verify created correctly + assertThat(response, isCreated()); + assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); + assertThat(response.getContentAsString(), notNullValue()); + + Immunization immunization = readResponse(response); + + assertThat(immunization, notNullValue()); + assertThat(immunization.getResourceType().toString(), equalTo("Immunization")); + assertThat(immunization.getStatus().toCode(), equalTo("completed")); + assertThat(immunization.getVaccineCode().getCodingFirstRep().getCode(), + equalTo("15f83cd6-64e9-4e06-a5f9-364d3b14a43d")); + assertThat(immunization.getPatient().getReferenceElement().getIdPart(), + equalTo("8d703ff2-c3e2-4070-9737-73e713d5a50d")); + assertThat(immunization.getOccurrenceDateTimeType().getValueAsCalendar().getTime(), + sameInstant(Date.from(ZonedDateTime.parse("2020-07-08T18:30:00.000Z").toInstant()))); + assertThat(immunization.hasManufacturer(), is(true)); + assertThat(immunization.getManufacturer().getDisplay(), equalTo("Pfizer")); + assertThat(immunization.getLotNumber(), equalTo("22")); + assertThat(immunization.getExpirationDate(), sameDay(LocalDate.parse("2021-07-28"))); + assertThat(immunization.getPerformer().get(0).getActor().getReferenceElement().getIdPart(), + equalTo("6f763a67-2bd1-451c-93b9-95caeb36cc24")); + assertThat(immunization, validResource()); + + // try to get new immunization + response = get("/Immunization/" + immunization.getIdElement().getIdPart()).accept(FhirMediaTypes.XML).go(); + + assertThat(response, isOk()); + + Immunization newImmunization = readResponse(response); + + assertThat(newImmunization.getId(), equalTo(immunization.getId())); + } + @Test public void shouldUpdateExistingImmunizationAsJson() throws Exception { // get the existing record @@ -314,7 +414,7 @@ public void shouldUpdateExistingImmunizationAsXML() throws Exception { immunization.setExpirationDate(expirationDate); // send the update to the server - response = put("/Immunization/" + IMMUNIZATION_UUID).xmlContext(toXML(immunization)).accept(FhirMediaTypes.XML).go(); + response = put("/Immunization/" + IMMUNIZATION_UUID).xmlContent(toXML(immunization)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -345,7 +445,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchImmunizationIdAsXML( immunization.setId(UNKNOWN_IMMUNIZATION_UUID); // send the update to the server - response = put("/Immunization/" + IMMUNIZATION_UUID).xmlContext(toXML(immunization)).accept(FhirMediaTypes.XML).go(); + response = put("/Immunization/" + IMMUNIZATION_UUID).xmlContent(toXML(immunization)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -367,7 +467,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentImmunizationAsXML() throw immunization.setId(UNKNOWN_IMMUNIZATION_UUID); // send the update to the server - response = put("/Immunization/" + UNKNOWN_IMMUNIZATION_UUID).xmlContext(toXML(immunization)) + response = put("/Immunization/" + UNKNOWN_IMMUNIZATION_UUID).xmlContent(toXML(immunization)) .accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/LocationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/LocationFhirResourceProviderIntegrationTest.java index 3652c7354c..788a6f7037 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/LocationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/LocationFhirResourceProviderIntegrationTest.java @@ -166,7 +166,7 @@ public void shouldCreateNewLocationAsXML() throws Exception { } // create location - MockHttpServletResponse response = post("/Location").accept(FhirMediaTypes.XML).xmlContext(xmlLocation).go(); + MockHttpServletResponse response = post("/Location").accept(FhirMediaTypes.XML).xmlContent(xmlLocation).go(); // verify created correctly assertThat(response, isCreated()); @@ -278,7 +278,7 @@ public void shouldUpdateExistingLocationAsXML() throws Exception { location.getAddress().setCountry("France"); // send the update to the server - response = put("/Location/" + LOCATION_UUID).xmlContext(toXML(location)).accept(FhirMediaTypes.XML).go(); + response = put("/Location/" + LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -309,7 +309,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchLocationIdAsXML() th location.setId(UNKNOWN_LOCATION_UUID); // send the update to the server - response = put("/Location/" + LOCATION_UUID).xmlContext(toXML(location)).accept(FhirMediaTypes.XML).go(); + response = put("/Location/" + LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -331,7 +331,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentLocationAsXML() throws Ex location.setId(UNKNOWN_LOCATION_UUID); // send the update to the server - response = put("/Location/" + UNKNOWN_LOCATION_UUID).xmlContext(toXML(location)).accept(FhirMediaTypes.XML).go(); + response = put("/Location/" + UNKNOWN_LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationFhirResourceProviderIntegrationTest.java index 8a945ba661..a2020129e9 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationFhirResourceProviderIntegrationTest.java @@ -164,7 +164,7 @@ public void shouldCreateNewMedicationAsXml() throws Exception { } // create medication - MockHttpServletResponse response = post("/Medication").accept(FhirMediaTypes.XML).xmlContext(xmlMedication).go(); + MockHttpServletResponse response = post("/Medication").accept(FhirMediaTypes.XML).xmlContent(xmlMedication).go(); // verify created correctly assertThat(response, isCreated()); @@ -317,7 +317,7 @@ public void shouldUpdateExistingMedicationAsXml() throws Exception { } //Update - response = put("/Medication/" + MEDICATION_UUID).xmlContext(xmlMedication).accept(FhirMediaTypes.XML).go(); + response = put("/Medication/" + MEDICATION_UUID).xmlContent(xmlMedication).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -358,7 +358,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchMedicationIdAsXML() medication.setId(WRONG_MEDICATION_UUID); // send the update to the server - response = put("/Medication/" + MEDICATION_UUID).xmlContext(toXML(medication)).accept(FhirMediaTypes.XML).go(); + response = put("/Medication/" + MEDICATION_UUID).xmlContent(toXML(medication)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -380,7 +380,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentMedicationAsXML() throws medication.setId(WRONG_MEDICATION_UUID); // send the update to the server - response = put("/Medication/" + WRONG_MEDICATION_UUID).xmlContext(toXML(medication)).accept(FhirMediaTypes.XML).go(); + response = put("/Medication/" + WRONG_MEDICATION_UUID).xmlContent(toXML(medication)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java index 2cabbd2217..7ec2af18bd 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderIntegrationTest.java @@ -270,7 +270,7 @@ public void shouldCreateNewObservationAsXML() throws Exception { } // create obs - MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContext(xmlObs).go(); + MockHttpServletResponse response = post("/Observation").accept(FhirMediaTypes.XML).xmlContent(xmlObs).go(); // verify created correctly assertThat(response, isCreated()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java index f42008dbf1..85a2aeb7d0 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java @@ -218,7 +218,7 @@ public void shouldCreateNewPatientAsXML() throws Exception { } // create patient - MockHttpServletResponse response = post("/Patient").accept(FhirMediaTypes.XML).xmlContext(xmlPatient).go(); + MockHttpServletResponse response = post("/Patient").accept(FhirMediaTypes.XML).xmlContent(xmlPatient).go(); // verify created correctly assertThat(response, isCreated()); @@ -345,7 +345,7 @@ public void shouldUpdateExistingPatientAsXML() throws Exception { patient.setBirthDate(birthDate); // send the update to the server - response = put("/Patient/" + PATIENT_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Patient/" + PATIENT_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -376,7 +376,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPatientIdAsXML() thr patient.setId(WRONG_PATIENT_UUID); // send the update to the server - response = put("/Patient/" + PATIENT_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Patient/" + PATIENT_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -398,7 +398,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentPatientAsXML() throws Exc patient.setId(WRONG_PATIENT_UUID); // send the update to the server - response = put("/Patient/" + WRONG_PATIENT_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Patient/" + WRONG_PATIENT_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PersonFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PersonFhirResourceProviderIntegrationTest.java index 2350bcdfbb..8c2b9ec721 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PersonFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PersonFhirResourceProviderIntegrationTest.java @@ -169,7 +169,7 @@ public void shouldCreateNewPersonAsXML() throws Exception { } // create person - MockHttpServletResponse response = post("/Person").accept(FhirMediaTypes.XML).xmlContext(xmlPerson).go(); + MockHttpServletResponse response = post("/Person").accept(FhirMediaTypes.XML).xmlContent(xmlPerson).go(); // verify created correctly assertThat(response, isCreated()); @@ -290,7 +290,7 @@ public void shouldUpdateExistingPersonAsXML() throws Exception { person.setBirthDate(birthDate); // send the update to the server - response = put("/Person/" + PERSON_UUID).xmlContext(toXML(person)).accept(FhirMediaTypes.XML).go(); + response = put("/Person/" + PERSON_UUID).xmlContent(toXML(person)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -321,7 +321,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPersonIdAsXML() thro person.setId(WRONG_PERSON_UUID); // send the update to the server - response = put("/Person/" + PERSON_UUID).xmlContext(toXML(person)).accept(FhirMediaTypes.XML).go(); + response = put("/Person/" + PERSON_UUID).xmlContent(toXML(person)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PractitionerFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PractitionerFhirResourceProviderIntegrationTest.java index 4ec001f227..0771b6d087 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PractitionerFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PractitionerFhirResourceProviderIntegrationTest.java @@ -179,7 +179,7 @@ public void shouldCreateNewPractitionerAsXML() throws Exception { } // create practitioner - MockHttpServletResponse response = post("/Practitioner").accept(FhirMediaTypes.XML).xmlContext(xmlPractitioner).go(); + MockHttpServletResponse response = post("/Practitioner").accept(FhirMediaTypes.XML).xmlContent(xmlPractitioner).go(); // verify created correctly assertThat(response, isCreated()); @@ -303,7 +303,7 @@ public void shouldUpdateExistingPractitionerAsXML() throws Exception { practitioner.setBirthDate(birthDate); // send the update to the server - response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContext(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); + response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -334,7 +334,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPractitionerIdAsXML( practitioner.setId(WRONG_PRACTITIONER_UUID); // send the update to the server - response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContext(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); + response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -356,7 +356,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentPractitionerAsXML() throw practitioner.setId(WRONG_PRACTITIONER_UUID); // send the update to the server - response = put("/Practitioner/" + WRONG_PRACTITIONER_UUID).xmlContext(toXML(practitioner)).accept(FhirMediaTypes.XML) + response = put("/Practitioner/" + WRONG_PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML) .go(); assertThat(response, isNotFound()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/TaskFhirResourceIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/TaskFhirResourceIntegrationTest.java index ab4bbfcea1..0fae1e683d 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/TaskFhirResourceIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/TaskFhirResourceIntegrationTest.java @@ -177,7 +177,7 @@ public void shouldCreateNewTaskAsXML() throws Exception { xmlTask = IOUtils.toString(is, StandardCharsets.UTF_8); } - MockHttpServletResponse response = post("/Task").accept(FhirMediaTypes.XML).xmlContext(xmlTask).go(); + MockHttpServletResponse response = post("/Task").accept(FhirMediaTypes.XML).xmlContent(xmlTask).go(); assertThat(response, isCreated()); assertThat(response.getHeader("Location"), containsString("/Task/")); @@ -298,7 +298,7 @@ public void shouldUpdateExistingTaskAsXML() throws Exception { task.setStatus(Task.TaskStatus.COMPLETED); - response = put("/Task/" + TASK_UUID).xmlContext(toXML(task)).accept(FhirMediaTypes.XML).go(); + response = put("/Task/" + TASK_UUID).xmlContent(toXML(task)).accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -330,7 +330,7 @@ public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchTaskIdAsXML() throws task.setId(WRONG_TASK_UUID); - response = put("/Task/" + TASK_UUID).xmlContext(toXML(task)).accept(FhirMediaTypes.XML).go(); + response = put("/Task/" + TASK_UUID).xmlContent(toXML(task)).accept(FhirMediaTypes.XML).go(); assertThat(response, isBadRequest()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); @@ -352,7 +352,7 @@ public void shouldReturnNotFoundWhenUpdatingNonExistentTaskAsXML() throws Except patient.setId(WRONG_TASK_UUID); - response = put("/Task/" + WRONG_TASK_UUID).xmlContext(toXML(patient)).accept(FhirMediaTypes.XML).go(); + response = put("/Task/" + WRONG_TASK_UUID).xmlContent(toXML(patient)).accept(FhirMediaTypes.XML).go(); assertThat(response, isNotFound()); assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString())); diff --git a/test-data/src/test/resources/org/openmrs/module/fhir2/api/dao/impl/FhirImmunizationDaoImplTest_initial_data.xml b/test-data/src/test/resources/org/openmrs/module/fhir2/api/dao/impl/FhirImmunizationDaoImplTest_initial_data.xml index def0b13cbe..3a419b13ce 100644 --- a/test-data/src/test/resources/org/openmrs/module/fhir2/api/dao/impl/FhirImmunizationDaoImplTest_initial_data.xml +++ b/test-data/src/test/resources/org/openmrs/module/fhir2/api/dao/impl/FhirImmunizationDaoImplTest_initial_data.xml @@ -29,6 +29,8 @@ + + diff --git a/test-data/src/test/resources/org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.json b/test-data/src/test/resources/org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.json new file mode 100644 index 0000000000..1b6e981a07 --- /dev/null +++ b/test-data/src/test/resources/org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.json @@ -0,0 +1,39 @@ +{ + "resourceType": "Immunization", + "status": "completed", + "vaccineCode": { + "coding": [ + { + "code": "15f83cd6-64e9-4e06-a5f9-364d3b14a43d", + "display": "MEASLES VACCINATION" + } + ] + }, + "patient": { + "type": "Patient", + "reference": "Patient/8d703ff2-c3e2-4070-9737-73e713d5a50d" + }, + "encounter": { + "type": "Encounter", + "reference": "Encounter/814fd8dc-e0be-416b-a7b5-4bac0a4b3297" + }, + "occurrenceDateTime": "2020-07-08T18:30:00.000Z", + "expirationDate": "2021-07-28", + "location": { + "type": "Location", + "reference": "Location/6351fcf4-e311-4a19-90f9-35667d99a8af" + }, + "performer": [ + { + "actor": { + "type": "Practitioner", + "reference": "Practitioner/6f763a67-2bd1-451c-93b9-95caeb36cc24" + } + } + ], + "manufacturer": { + "display": "Pfizer" + }, + "lotNumber": "22", + "protocolApplied": [] +} diff --git a/test-data/src/test/resources/org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.xml b/test-data/src/test/resources/org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.xml new file mode 100644 index 0000000000..281e921a2c --- /dev/null +++ b/test-data/src/test/resources/org/openmrs/module/fhir2/providers/ImmunizationWebTest_create_partial.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +