123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import 'package:fis_common/event/event_type.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flutter/material.dart';
- import 'package:vitalapp/database/db.dart';
- import 'package:vitalapp/database/entities/defines.dart';
- import 'package:vitalapp/managers/interfaces/follow_up.dart';
- import 'package:vitalapp/rpc.dart';
- import 'package:vitalapp/store/store.dart';
- import 'package:fis_common/logger/logger.dart';
- class FollowUpManager implements IFollowUpManager {
- @override
- Future<String> createFollowUp(CreateFollowUpRequest examRequest) async {
- try {
- examRequest.token = Store.user.token;
- final examCode = await rpc.vitalFollowUp.createFollowUpAsync(
- examRequest,
- );
- return examCode;
- } catch (e) {
- logger.e("FollowUpManager createFollowUp error.", e);
- return '';
- }
- }
- @override
- Future<bool?> updateFollowUp(UpdateFollowUpRequest followRequest) async {
- try {
- followRequest.token = Store.user.token;
- final result = await rpc.vitalFollowUp.updateFollowUpAsync(
- followRequest,
- );
- return result;
- } catch (e) {
- logger.e("FollowUpManager updateFollowUp error.", e);
- return null;
- }
- }
- @override
- Future<bool> removeFollowUpAsync(String code, String key) async {
- try {
- final result = await rpc.vitalFollowUp.removeFollowUpAsync(
- RemoveFollowUpRequest(
- key: key,
- code: code,
- token: Store.user.token,
- ),
- );
- return result;
- } catch (e) {
- logger.e("FollowUpManager removeFollowUpAsync error.", e);
- }
- return false;
- }
- @override
- Future<List<FollowUpDTO>?> getFollowUpPage(
- FollowUpPageRequest followUpPageRequest) async {
- try {
- followUpPageRequest.token = Store.user.token;
- final result = await rpc.vitalFollowUp.getFollowUpPageAsync(
- followUpPageRequest,
- );
- return result.pageData;
- } catch (e) {
- logger.e("FollowUpManager getFollowUpPage error.", e);
- return null;
- }
- }
- @override
- Future<List<FollowUpRecordDTO>?> getFollowUpRecordList(
- List<String> keys, String patientCode) async {
- try {
- var request = GetFollowUpRecordListRequest(
- keys: keys,
- patientCode: patientCode,
- token: Store.user.token,
- );
- final result =
- await rpc.vitalFollowUp.getFollowUpRecordListAsync(request);
- return result;
- } catch (e) {
- return null;
- }
- }
- @override
- Future<List<FollowUpRecordDTO>?> getFollowUpRecordListByYearAsync(
- GetFollowUpRecordListByYearRequest
- followUpRecordListByYearRequest) async {
- try {
- followUpRecordListByYearRequest.token = Store.user.token;
- final result = await rpc.vitalFollowUp
- .getFollowUpRecordListByYearAsync(followUpRecordListByYearRequest);
- return result;
- } catch (e) {
- return null;
- }
- }
- Future<List<FollowUpRecordDTO>> getPatientNotUploadedRecordList(
- String patientCode, String key) async {
- final entities = await db.repositories.followUp.queryable
- .where(
- (x) => [
- x.isValid.equals(true),
- x.userCode.equals(Store.user.userCode),
- x.patientCode.equals(patientCode),
- x.typeKey.equals(key),
- x.syncState.notEquals(OfflineDataSyncState.success),
- ],
- )
- .toList();
- if (entities.isEmpty) {
- return [];
- }
- // 都放一个Record里
- final record = FollowUpRecordDTO();
- final patient = Store.user.currentSelectPatientInfo;
- record.patientName = patient?.patientName ?? "";
- // record.contractedDoctor = patient?.contractedDoctorName ?? "";
- record.contractedDoctor = entities.first.contractDoctor;
- record.followUpRecordDatas = entities
- .map(
- (e) => FollowUpRecordDataDTO(
- code: e.code,
- templateCode: e.templateCode,
- key: e.typeKey,
- followUpDoctor: e.contractDoctor,
- followUpState: FollowUpStateEnum.FollowUpVisit,
- followUpMode: e.mode,
- followUpTime: e.followUpTime,
- nextFollowUpTime: e.nextFollowUpTime,
- followUpPhotos: e.followUpPhtots,
- followUpData: e.dataJson,
- ),
- )
- .toList();
- return [record];
- }
- MaterialColor followUpStateColors(FollowUpStateEnum state) {
- switch (state) {
- case FollowUpStateEnum.NoFollowUp:
- return Colors.grey;
- case FollowUpStateEnum.Cancelled:
- return Colors.red;
- case FollowUpStateEnum.FollowUpVisit:
- return Colors.green;
- default:
- return Colors.blue;
- }
- }
- String getFollowUpMode(FollowUpModeEnum? modeEnum) {
- switch (modeEnum) {
- case FollowUpModeEnum.Outpatient:
- return "门诊";
- case FollowUpModeEnum.Phone:
- return "电话";
- case FollowUpModeEnum.Visit:
- return "上门";
- default:
- return "";
- }
- }
- String followUpStateTransition(FollowUpStateEnum state) {
- switch (state) {
- case FollowUpStateEnum.NoFollowUp:
- return "未随访";
- case FollowUpStateEnum.FollowUpVisit:
- return "已随访";
- case FollowUpStateEnum.Cancelled:
- return "已作废";
- default:
- return "";
- }
- }
- final FEventHandler<String> onFollowMedicalData = FEventHandler<String>();
- }
|