Search in sources :

Example 91 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist.

@Test(expected = MethodNotAllowedException.class)
public void updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist() {
    DiagnosticReport wrongDiagnosticReport = new DiagnosticReport();
    wrongDiagnosticReport.setId(WRONG_UUID);
    when(service.update(eq(WRONG_UUID), any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenThrow(MethodNotAllowedException.class);
    resourceProvider.updateDiagnosticReport(new IdType().setValue(WRONG_UUID), wrongDiagnosticReport);
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 92 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowInvalidRequestForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateDiagnosticReport_shouldThrowInvalidRequestForMissingId() {
    DiagnosticReport noIdDiagnosticReport = new DiagnosticReport();
    when(service.update(eq(UUID), any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenThrow(InvalidRequestException.class);
    resourceProvider.updateDiagnosticReport(new IdType().setValue(UUID), noIdDiagnosticReport);
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 93 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class EncounterFhirResourceProviderTest method updateEncounter_shouldUpdateEncounter.

@Test
public void updateEncounter_shouldUpdateEncounter() {
    when(encounterService.update(eq(ENCOUNTER_UUID), any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter);
    MethodOutcome result = resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), Encounter30_40.convertEncounter(encounter));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ENCOUNTER_UUID));
}
Also used : Encounter(org.hl7.fhir.dstu3.model.Encounter) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 94 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class EncounterFhirResourceProviderTest method createEncounter_shouldCreateNewEncounter.

@Test
public void createEncounter_shouldCreateNewEncounter() {
    when(encounterService.create(any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter);
    MethodOutcome result = resourceProvider.createEncounter(Encounter30_40.convertEncounter(encounter));
    assertThat(result, notNullValue());
    assertThat(result.getCreated(), is(true));
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ENCOUNTER_UUID));
}
Also used : Encounter(org.hl7.fhir.dstu3.model.Encounter) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 95 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class EncounterFhirResourceProviderTest method searchEncounters_shouldReturnMatchingEncounters.

@Test
public void searchEncounters_shouldReturnMatchingEncounters() {
    List<org.hl7.fhir.r4.model.Encounter> encounters = new ArrayList<>();
    encounters.add(encounter);
    when(encounterService.searchForEncounters(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(encounters, PREFERRED_SIZE, COUNT));
    ReferenceAndListParam subjectReference = new ReferenceAndListParam();
    subjectReference.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME)));
    IBundleProvider results = resourceProvider.searchEncounter(null, null, null, subjectReference, null, null, null, null, null, null, null);
    List<Encounter> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.ENCOUNTER));
    assertThat(resultList.get(0).getId(), equalTo(ENCOUNTER_UUID));
}
Also used : ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.dstu3.model.Encounter) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)427 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)104 ArrayList (java.util.ArrayList)101 IOException (java.io.IOException)78 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)65 List (java.util.List)64 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 FileOutputStream (java.io.FileOutputStream)59 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 File (java.io.File)57 InputStream (java.io.InputStream)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Bundle (org.hl7.fhir.dstu3.model.Bundle)48 MethodSource (org.junit.jupiter.params.provider.MethodSource)46 Arrays (java.util.Arrays)45 Collectors (java.util.stream.Collectors)45