|
|
|
|
@ -1,7 +1,12 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
|
|
|
@ -9,6 +14,8 @@ import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/labo
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:open_filex/open_filex.dart';
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class LaboratoryResultPage extends StatefulWidget {
|
|
|
|
|
@ -80,6 +87,12 @@ class _LaboratoryResultPageState extends State<LaboratoryResultPage> {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user, isDownload: true);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
try {
|
|
|
|
|
String path = await _createFileFromString(model.labReportPDF, "pdf");
|
|
|
|
|
OpenFilex.open(path);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
AppToast.showErrorToast(message: "Cannot open file.");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
@ -91,6 +104,14 @@ class _LaboratoryResultPageState extends State<LaboratoryResultPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String> _createFileFromString(String encodedStr, String ext) async {
|
|
|
|
|
Uint8List bytes = base64.decode(encodedStr);
|
|
|
|
|
String dir = (await getApplicationDocumentsDirectory()).path;
|
|
|
|
|
File file = File("$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext);
|
|
|
|
|
await file.writeAsBytes(bytes);
|
|
|
|
|
return file.path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getSpecialResults(LabsViewModel model) {
|
|
|
|
|
String labResults = "";
|
|
|
|
|
model.patientLabSpecialResult.forEach((element) {
|
|
|
|
|
|