Search in sources :

Example 96 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnSortedAndFilteredSearchResultsForPatientsAsJson.

@Test
public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsJson() throws Exception {
    MockHttpServletResponse response = get("/DiagnosticReport?patient.given=Collet&_sort=-_lastUpdated").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", equalTo("Patient/5946f880-b197-400b-9caa-a3c661d23041"))))));
    assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2018, 8, 18, 14, 9, 35).atZone(ZoneId.systemDefault()).toInstant()))))), hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2008, 8, 18, 14, 9, 35).atZone(ZoneId.systemDefault()).toInstant())))))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 97 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project openmrs-module-fhir2 by openmrs.

the class TaskFhirResourceIntegrationTest method shouldSearchForFilteredAndSortedTasksAsXML.

@Test
public void shouldSearchForFilteredAndSortedTasksAsXML() throws Exception {
    MockHttpServletResponse response = get("/Task?status=requested&_sort=_lastUpdated").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), is(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, hasSize(2));
    assertThat(entries, everyItem(hasResource(hasProperty("status", is(Task.TaskStatus.REQUESTED)))));
    assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2012, 5, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))))), hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2012, 7, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant())))))));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 98 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project openmrs-module-fhir2 by openmrs.

the class TaskFhirResourceIntegrationTest method shouldSearchForFilteredAndSortedTasksAsJson.

@Test
public void shouldSearchForFilteredAndSortedTasksAsJson() throws Exception {
    MockHttpServletResponse response = get("/Task?status=requested&_sort=_lastUpdated").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), is(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, hasSize(2));
    assertThat(entries, everyItem(hasResource(hasProperty("status", is(Task.TaskStatus.REQUESTED)))));
    assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2012, 5, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))))), hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2012, 7, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant())))))));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 99 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnSortedAndFilteredSearchResultsForPatientsAsXML.

@Test
public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsXML() throws Exception {
    MockHttpServletResponse response = get("/DiagnosticReport?patient.given=Collet&_sort=-_lastUpdated").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", equalTo("Patient/5946f880-b197-400b-9caa-a3c661d23041"))))));
    assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2018, 8, 18, 14, 9, 35).atZone(ZoneId.systemDefault()).toInstant()))))), hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2008, 8, 18, 14, 9, 35).atZone(ZoneId.systemDefault()).toInstant())))))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 100 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project summary-care-record-api by NHSDigital.

the class FindingMapper method mapObservation.

private void mapObservation(ArrayList<Resource> resources, String creTypeCode, String creTypeDisplay, Node node) {
    CodedEntry entry = codedEntryMapper.getCommonCodedEntryValues(node);
    if (SARS_COV_2_CODE.equals(entry.getCodeValue())) {
        var effectiveTimeCentre = xmlUtils.getOptionalValueByXPath(node, EFFECTIVE_TIME_CENTRE_XPATH).map(it -> parseDate(it, DateTimeType.class));
        var observation = new Observation();
        observation.setId(entry.getId());
        observation.setMeta(new Meta().addProfile(UK_CORE_OBSERVATION_META));
        observation.addIdentifier(new Identifier().setValue(entry.getId()));
        observation.setCode(new CodeableConcept().addCoding(new Coding().setCode(entry.getCodeValue()).setSystem(SNOMED_SYSTEM).setDisplay(entry.getCodeDisplay())));
        observation.setStatus(mapStatus(entry.getStatus()));
        if (entry.getEffectiveTimeLow().isPresent() || entry.getEffectiveTimeHigh().isPresent()) {
            var period = new Period();
            entry.getEffectiveTimeLow().ifPresent(period::setStartElement);
            entry.getEffectiveTimeHigh().ifPresent(period::setEndElement);
            observation.setEffective(period);
        } else {
            effectiveTimeCentre.ifPresent(observation::setEffective);
        }
        observation.addCategory(new CodeableConcept(new Coding().setSystem(SNOMED_SYSTEM).setCode(creTypeCode).setDisplay(creTypeDisplay)));
        mapEncounter(node, observation, resources);
        resources.add(observation);
    }
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) Observation(org.hl7.fhir.r4.model.Observation) Period(org.hl7.fhir.r4.model.Period) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

Meta (org.hl7.fhir.r4.model.Meta)35 Date (java.util.Date)33 Reference (org.hl7.fhir.r4.model.Reference)26 Meta (org.hl7.fhir.dstu3.model.Meta)25 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)17 ArrayList (java.util.ArrayList)16 Coding (org.hl7.fhir.r4.model.Coding)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)15 Test (org.junit.Test)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)13 Reference (org.hl7.fhir.dstu3.model.Reference)11 Identifier (org.hl7.fhir.r4.model.Identifier)10 Test (org.junit.jupiter.api.Test)10 Element (org.w3c.dom.Element)10 HashMap (java.util.HashMap)9 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)9 Bundle (org.hl7.fhir.r4.model.Bundle)9