Search in sources :

Example 41 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project himss_2021_sepsis_detection by redhat-na-ssa.

the class GetObservationsSignalEventCommand method getTimeBoxedObservation.

private List<Observation> getTimeBoxedObservation(Patient patient) {
    List<Observation> obsList = new ArrayList<>();
    Calendar instance = Calendar.getInstance();
    instance.add(Calendar.DATE, -1);
    Date timeBoxDate = instance.getTime();
    String patientID = patient.getId();
    String url = fhirURL + "/fhir/Observation?patient=" + patientID + "&_pretty=true";
    log.info("getTimeBoxedObservation() fhirUrl endpoint = " + url);
    String bundleStr = template.getForEntity(url, String.class).getBody();
    Bundle newBundle = fhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr);
    for (BundleEntryComponent component : newBundle.getEntry()) {
        if (component.getResource() instanceof Observation) {
            Observation obs = (Observation) component.getResource();
            if (// Adding Observation only if its 24 hrs
            obs.getMeta().getLastUpdatedElement().after(timeBoxDate))
                obsList.add(obs);
        }
    }
    log.info("getTimedBoxedObservation() Patient Id : " + patientID + " # of Observations = " + obsList.size());
    return obsList;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Calendar(java.util.Calendar) Observation(org.hl7.fhir.r4.model.Observation) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 42 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project CRD by HL7-DaVinci.

the class CoverageRequirementsDiscoveryOperationHardCodedResponseTests method testCrdSuccess.

@Test
@DisplayName("Test CRD with good data.")
void testCrdSuccess() {
    CoverageRequirementsDiscoveryOperationHardCodedResponse crdop = new CoverageRequirementsDiscoveryOperationHardCodedResponse();
    // valid parameters
    Parameters.ParametersParameterComponent request = buildRequest(buildCoverageEligibilityRequest("1234"), buildPatient("patient-4", "Bob Smith"), buildCoverage("4321"), buildProvider("5678"), buildInsurer("87654", "InsureCo"), buildFacility(), buildCondition("condition-1"), buildDevice("XYZ-123"), buildProcedure("12345678"), buildMedication(40));
    Endpoint endpoint = buildEndpoint();
    CodeableConcept requestQualification = buildRequestQualification();
    Parameters outParams = crdop.coverageRequirementsDiscovery(request, endpoint, requestQualification);
    assertFalse(outParams.isEmpty());
}
Also used : CoverageRequirementsDiscoveryOperationHardCodedResponse(org.hl7.davinci.CoverageRequirementsDiscoveryOperationHardCodedResponse) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 43 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project CRD by HL7-DaVinci.

the class CdsHooksController method serviceDiscovery.

/**
 * The FHIR r4 services discovery endpoint.
 * @return A services object containing an array of all services available on this server
 */
@CrossOrigin
@GetMapping(value = FHIR_RELEASE + URL_BASE)
public CdsServiceInformation serviceDiscovery() {
    logger.info("r4/serviceDiscovery");
    CdsServiceInformation serviceInformation = new CdsServiceInformation();
    serviceInformation.addServicesItem(orderSignService);
    serviceInformation.addServicesItem(orderSelectService);
    return serviceInformation;
}
Also used : CdsServiceInformation(org.hl7.davinci.endpoint.cdshooks.services.crd.CdsServiceInformation) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 44 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project dpc-app by CMSgov.

the class OrganizationResourceTest method testOrganizationFetchById.

@Test
void testOrganizationFetchById() {
    final IGenericClient client = APIAuthHelpers.buildAuthenticatedClient(ctx, getBaseURL(), ORGANIZATION_TOKEN, PUBLIC_KEY_ID, PRIVATE_KEY);
    final Organization organization = client.read().resource(Organization.class).withId(ORGANIZATION_ID).encodedJson().execute();
    assertNotNull(organization, "Should have organization");
    // Try to get all public endpoints
    final Bundle endPointBundle = client.search().forResource(Endpoint.class).encodedJson().returnBundle(Bundle.class).execute();
    assertEquals(1, endPointBundle.getTotal(), "Should have one endpoint");
    // Try to fetch it
    final Endpoint endpoint = (Endpoint) endPointBundle.getEntryFirstRep().getResource();
    final Endpoint fetchedEndpoint = client.read().resource(Endpoint.class).withId(endpoint.getId()).encodedJson().execute();
    assertTrue(endpoint.equalsDeep(fetchedEndpoint), "Should have matching records");
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) Endpoint(org.hl7.fhir.dstu3.model.Endpoint) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle) Test(org.junit.jupiter.api.Test) AbstractSecureApplicationTest(gov.cms.dpc.api.AbstractSecureApplicationTest)

Example 45 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project dpc-app by CMSgov.

the class EndpointResourceUnitTest method testCreateEndpoint.

@Test
public void testCreateEndpoint() {
    UUID orgId = UUID.randomUUID();
    Organization organization = new Organization();
    organization.setId(orgId.toString());
    OrganizationPrincipal organizationPrincipal = new OrganizationPrincipal(organization);
    Endpoint endpoint = new Endpoint();
    ICreateTyped createExec = Mockito.mock(ICreateTyped.class);
    Mockito.when(attributionClient.create().resource(endpoint).encodedJson()).thenReturn(createExec);
    MethodOutcome outcome = new MethodOutcome();
    outcome.setResource(endpoint);
    Mockito.when(createExec.execute()).thenReturn(outcome);
    Response response = resource.createEndpoint(organizationPrincipal, endpoint);
    Endpoint result = (Endpoint) response.getEntity();
    assertEquals(endpoint, result);
    assertEquals("Organization/" + orgId.toString(), endpoint.getManagingOrganization().getReference());
}
Also used : Response(javax.ws.rs.core.Response) OrganizationPrincipal(gov.cms.dpc.api.auth.OrganizationPrincipal) Organization(org.hl7.fhir.dstu3.model.Organization) Endpoint(org.hl7.fhir.dstu3.model.Endpoint) ICreateTyped(ca.uhn.fhir.rest.gclient.ICreateTyped) UUID(java.util.UUID) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)36 Endpoint (org.hl7.fhir.dstu3.model.Endpoint)21 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)18 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)16 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)15 Endpoint (org.hl7.fhir.r4.model.Endpoint)15 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)14 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)14 Bundle (org.hl7.fhir.r4.model.Bundle)12 Organization (org.hl7.fhir.dstu3.model.Organization)11 Resource (org.hl7.fhir.r4.model.Resource)10 Resource (org.hl7.fhir.dstu3.model.Resource)9 Operation (ca.uhn.fhir.rest.annotation.Operation)7 List (java.util.List)7 Bundle (org.hl7.fhir.dstu3.model.Bundle)7 Description (ca.uhn.fhir.model.api.annotation.Description)6 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)6 ArrayList (java.util.ArrayList)6