Search in sources :

Example 1 with Observation

use of org.hl7.fhir.r4.model.Observation in project loinc2hpo by monarch-initiative.

the class ObservationDownloader method find20CompleteRecordOfEachType.

static void find20CompleteRecordOfEachType() {
    int i = 0;
    Bundle bundle = client.search().forResource(Observation.class).prettyPrint().returnBundle(Bundle.class).execute();
    while (true) {
        for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
            Observation observation = (Observation) bundleEntryComponent.getResource();
            if (isComplte(observation)) {
                String completeRecord = jsonParser.encodeResourceToString(observation);
                i++;
                System.out.println(i + ". Find a complete record: \n" + completeRecord);
            }
            ;
        }
        if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
            bundle = client.loadPage().next(bundle).execute();
        } else {
            break;
        }
    }
}
Also used : IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle)

Example 2 with Observation

use of org.hl7.fhir.r4.model.Observation in project loinc2hpo by monarch-initiative.

the class FhirObservationRetrieverTest method testParseJsonFile2Observation.

@Test
public void testParseJsonFile2Observation() {
    String path = getClass().getClassLoader().getResource("json/glucoseHigh.fhir").getPath();
    Observation observation = FhirResourceRetriever.parseJsonFile2Observation(path);
    assertNotNull(observation);
    assertEquals("Observation", observation.getResourceType().toString());
}
Also used : Observation(org.hl7.fhir.dstu3.model.Observation) Test(org.junit.Test)

Example 3 with Observation

use of org.hl7.fhir.r4.model.Observation in project loinc2hpo by monarch-initiative.

the class Dstu3ObservationTest method testGlucoseNormal.

@Test
void testGlucoseNormal() throws IOException {
    String jsonPath = "json/glucoseNormal.fhir";
    Observation glucoseAbnormal = importDstu3Observation(jsonPath);
    Uberobservation uberobservation = new ObservationDtu3(glucoseAbnormal);
    LoincId expectedLoincId = new LoincId("15074-8");
    Optional<LoincId> opt = uberobservation.getLoincId();
    assertTrue(opt.isPresent());
    assertEquals(expectedLoincId, opt.get());
    Optional<Outcome> opt2 = uberobservation.getOutcome();
    assertTrue(opt2.isPresent());
    assertEquals(Outcome.NORMAL(), opt2.get());
    assertNotEquals(Outcome.LOW(), opt2.get());
    assertNotEquals(Outcome.HIGH(), opt2.get());
}
Also used : ObservationDtu3(org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Observation(org.hl7.fhir.dstu3.model.Observation) TestBase.importDstu3Observation(fhir.TestBase.importDstu3Observation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Uberobservation(org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation) Test(org.junit.jupiter.api.Test)

Example 4 with Observation

use of org.hl7.fhir.r4.model.Observation in project loinc2hpo by monarch-initiative.

the class Dstu3ObservationTest method testGlucoseHigh.

@Test
void testGlucoseHigh() throws IOException {
    String jsonPath = "json/glucoseHigh.fhir";
    Observation glucoseHigh = importDstu3Observation(jsonPath);
    Uberobservation uberobservation = new ObservationDtu3(glucoseHigh);
    LoincId expectedLoincId = new LoincId("15074-8");
    Optional<LoincId> opt = uberobservation.getLoincId();
    assertTrue(opt.isPresent());
    assertEquals(expectedLoincId, opt.get());
    Optional<Outcome> opt2 = uberobservation.getOutcome();
    assertTrue(opt2.isPresent());
    assertEquals(Outcome.HIGH(), opt2.get());
    assertNotEquals(Outcome.LOW(), opt2.get());
    assertNotEquals(Outcome.NORMAL(), opt2.get());
}
Also used : ObservationDtu3(org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Observation(org.hl7.fhir.dstu3.model.Observation) TestBase.importDstu3Observation(fhir.TestBase.importDstu3Observation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Uberobservation(org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation) Test(org.junit.jupiter.api.Test)

Example 5 with Observation

use of org.hl7.fhir.r4.model.Observation in project loinc2hpo by monarch-initiative.

the class ObservationWithValueRangeTest method highHbWithReferenceRange.

/**
 * This observation does not have an Interpretation, but we can infer the value to be high
 * based on the reference range.
 */
@Test
public void highHbWithReferenceRange() {
    Observation observation = highHemoglobinWithValueRangeObservation();
    Uberobservation uberobservation = new ObservationDtu3(observation);
    LoincId erysInBlood = new LoincId("789-8");
    Optional<LoincId> opt = uberobservation.getLoincId();
    assertTrue(opt.isPresent());
    assertEquals(erysInBlood, opt.get());
    Optional<Outcome> outcomeOpt = uberobservation.getOutcome();
    assertTrue(outcomeOpt.isPresent());
    assertEquals(Outcome.HIGH(), outcomeOpt.get());
}
Also used : ObservationDtu3(org.monarchinitiative.loinc2hpofhir.fhir2hpo.ObservationDtu3) Outcome(org.monarchinitiative.loinc2hpocore.codesystems.Outcome) Observation(org.hl7.fhir.dstu3.model.Observation) LoincId(org.monarchinitiative.loinc2hpocore.loinc.LoincId) Uberobservation(org.monarchinitiative.loinc2hpofhir.fhir2hpo.Uberobservation) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.Test)235 Observation (org.hl7.fhir.r4.model.Observation)231 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)114 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)106 Observation (org.hl7.fhir.dstu3.model.Observation)88 Bundle (org.hl7.fhir.r4.model.Bundle)85 Test (org.junit.jupiter.api.Test)70 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)64 Resource (org.hl7.fhir.r4.model.Resource)55 Bundle (org.hl7.fhir.dstu3.model.Bundle)52 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)51 Coding (org.hl7.fhir.r4.model.Coding)45 ArrayList (java.util.ArrayList)43 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Reference (org.hl7.fhir.r4.model.Reference)41 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)37 TokenParam (ca.uhn.fhir.rest.param.TokenParam)37 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)32 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)32 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)32