📊

Reports

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

Request a measurement report and render the PDF

Flutter
React Native
The sdk.getMeasurementReportUrl accepts a measurementId and will handle creation / fetching of the report. This function works great in combination with https://pub.dev/packages/url_launcher
  • First time calling this function for a measurement, it will take a little longer as the cloud service will render the report. Once it's ready (~5s) the url where you can fetch it will be returned
  • 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 language of the user (this language is specified during register-a-new-user)
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';
}
}
}
The sdk.getMeasurementReportUrl accepts a measurementId and will handle creation / fetching of the report. This function works great in combination with react-native-pdf or react-native-share
  • First time calling this function for a measurement, it will take a little longer as the cloud service will render the report. Once it's ready (~5s) the url where you can fetch it will be returned
  • 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 language of the user (this language is specified during register-a-new-user)
import client from '@fibricheck/javascript-sdk';
import Pdf from 'react-native-pdf';
const sdk = client({
consumerKey: '',
consumerSecret: '',
});
await sdk.authenticate({
token: '',
tokenSecret: '',
});
const measurementId = '0000';
const App = () => {
const [uri, setUri] = useState();
useEffect(() => {
(async () => {
const uri = await sdk.getReportUrl(measurementId);
setUri(uri);
})();
}, []);
return (
<Pdf
source={{
uri,
}}
/>
);
};

Request all periodic reports

The sdk.getPeriodicReports method will retrieve all your periodic reports.
Flutter
React Native
  • Using sdk.getPeriodicReports will return a paginated result with all periodicReports for the currently authenticated user. You can find the measurements under the data property. You can also use the next and previous functions present on the result to navigate through the user's measurents.
  • In the periodic reports, the trigger field indicates for which period the report was made (7 days, 30 days or at the end of a prescription)
⚠️ To use this functionality, @babel/plugin-proposal-async-generator-functions is required. This plugin is included in @babel/preset-env.
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
  • This 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)
  • In the periodic reports, the trigger field indicates for which period the report was made (7 days, 30 days or at the end of a prescription)
⚠️ To use this functionality, @babel/plugin-proposal-async-generator-functions is required. This plugin is included in @babel/preset-env.
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> */
}

Request a periodic report in PDF-format

The sdk.getPeriodicReportPdf method will retrieve a pdf-version of the periodic report.
Flutter
React Native
import 'package:flutter_fibricheck_sdk/flutter_fibricheck_sdk.dart';
await a_sdk.getPeriodicReportPdf(reportId);
  • This method takes the reportId as a parameter.
  • The pdf will always be rendered in the language of the user (this language is specified during register-a-new-user)
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,
});