use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenImmunizationNotFoundAsJson.
@Test
public void shouldReturnNotFoundWhenImmunizationNotFoundAsJson() throws Exception {
MockHttpServletResponse response = get("/Immunization/" + UNKNOWN_IMMUNIZATION_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchImmunizationIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchImmunizationIdAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Immunization/" + IMMUNIZATION_UUID).accept(FhirMediaTypes.JSON).go();
Immunization immunization = readResponse(response);
// update the existing record
immunization.setId(UNKNOWN_IMMUNIZATION_UUID);
// send the update to the server
response = put("/Immunization/" + IMMUNIZATION_UUID).jsonContent(toJson(immunization)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isBadRequest());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderIntegrationTest method shouldUpdateExistingImmunizationAsJson.
@Test
public void shouldUpdateExistingImmunizationAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Immunization/" + IMMUNIZATION_UUID).accept(FhirMediaTypes.JSON).go();
Immunization immunization = readResponse(response);
// update the existing record
Date expirationDate = DateUtils.truncate(new Date(), Calendar.DATE);
immunization.setExpirationDate(expirationDate);
// send the update to the server
response = put("/Immunization/" + IMMUNIZATION_UUID).jsonContent(toJson(immunization)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
Immunization updatedImmunization = readResponse(response);
assertThat(updatedImmunization, notNullValue());
assertThat(updatedImmunization.getIdElement().getIdPart(), equalTo(IMMUNIZATION_UUID));
assertThat(updatedImmunization.getExpirationDate(), equalTo(expirationDate));
assertThat(immunization, validResource());
// double-check the record returned via get
response = get("/Immunization/" + IMMUNIZATION_UUID).accept(FhirMediaTypes.JSON).go();
Immunization reReadImmunization = readResponse(response);
assertThat(reReadImmunization.getExpirationDate(), equalTo(expirationDate));
}
use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderIntegrationTest method shouldSearchForExistingImmunizationAsJson.
@Test
public void shouldSearchForExistingImmunizationAsJson() throws Exception {
MockHttpServletResponse response = get("/Immunization").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/Immunization/"))));
assertThat(entries, everyItem(hasResource(instanceOf(Immunization.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/Immunization?patient.identifier=M4001-1&_sort=status").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("patient", hasProperty("referenceElement", hasProperty("idPart", equalTo(PATIENT_UUID)))))));
assertThat(entries, everyItem(hasResource(validResource())));
}
use of org.hl7.fhir.r4.model.Immunization in project odm2fhir by num-codex.
the class ImmunizationStatus method createImmunization.
@SuppressWarnings("fallthrough")
private Immunization createImmunization(ItemData immunizationCoding, ItemData dateCoding, ItemData textValue) {
var immunization = (Immunization) new Immunization().addIdentifier(createIdentifier(IMMUNIZATION, immunizationCoding)).setOccurrence(createDateTimeType(dateCoding)).setMeta(createMeta(NUMStructureDefinition.IMMUNIZATION));
var vaccineCodeableCoding = new CodeableConcept();
var diseaseCodeableCoding = new CodeableConcept();
for (var coding : createCodings(immunizationCoding)) {
switch(coding.getCode()) {
case // YES
"410605003":
immunization.setStatus(COMPLETED);
break;
case // NO
"410594000":
immunization.setStatus(NOTDONE);
break;
case // Answer = Sonstige/Other
"385432009":
diseaseCodeableCoding.addCoding(coding.setDisplay("Not applicable (qualifier value)"));
if (!textValue.isEmpty()) {
diseaseCodeableCoding.setText(textValue.getValue());
}
break;
case // UNKNOWN
"261665006":
// do not create FHIR-resources
return new Immunization();
// Influenza
case "836377006":
// Pneumokokken
case "836398006":
// BCG
case "836402002":
case // Covid19
"1119349007":
vaccineCodeableCoding.addCoding(coding);
break;
// cases for targetDisease
case // Andere
"64572001":
if (!textValue.isEmpty()) {
diseaseCodeableCoding.setText(textValue.getValue());
}
// Influenza
case "6142004":
// Pneumokokken
case "16814004":
// BCG
case "56717001":
case // Covid19
"840539006":
diseaseCodeableCoding.addCoding(coding);
break;
}
}
if (vaccineCodeableCoding.isEmpty()) {
// add No-Known-Immunuzations if no vaccineCode given
vaccineCodeableCoding.addCoding(createCoding(NO_IMMUNIZATION_INFO_UV_IPS, "no-known-immunizations", "vaccineCode unknown"));
}
if (diseaseCodeableCoding.isEmpty()) {
// add targetDisease unknown if none present
diseaseCodeableCoding.addCoding(createCoding(SNOMED_CT, "64572001", "Disease (disorder)"));
}
immunization.setVaccineCode(vaccineCodeableCoding).addProtocolApplied(new ImmunizationProtocolAppliedComponent().setDoseNumber((StringType) new StringType().addExtension(DATA_ABSENT_FOR_UNKNOWN_REASON)).addTargetDisease(diseaseCodeableCoding));
return immunization;
}
Aggregations