Search in sources :

Example 76 with CapabilityStatement

use of org.hl7.fhir.r4.model.CapabilityStatement in project beneficiary-fhir-data by CMSgov.

the class AuthenticationIT method authenticationWorksForTrustedClient.

/**
 * Verifies that authentication works for an SSL client certificate in the server's trust store.
 */
@Test
public void authenticationWorksForTrustedClient() {
    // Construct a FHIR client using a trusted client identity certificate.
    IGenericClient fhirClient = ServerTestUtils.get().createFhirClient(Optional.of(ClientSslIdentity.TRUSTED));
    /*
     * Just check an arbitrary endpoint (all trusted clients have access to
     * everything).
     */
    CapabilityStatement capabilities = fhirClient.capabilities().ofType(CapabilityStatement.class).execute();
    assertNotNull(capabilities);
}
Also used : IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) CapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement) Test(org.junit.jupiter.api.Test)

Example 77 with CapabilityStatement

use of org.hl7.fhir.r4.model.CapabilityStatement in project elexis-server by elexis.

the class ServerCapabilityStatementProvider method getServerConformance.

@Override
public CapabilityStatement getServerConformance(HttpServletRequest theRequest, RequestDetails requestDetails) {
    CapabilityStatement serverConformance = (CapabilityStatement) super.getServerConformance(theRequest, requestDetails);
    serverConformance.getRest().get(0).setSecurity(getSmartOnFhirCapabilityStatementRestSecurityComponent(theRequest));
    return serverConformance;
}
Also used : CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement)

Example 78 with CapabilityStatement

use of org.hl7.fhir.r4.model.CapabilityStatement in project ab2d by CMSgov.

the class BFDHealthCheck method checkBFDHealth.

void checkBFDHealth(HealthCheckData data) {
    boolean errorOccurred = false;
    IBaseConformance capabilityStatement = null;
    try {
        capabilityStatement = bfdClient.capabilityStatement(data.getVersion());
    } catch (Exception e) {
        errorOccurred = true;
        log.error("Exception occurred while trying to retrieve capability statement", e);
        markFailure(data);
    }
    try {
        if (!errorOccurred) {
            if (!data.getVersion().metaDataValid(capabilityStatement)) {
                markFailure(data);
            } else {
                data.incrementSuccesses();
                data.setConsecutiveFailures(0);
                log.debug("{} consecutive successes to connect to BFD for {}", data.getConsecutiveSuccesses(), data.getVersion());
            }
        }
    } catch (Exception ex) {
        errorOccurred = true;
        log.error("Exception occurred while trying to retrieve capability statement - Invalid version", ex);
        markFailure(data);
    }
    if (data.getConsecutiveSuccesses() >= consecutiveSuccessesToBringUp && data.getStatus() == Status.DOWN) {
        updateMaintenanceStatus(data, Status.UP, "false");
    } else if (data.getConsecutiveFailures() >= consecutiveFailuresToTakeDown && data.getStatus() == Status.UP) {
        updateMaintenanceStatus(data, Status.DOWN, "true");
    }
}
Also used : IBaseConformance(org.hl7.fhir.instance.model.api.IBaseConformance)

Example 79 with CapabilityStatement

use of org.hl7.fhir.r4.model.CapabilityStatement in project ab2d by CMSgov.

the class CapabilityAPIV1 method capabilityStatement.

@Operation(summary = CAP_REQ)
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = CAP_DESC + " https://www.hl7.org/fhir/STU3/capabilitystatement.html", headers = { @Header(name = CONTENT_TYPE, description = APPLICATION_JSON) }) })
@ResponseStatus(value = HttpStatus.OK)
@GetMapping(value = "/metadata")
public ResponseEntity<String> capabilityStatement(HttpServletRequest request) {
    IParser parser = STU3.getJsonParser();
    eventLogger.log(new ApiResponseEvent(MDC.get(ORGANIZATION), null, HttpStatus.OK, CAP_STMT, CAP_RET, (String) request.getAttribute(REQUEST_ID)));
    String server = common.getCurrentUrl(request).replace("/metadata", "");
    CapabilityStatement capabilityStatement = CapabilityStatementSTU3.populateCS(server);
    return new ResponseEntity<>(parser.encodeResourceToString(capabilityStatement), null, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) CapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement) ApiResponseEvent(gov.cms.ab2d.eventlogger.events.ApiResponseEvent) IParser(ca.uhn.fhir.parser.IParser) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 80 with CapabilityStatement

