123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:vitalapp/managers/interfaces/contract.dart';
- import 'package:vitalapp/rpc.dart';
- import 'package:vitalapp/store/store.dart';
- class ContractManager implements IContractManager {
- @override
- Future<String?> createContractRecordAsync(
- CreateContractRecordRequest request) async {
- try {
- request.token = Store.user.token;
- final result =
- await rpc.contractRecord.createContractRecordAsync(request);
- return result;
- } catch (e) {
- // logger.e("PatientManager create patient error.", e);
- return null;
- }
- }
- @override
- Future<PageCollection<ContractRecordDTO>?>
- getContractRecordPageByPatientCodeAsync(String patientCode) async {
- try {
- final result = await rpc.contractRecord
- .getContractRecordPageByPatientCodeAsync(
- GetContractRecordPageByPatientCodeRequest(
- patientCode: patientCode,
- token: Store.user.token,
- pageSize: 20,
- pageIndex: 1));
- return result;
- } catch (e) {
- return null;
- }
- }
- @override
- Future<PageCollection<ContractRecordDTO>?>
- getContractRecordPageAsync() async {
- try {
- final result = await rpc.contractRecord.getContractRecordPageAsync(
- ContractRecordPageRequest(
- token: Store.user.token, pageSize: 20, pageIndex: 1));
- return result;
- } catch (e) {
- return null;
- }
- }
- @override
- Future<ContractRecordDTO?> getContractRecordDetailAsync(
- String patientCode) async {
- try {
- var request = GetContractRecordRequest(
- code: patientCode,
- token: Store.user.token,
- );
- final result =
- await rpc.contractRecord.getContractRecordDetailAsync(request);
- return result;
- } catch (e) {
- return null;
- }
- }
- @override
- Future<bool> updateContractRecordStateAsync(
- String? code, ContractStateEnum? contractState, String? reason) async {
- try {
- var request = UpdateContractRecordStateRequest(
- code: code,
- contractState: contractState,
- reason: reason,
- token: Store.user.token,
- );
- final result =
- await rpc.contractRecord.updateContractRecordStateAsync(request);
- return result;
- } catch (e) {}
- return false;
- }
- @override
- Future<bool> removeContractRecordAsync(String code) async {
- try {
- var request = RemoveContractRecordRequest(
- code: code,
- token: Store.user.token,
- );
- final result =
- await rpc.contractRecord.removeContractRecordAsync(request);
- return result;
- } catch (e) {}
- return false;
- }
- @override
- Future<String> renewalContractRecordAsync(String code) async {
- try {
- var request = RenewalContractRecordRequest(
- token: Store.user.token,
- code: code,
- serviceStartDate: DateTime.now(),
- serviceEndDate: DateTime.now().add(const Duration(days: 365)),
- );
- final result =
- await rpc.contractRecord.renewalContractRecordAsync(request);
- return result;
- } catch (e) {}
- return "";
- }
- }
|