View medical report done

Dev_3.3_MedicalReportCR
haroon amjad 1 year ago
parent e4e3377c5c
commit 2455f48fe1

@ -184,6 +184,7 @@ var REPORTS = 'Services/Doctors.svc/REST/GetPatientMedicalReportStatusInfo';
var INSERT_REQUEST_FOR_MEDICAL_REPORT = 'Services/Doctors.svc/REST/InsertRequestForMedicalReport';
var SEND_MEDICAL_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendMedicalReportEmail';
var GET_INPATIENT_ADMISSIONS = 'Services/inps.svc/REST/getAdmissionForMedicalReport';
var GET_MEDICAL_REPORT_PDF = 'Services/inps.svc/REST/getMedicalReportPDF';
///Rate
// var IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated';

@ -177,4 +177,34 @@ class ReportsService extends BaseService {
}, body: body);
return response;
}
Future getMedicalReportPDF(String projectName, String clinicName, String doctorName, String requestDate, String invoiceNo, int projectID, String stamp, String setupID) async {
Map<String, dynamic> body = new Map<String, dynamic>();
body['SetupID'] = setupID;
body['PrintDate'] = requestDate;
body['ProcedureID'] = "05005009";
body['Reporttype'] = "MEDICAL REPORT";
body['stamp'] = stamp;
body['To'] = user.emailAddress;
body['DateofBirth'] = user.dateofBirth;
body['PatientIditificationNum'] = user.patientIdentificationNo;
body['PatientMobileNumber'] = user.mobileNumber;
body['PatientName'] = user.firstName + " " + user.lastName;
body['ProjectName'] = projectName;
body['ClinicName'] = clinicName;
body['ProjectID'] = projectID;
body['InvoiceNo'] = invoiceNo;
body['PrintedByName'] = user.firstName + " " + user.lastName;
dynamic response;
hasError = false;
await baseAppClient.post(GET_MEDICAL_REPORT_PDF, onSuccess: (dynamic res, int statusCode) {
response = res;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
return response;
}
}

@ -1,3 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/reports/Reports.dart';
import 'package:diplomaticquarterapp/core/service/medical/reports_service.dart';
@ -14,6 +18,8 @@ import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.d
import 'package:diplomaticquarterapp/widgets/my_rich_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart';
@ -111,10 +117,22 @@ class ReportListWidget extends StatelessWidget {
if (reportList[index].status == 2)
Row(
children: [
Padding(
InkWell(
onTap: () {
getMedicalReportPDF(report);
},
child: Padding(
padding: const EdgeInsets.only(right: 11.0, left: 11.0),
child: Text(TranslationBase.of(context).viewReport,
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, fontStyle: FontStyle.italic, color: CustomColors.accentColor, letterSpacing: -0.48, height: 18 / 12, decoration: TextDecoration.underline)),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.italic,
color: CustomColors.accentColor,
letterSpacing: -0.48,
height: 18 / 12,
decoration: TextDecoration.underline)),
),
),
IconButton(
icon: Icon(Icons.email),
@ -155,6 +173,26 @@ class ReportListWidget extends StatelessWidget {
);
}
void getMedicalReportPDF(Reports report) {
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
ReportsService _reportsService = locator<ReportsService>();
_reportsService
.getMedicalReportPDF(report.projectName, report.clinicDescription, report.doctorName, DateUtil.convertDateToString(report.requestDate), report.invoiceNo.toString(), report.projectID,
DateUtil.convertDateToString(report.requestDate), report.setupId)
.then((value) async {
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
try {
String path = await _createFileFromString(value["MedicalReportBase64"], "pdf");
OpenFile.open(path);
} catch (ex) {
AppToast.showErrorToast(message: "Cannot open file.");
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
print(err);
});
}
sendReportEmail(Reports report) {
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
ReportsService _reportsService = locator<ReportsService>();
@ -169,4 +207,12 @@ class ReportListWidget extends StatelessWidget {
print(err);
});
}
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;
}
}

@ -207,6 +207,8 @@ dependencies:
sms_otp_auto_verify: ^2.1.0
flutter_ios_voip_kit: ^0.0.5
google_api_availability: ^3.0.1
open_file: ^3.2.1
path_provider: ^2.0.8
# flutter_callkit_incoming: ^1.0.3+3
# firebase_core: 1.12.0

Loading…
Cancel
Save