use of org.hl7.fhir.r4.model.CapabilityStatement in project ab2d by CMSgov.

the class CapabilityStatementSTU3 method populateCS.

public static CapabilityStatement populateCS(String server) {
    SimpleDateFormat sdfLess = new SimpleDateFormat("MM/dd/yyyy HH:mm");
    CapabilityStatement cs = new CapabilityStatement();
    cs.setPublisher("Centers for Medicare &amp; Medicaid Services");
    cs.setKind(CapabilityStatement.CapabilityStatementKind.INSTANCE);
    cs.setStatus(Enumerations.PublicationStatus.ACTIVE);
    String dt = sdfLess.format(new Date());
    try {
        cs.setDate(sdfLess.parse(dt));
    } catch (ParseException e) {
        cs.setDate(new Date());
    }
    cs.setAcceptUnknown(CapabilityStatement.UnknownContentCode.EXTENSIONS);
    cs.setFhirVersion(FhirVersionEnum.DSTU3.getFhirVersionString());
    CodeType codeType = new CodeType();
    codeType.setValue(APPLICATION_JSON);
    CodeType codeType2 = new CodeType();
    codeType2.setValue("application/fhir+json");
    cs.setFormat(List.of(codeType, codeType2));
    CapabilityStatement.CapabilityStatementSoftwareComponent cssc = new CapabilityStatement.CapabilityStatementSoftwareComponent();
    cssc.setName("AB2D");
    cssc.setVersion("V1");
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    try {
        Date releaseDate = sdf.parse("08/27/2020 00:00:00");
        cssc.setReleaseDate(releaseDate);
    } catch (Exception ex) {
        cssc.setReleaseDate(new Date());
    }
    cs.setSoftware(cssc);
    CapabilityStatement.CapabilityStatementImplementationComponent implementation = new CapabilityStatement.CapabilityStatementImplementationComponent();
    implementation.setUrl(server);
    cs.setImplementation(implementation);
    CapabilityStatement.CapabilityStatementRestComponent rest = new CapabilityStatement.CapabilityStatementRestComponent();
    rest.setMode(CapabilityStatement.RestfulCapabilityMode.SERVER);
    CapabilityStatement.CapabilityStatementRestSecurityComponent security = new CapabilityStatement.CapabilityStatementRestSecurityComponent();
    security.setCors(true);
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = new Coding();
    coding.setSystem("http://hl7.org/fhir/ValueSet/restful-security-service");
    coding.setCode("OAuth");
    coding.setDisplay("OAuth");
    codeableConcept.setCoding(List.of(coding));
    codeableConcept.setText("OAuth");
    security.setService(List.of(codeableConcept));
    rest.setSecurity(security);
    List<CapabilityStatement.CapabilityStatementRestOperationComponent> restComponents = new ArrayList<>();
    restComponents.add(createOperation("export", server + "/Patient/$export"));
    restComponents.add(createOperation("export by contract", server + "/Group/{contractNumber}/$export"));
    restComponents.add(createOperation("cancel", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("status", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("download", server + "/Job/{jobUuid}/file/{filename}"));
    restComponents.add(createOperation("capability", server + "/metadata"));
    rest.setOperation(restComponents);
    rest.setInteraction(List.of(new CapabilityStatement.SystemInteractionComponent().setCode(CapabilityStatement.SystemRestfulInteraction.BATCH)));
    cs.setRest(List.of(rest));
    return cs;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) ParseException(java.text.ParseException) Coding(org.hl7.fhir.dstu3.model.Coding) CapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement) CodeType(org.hl7.fhir.dstu3.model.CodeType) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)39 Test (org.junit.Test)24 Patient (org.hl7.fhir.r4.model.Patient)22 Library (org.hl7.fhir.r4.model.Library)20 Measure (org.hl7.fhir.r4.model.Measure)20 MeasureReport (org.hl7.fhir.r4.model.MeasureReport)18 ArrayList (java.util.ArrayList)17 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)16 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)15 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)14 CapabilityStatement (org.hl7.fhir.dstu3.model.CapabilityStatement)13 HashMap (java.util.HashMap)12 Test (org.junit.jupiter.api.Test)11 Date (java.util.Date)10 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)10 StringType (org.hl7.fhir.r4.model.StringType)10 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 Coding (org.hl7.fhir.r4.model.Coding)9 CapabilityStatement (org.hl7.fhir.r5.model.CapabilityStatement)9 Extension (org.hl7.fhir.r4.model.Extension)8