Search in sources :

Example 86 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 AllergyIntoleranceFhirR3ResourceProviderTest method createAllergyIntolerance_shouldCreateNewAllergyIntolerance.

@Test
public void createAllergyIntolerance_shouldCreateNewAllergyIntolerance() {
    when(service.create(any(org.hl7.fhir.r4.model.AllergyIntolerance.class))).thenReturn(allergyIntolerance);
    MethodOutcome result = resourceProvider.creatAllergyIntolerance(AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance));
    assertThat(result, notNullValue());
    assertThat(result.getCreated(), is(true));
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 87 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 AllergyIntoleranceFhirR3ResourceProviderTest method searchForAllergies_shouldAddPatientsToReturnedResultsForPatientInclude.

@Test
public void searchForAllergies_shouldAddPatientsToReturnedResultsForPatientInclude() {
    HashSet<Include> includes = new HashSet<>();
    includes.add(new Include("AllergyIntolerance:patient"));
    when(service.searchForAllergies(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includes)))).thenReturn(new MockIBundleProvider<>(Arrays.asList(allergyIntolerance, new org.hl7.fhir.r4.model.Patient()), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchForAllergies(null, null, null, null, null, null, null, null, null, null, includes);
    List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
    assertThat(results, notNullValue());
    assertThat(resultList.size(), greaterThanOrEqualTo(2));
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.ALLERGY_INTOLERANCE));
    assertThat(resultList.get(1).fhirType(), is(FhirConstants.PATIENT));
    assertThat(((AllergyIntolerance) resultList.iterator().next()).getId(), equalTo(ALLERGY_UUID));
}
Also used : Include(ca.uhn.fhir.model.api.Include) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 88 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 AllergyIntoleranceFhirR3ResourceProviderTest method updateAllergyIntolerance_shouldUpdateAllergyIntolerance.

@Test
public void updateAllergyIntolerance_shouldUpdateAllergyIntolerance() {
    when(service.update(eq(ALLERGY_UUID), any(org.hl7.fhir.r4.model.AllergyIntolerance.class))).thenReturn(allergyIntolerance);
    MethodOutcome result = resourceProvider.updateAllergyIntolerance(new IdType().setValue(ALLERGY_UUID), AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 89 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 ConditionFhirR3ResourceProviderTest method createCondition_shouldCreateNewCondition.

@Test
public void createCondition_shouldCreateNewCondition() {
    when(conditionService.create(any(org.hl7.fhir.r4.model.Condition.class))).thenReturn(condition);
    MethodOutcome result = resourceProvider.createCondition(Condition30_40.convertCondition(condition));
    assertThat(result, notNullValue());
    assertThat(result.getCreated(), is(true));
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(CONDITION_UUID));
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 90 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 createDiagnosticReport_shouldCreateNewDiagnosticReport.

@Test
public void createDiagnosticReport_shouldCreateNewDiagnosticReport() {
    when(service.create(any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenReturn(diagnosticReport);
    MethodOutcome result = resourceProvider.createDiagnosticReport(DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(diagnosticReport.getId()));
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) 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