123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import 'dart:convert';
- import 'package:fis_common/logger/logger.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:vitalapp/managers/interfaces/prescription.dart';
- import 'package:vitalapp/rpc.dart';
- import 'package:vitalapp/store/store.dart';
- class PrescriptionManager implements IPrescriptionManager {
- PrescriptionManager();
- @override
- Future<String?> createPrescription({
- required String patientCode,
- required String prescriptionKey,
- String? physicalExamNumber,
- String? followUpCode,
- String? prescriptionData,
- }) async {
- try {
- CreatePrescriptionRequest request = CreatePrescriptionRequest(
- patientCode: patientCode,
- physicalExamNumber: physicalExamNumber,
- followUpCode: followUpCode,
- prescriptionData: prescriptionData,
- key: prescriptionKey,
- token: Store.user.token,
- );
- print(jsonEncode(request.toJson()));
- logger.i(
- "PrescriptionManager updatePrescription request:${jsonEncode(request.toJson())}.",
- );
- String prescriptionCode =
- await rpc.vitalPrescription.createPrescriptionAsync(request);
- return prescriptionCode;
- } catch (e) {
- logger.e("createPrescription error.", e);
- return null;
- }
- }
- @override
- Future<PrescriptionDTO?> getPrescriptionDetailByFollowAnPatient({
- required String patientCode,
- String? followUpCode,
- }) async {
- try {
- GetPrescriptionDetailByFollowAnPatientRequest request =
- GetPrescriptionDetailByFollowAnPatientRequest(
- token: Store.user.token,
- followUpCode: followUpCode,
- patientCode: patientCode,
- );
- PrescriptionDTO? prescription = await rpc.vitalPrescription
- .getPrescriptionDetailByFollowAnPatientAsync(request);
- return prescription;
- } catch (e) {
- logger.e("getPrescriptionDetailByFollowAnPatient error.", e);
- return null;
- }
- }
- @override
- Future<List<PrescriptionDTO>?> getPrescriptionPage({
- required String patientCode,
- String? physicalExamNumber,
- String? followUpCode,
- }) async {
- try {
- PrescriptionPageRequest request = PrescriptionPageRequest(
- token: Store.user.token,
- physicalExamNumber: physicalExamNumber,
- followUpCode: followUpCode,
- patientCode: patientCode,
- pageIndex: 1,
- pageSize: 1000,
- );
- PageCollection<PrescriptionDTO> prescription =
- await rpc.vitalPrescription.getPrescriptionPageAsync(request);
- return prescription.pageData;
- } catch (e) {
- logger.e("getPrescriptionPage error.", e);
- return null;
- }
- }
- @override
- Future<bool?> updatePrescription({
- required String patientCode,
- required String prescriptionKey,
- required String prescriptionCode,
- String? physicalExamNumber,
- String? followUpCode,
- String? prescriptionData,
- }) async {
- try {
- UpdatePrescriptionRequest request = UpdatePrescriptionRequest(
- patientCode: patientCode,
- physicalExamNumber: physicalExamNumber,
- followUpCode: followUpCode,
- prescriptionData: prescriptionData,
- key: prescriptionKey,
- code: prescriptionCode,
- token: Store.user.token,
- );
- logger.i(
- "PrescriptionManager updatePrescription request:${jsonEncode(request.toJson())}.",
- );
- bool result =
- await rpc.vitalPrescription.updatePrescriptionAsync(request);
- return result;
- } catch (e) {
- logger.e("createPrescription error.", e);
- return null;
- }
- }
- @override
- Future<bool?> removePrescription({
- required String prescriptionCode,
- }) async {
- try {
- RemovePrescriptionRequest request = RemovePrescriptionRequest(
- code: prescriptionCode,
- token: Store.user.token,
- );
- bool result =
- await rpc.vitalPrescription.removePrescriptionAsync(request);
- return result;
- } catch (e) {
- logger.e("removePrescription error.", e);
- return null;
- }
- }
- }
|