Search in sources :

Example 36 with Task

use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.

the class TaskFhirResourceProviderTest method getTaskById_shouldReturnMatchingTask.

@Test
public void getTaskById_shouldReturnMatchingTask() {
    IdType id = new IdType();
    id.setValue(TASK_UUID);
    when(taskService.get(TASK_UUID)).thenReturn(task);
    Task result = resourceProvider.getTaskById(id);
    assertThat(result.isResource(), is(true));
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(TASK_UUID));
}
Also used : Task(org.hl7.fhir.dstu3.model.Task) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 37 with Task

use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.

the class TaskFhirResourceProviderTest method updateTask_shouldUpdateTask.

@Test
public void updateTask_shouldUpdateTask() {
    when(taskService.update(eq(TASK_UUID), any(org.hl7.fhir.r4.model.Task.class))).thenReturn(task);
    MethodOutcome result = resourceProvider.updateTask(new IdType().setValue(TASK_UUID), TaskVersionConverter.convertTask(task));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(TASK_UUID));
}
Also used : Task(org.hl7.fhir.dstu3.model.Task) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 38 with Task

use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.

the class ProvenanceTranslatorImplTest method shouldGetCreateProvenanceWithCorrectAgentRoleForOpenmrsMetadata.

@Test
public void shouldGetCreateProvenanceWithCorrectAgentRoleForOpenmrsMetadata() {
    Provenance provenance = taskProvenanceTranslator.getCreateProvenance(task);
    assertThat(provenance, notNullValue());
    assertThat(provenance.getAgent(), not(empty()));
    assertThat(provenance.getAgentFirstRep().getRoleFirstRep(), notNullValue());
    assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep(), notNullValue());
    assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep().getCode(), equalTo(AGENT_ROLE_CODE));
    assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep().getDisplay(), equalTo(AGENT_ROLE_DISPLAY));
    assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep().getSystem(), equalTo(FhirConstants.FHIR_TERMINOLOGY_PARTICIPATION_TYPE));
}
Also used : Provenance(org.hl7.fhir.r4.model.Provenance) Test(org.junit.Test)

Example 39 with Task

use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.

the class ProvenanceTranslatorImplTest method shouldGetCreateProvenanceWithCorrectDateChangedForOpenmrsMetadata.

@Test
public void shouldGetCreateProvenanceWithCorrectDateChangedForOpenmrsMetadata() {
    Provenance provenance = taskProvenanceTranslator.getCreateProvenance(task);
    assertThat(provenance, notNullValue());
    assertThat(provenance.getRecorded(), notNullValue());
    assertThat(provenance.getRecorded(), DateMatchers.sameDay(new Date()));
}
Also used : Provenance(org.hl7.fhir.r4.model.Provenance) Date(java.util.Date) Test(org.junit.Test)

Example 40 with Task

use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.

the class ProvenanceTranslatorImplTest method shouldGetCreateProvenanceWithCorrectAgentTypeForOpenmrsMetadata.

@Test
public void shouldGetCreateProvenanceWithCorrectAgentTypeForOpenmrsMetadata() {
    Provenance provenance = taskProvenanceTranslator.getCreateProvenance(task);
    assertThat(provenance, notNullValue());
    assertThat(provenance.getAgent(), not(empty()));
    assertThat(provenance.getAgentFirstRep().getType(), notNullValue());
    assertThat(provenance.getAgentFirstRep().getType().getCodingFirstRep(), notNullValue());
    assertThat(provenance.getAgentFirstRep().getType().getCodingFirstRep().getCode(), equalTo(AGENT_TYPE_CODE));
    assertThat(provenance.getAgentFirstRep().getType().getCodingFirstRep().getDisplay(), equalTo(AGENT_TYPE_DISPLAY));
    assertThat(provenance.getAgentFirstRep().getType().getCodingFirstRep().getSystem(), equalTo(FhirConstants.FHIR_TERMINOLOGY_PROVENANCE_PARTICIPANT_TYPE));
}
Also used : Provenance(org.hl7.fhir.r4.model.Provenance) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)127 Task (org.hl7.fhir.r4.model.Task)120 FhirTask (org.openmrs.module.fhir2.model.FhirTask)59 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)46 Bundle (org.hl7.fhir.r4.model.Bundle)40 Reference (org.hl7.fhir.r4.model.Reference)28 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)24 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)23 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)22 Task (org.hl7.fhir.dstu3.model.Task)21 IdType (org.hl7.fhir.r4.model.IdType)21 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 Date (java.util.Date)16 ArrayList (java.util.ArrayList)13 List (java.util.List)13 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)13 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)11 TokenParam (ca.uhn.fhir.rest.param.TokenParam)11 Collectors (java.util.stream.Collectors)11