Search in sources :

Example 71 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationTranslatorImplTest method toFhirResource_shouldConvertStatus.

@Test
public void toFhirResource_shouldConvertStatus() {
    Obs observation = new Obs();
    when(observationStatusTranslator.toFhirResource(observation)).thenReturn(Observation.ObservationStatus.UNKNOWN);
    Observation result = observationTranslator.toFhirResource(observation);
    assertThat(result.getStatus(), is(Observation.ObservationStatus.UNKNOWN));
}
Also used : Obs(org.openmrs.Obs) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.Test)

Example 72 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationTranslatorImplTest method toOpenmrsType_shouldTranslateCodeToConcept.

@Test
public void toOpenmrsType_shouldTranslateCodeToConcept() {
    Observation observation = new Observation();
    CodeableConcept codeableConcept = new CodeableConcept();
    codeableConcept.setId(CONCEPT_UUID);
    observation.setCode(codeableConcept);
    Concept concept = new Concept();
    concept.setUuid(CONCEPT_UUID);
    when(conceptTranslator.toOpenmrsType(codeableConcept)).thenReturn(concept);
    Obs result = observationTranslator.toOpenmrsType(new Obs(), observation);
    assertThat(result, notNullValue());
    assertThat(result.getConcept(), notNullValue());
    assertThat(result.getConcept().getUuid(), equalTo(CONCEPT_UUID));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) Obs(org.openmrs.Obs) Observation(org.hl7.fhir.r4.model.Observation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 73 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationTranslatorImplTest method toFhirResource_shouldTranslateOpenMrsDateCreatedToDateIssued.

@Test
public void toFhirResource_shouldTranslateOpenMrsDateCreatedToDateIssued() {
    Obs observation = new Obs();
    observation.setDateCreated(new Date());
    Observation result = observationTranslator.toFhirResource(observation);
    assertThat(result, notNullValue());
    assertThat(result.getIssued(), DateMatchers.sameDay(new Date()));
}
Also used : Obs(org.openmrs.Obs) Observation(org.hl7.fhir.r4.model.Observation) Date(java.util.Date) Test(org.junit.Test)

Example 74 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationTranslatorImplTest method toFhirResource_shouldConvertPatientToReference.

@Test
public void toFhirResource_shouldConvertPatientToReference() {
    Obs observation = new Obs();
    Patient patient = new Patient();
    patient.setUuid(PATIENT_UUID);
    observation.setPerson(patient);
    Reference patientReference = new Reference();
    patientReference.setType("Patient");
    patientReference.setId(PATIENT_UUID);
    when(patientReferenceTranslator.toFhirResource(patient)).thenReturn(patientReference);
    Observation result = observationTranslator.toFhirResource(observation);
    assertThat(result.getSubject(), notNullValue());
    assertThat(result.getSubject().getType(), equalTo("Patient"));
    assertThat(result.getSubject().getId(), equalTo(PATIENT_UUID));
}
Also used : Obs(org.openmrs.Obs) Reference(org.hl7.fhir.r4.model.Reference) Observation(org.hl7.fhir.r4.model.Observation) Patient(org.openmrs.Patient) Test(org.junit.Test)

Example 75 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationTranslatorImplTest method toOpenmrsType_shouldThrowExceptionIfObsNull.

@Test(expected = NullPointerException.class)
public void toOpenmrsType_shouldThrowExceptionIfObsNull() {
    Observation observation = new Observation();
    observationTranslator.toOpenmrsType(null, observation);
}
Also used : Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.Test)

Aggregations

Observation (org.hl7.fhir.r4.model.Observation)237 Test (org.junit.Test)235 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)114 Test (org.junit.jupiter.api.Test)107 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)106 Observation (org.hl7.fhir.dstu3.model.Observation)94 Bundle (org.hl7.fhir.r4.model.Bundle)88 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)64 ArrayList (java.util.ArrayList)62 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)59 Resource (org.hl7.fhir.r4.model.Resource)55 Bundle (org.hl7.fhir.dstu3.model.Bundle)53 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)47 Coding (org.hl7.fhir.r4.model.Coding)46 Reference (org.hl7.fhir.r4.model.Reference)41 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)37 TokenParam (ca.uhn.fhir.rest.param.TokenParam)37 Date (java.util.Date)34 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)32 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)32