use of org.hl7.fhir.r4b.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);
}
use of org.hl7.fhir.r4b.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;
}
use of org.hl7.fhir.r4b.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");
}
}
use of org.hl7.fhir.r4b.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);
}
use of org.hl7.fhir.r4b.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 & 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;
}
Aggregations