📊

Reports

After a user completes a measurement or when the prescription period ends, the user and physician receive (periodic) reports with results and insights into the measurement(s).

Request a measurement report and render the PDF

SDK

The getMeasurementReportUrl method accepts a measurementId and handles the creation and fetching of the report.
  • The first time you execute this function for a measurement, it will take a little longer. The cloud service will render the report synchronously. Once it's ready (~5s) a URL will be returned. The report is available at this URL.
  • Subsequent calls will be much faster, as the report is already rendered and the URL will be returned almost instantly.
  • The PDF will always be rendered in the user's language. This is the language that was specified during the user's registration process.
Flutter
React Native
This functionality works great in combination with url_launcher.
​
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_fibricheck_sdk/flutter_fibricheck_sdk.dart';
​
_reportUrl = await _sdk.getMeasurementReportUrl(widget.measurement.id!);
​
Future<void> _launchUrl() async {
final url = Platform.isAndroid ? "https://docs.google.com/viewer?url=$reportUrl" : reportUrl;
if (await canLaunchUrl(Uri.parse(url))) {
if (!await launchUrl(Uri.parse(url))) {
throw 'Could not launch $reportUrl';
}
}
}
This functionality works great in combination with react-native-pdf or react-native-share.
import Pdf from 'react-native-pdf';
​
const measurementId = '0000';
​
const App = () => {
const [uri, setUri] = useState();
​
useEffect(() => {
(async () => {
const uri = await sdk.getReportUrl(measurementId);
setUri(uri);
})();
}, []);
​
return (
<Pdf
source={{
uri,
}}
/>
);
};

REST API

Rendering a PDF report using the REST API takes 3 simple steps. The first step is only needed when no report has been created yet.

Step 1 • Generate a report

post
https://api.fibricheck.com
/data/v1/measurement-reports
Generate a new report
This API call should be executed with the following body to trigger a report creation:
{
"measurementId" : "{measurementId}"
"language": "EN"
}
  • measurementId identifies the measurement for which you want to generate a report.
  • language defines the language in which the report will be generated. It is advised to use the user's set language.
To generate a report for a measurement, make sure that the measurement status is set toanalyzed, pending-review or reviewed

Step 2 • Fetch the report file token

Using the measurementId from the measurement, execute the API call below. This will return the latest generated report.
get
https://api.fibricheck.com
/data/v1/measurement-reports?limit(1)&sort(-id)&eq(data.measurementId,{measurementId})
Fetch report details
Best Practice
We recommend to compare data.forMeasurementUpdatedTimestamp from the report with value with the updateTimestamp from the measurement. If the measurement timestamp is later than the report timestamp, a new report should be generated (see step 1) because the measurement data has been updated.
If data.status is set to rendered, the PDF report is available for downloading.

Step 3 • Fetch the PDF report URL

Using data.readFileToken from step 2 you can construct the URL at which the PDF is available:
https://api.fibricheck.com/files/v1/{readFileToken}/file
This endpoint is publicly available.

Request periodic reports

Periodic reports are generated automatically on predetermined timeframes. This can be manual, 7 days, 30 days or at the end of a prescription.
Note that B2C Essential users will not receive periodic reports!

SDK

The getPeriodicReports method returns a paginated result with all periodic reports for the currently authenticated user. You can find the measurements from that period in the data.measurements property. You can also use the next and previous methods available on the result to navigate through the user's measurements.
In periodic reports, the trigger field indicates for which period the report was made. This can be 7 days, 30 days or at the end of a prescription.
The getPeriodicReportPdf method retrieves a PDF version of the report. This method takes a reportId as a parameter. The PDF is rendered in the user's language.
Flutter
React Native
import 'package:flutter_fibricheck_sdk/flutter_fibricheck_sdk.dart';
​
_sdk.getPeriodicReports(true); // true -> get newest reports first
await res.getNextPagedPeriodicReportsResult(); // get next 20 reports
await res.getPreviousPagedPeriodicReportsResult(); // get previous 20 reports
​
​
// To request a specific report in PDF format, use the following method
await _sdk.getPeriodicReportPdf(reportId);
If you save the PDF you could render it in the app with a package such as https://pub.dev/packages/pdf_render​
The method is a generator function that returns an iterator. This iterator can be called with .next() to retrieve the next 20 reports. Another way to do this is by using the for await construction, as seen in the example.
import client from '@fibricheck/javascript-sdk';
​
interface PeriodicReport {
id: string;
status: string;
trigger: 'PERIOD_DAYS_PASSED_7' | 'PERIOD_DAYS_PASSED_30' | 'PRESCRIPTION_ENDED';
creationTimestamp: number;
}
​
const sdk = client({
consumerKey: '',
consumerSecret: '',
});
​
await sdk.authenticate({
token: '',
tokenSecret: '',
});
​
const reportsIterator = await sdk.getPeriodicReports();
​
for await (const reportsPage of reportsIterator) {
... /* PagedResult<PeriodReport> */
}
​
Here's an example of how to convert the response to a PDF using react-native-share:
import client from '@fibricheck/javascript-sdk';
import Share from 'react-native-share';
​
const sdk = client({
consumerKey: '',
consumerSecret: '',
});
​
await sdk.authenticate({
token: '',
tokenSecret: '',
});
​
const report = await sdk.getPeriodicReportPdf('62441ce00000000000000000');
const base64 = Buffer.from(file.data, 'binary').toString('base64');
const file = `data:application/pdf;base64,${base64}`;
const filename = file.headers['content-disposition'].split('filename="')[1].split('.pdf"')[0];
​
await Share.open({
title: filename,
type: 'application/pdf',
filename: filename,
url: file,
});

REST API

get
https://api
/reports/v1?sort(-creation_timestamp)&user_id={userId}
Get periodic reports
To render a PDF version of the periodic report:
get
https://api.fibricheck.com
/reports/v1/{reportId}/pdf?language={language}&time_zone={timeZone}
Render periodic report