123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- import 'package:fis_common/helpers/encrypt.dart';
- import 'package:fis_common/index.dart';
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flyinsonolite/jsonrpc/fisLib/services/log.m.dart';
- import 'package:flyinsonolite/jsonrpc/jsonrpcclient.dart';
- import 'package:flyinsonolite/infrastructure/logger.dart';
- import 'package:flyinsonolite/managers/basemanager.dart';
- import 'package:flyinsonolite/managers/interfaces/iappointmentmanager.dart';
- import 'package:flyinsonolite/consultation/records/models/appointmentinformation.dart';
- import 'package:flyinsonolite/infrastructure/storage.dart';
- class AppointmentManager extends BaseManager implements IAppointmentManager {
- @override
- Future<PageResult<ConsultationPageDTO>> findConsultationsByPageAsync(
- ConsultationQueryTypeEnum consultationQueryType,
- int pageIndex,
- int pageSize,
- {String? keyword,
- DateTime? startDate,
- DateTime? endDate,
- QueryConsultationStatusEnum? consultationStatus,
- QueryEvaluateGradeEnum? evaluateGrade,
- String? language,
- List<String>? expertCodes,
- List<String>? applyOrganizationCodes,
- List<String>? expertOrganizationCodes,
- String? patientSex,
- String? patientDiseases,
- String? patientPrimaryDiagnosis,
- QueryPatientAgeLimitDTO? patientAgeLimit}) async {
- return await jsonRpcProxy.liveConsultation.findConsultationsByPageAsync(
- FindConsultationByPageRequest(
- token: token,
- pageIndex: pageIndex,
- pageSize: pageSize,
- consultationQueryType: consultationQueryType,
- keyword: keyword,
- startDate: startDate,
- endDate: endDate,
- language: language,
- expertCodes: expertCodes,
- patientSex: patientSex,
- patientAgeLimit: patientAgeLimit,
- patientDiseases: patientDiseases,
- patientPrimaryDiagnosis: patientPrimaryDiagnosis,
- applyOrganizationCodes: applyOrganizationCodes,
- expertOrganizationCodes: expertOrganizationCodes,
- consultationStatus:
- consultationStatus ?? QueryConsultationStatusEnum.All,
- evaluateGrade: evaluateGrade ?? QueryEvaluateGradeEnum.All,
- ),
- );
- }
- /// 查询会诊详情
- @override
- Future<ConsultationDetailDTO?> findConsultationDetailAsync(
- String consultationCode) async {
- try {
- final result =
- await jsonRpcProxy.liveConsultation.findConsultationDetailAsync(
- FindConsultationDetailRequest(
- token: token,
- consultationCode: consultationCode,
- ),
- );
- result.consultationTime =
- result.consultationTime?.toLocal() ?? DateTime.now();
- return result;
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- "AppointmentManager findConsultationDetailAsync exception: $e");
- return null;
- }
- }
- ///获取会诊随访信息
- @override
- Future<List<FollowUpVisitDTO>> getFollowUpVisitInfo(
- String currentConsultationCode) async {
- try {
- var result =
- await jsonRpcProxy.liveConsultation.getFollowUpVisitInfoAsync(
- GetFollowUpVisitInfoRequest(
- token: token,
- consultationRecordCode: currentConsultationCode,
- ),
- );
- return result;
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager getFollowUpVisitInfo ex:$e');
- return [];
- }
- }
- ///获取病人列表
- @override
- Future<PageResult<ClientPatientInfoBaseDTO>> findConsultationPatientAsync(
- String? keyword, int pageIndex, int pageSize) async {
- return await jsonRpcProxy.liveConsultation.findConsultationPatientAsync(
- FindConsultationPatientPageRequest(
- token: token,
- keyword: keyword,
- pageIndex: pageIndex,
- pageSize: pageSize,
- ),
- );
- }
- ///创建病人
- @override
- Future<ClientPatientInfoBaseDTO?> createPatientByUnregisteredAsync(
- String patientName) async {
- final name = FEncryptHelper.encodeBase64(patientName);
- var result = await jsonRpcProxy.patient.createUnregisteredPatientAsync(
- CreatePatientByUnregisteredRequest(
- token: token,
- patientName: name,
- ),
- );
- if (result.isNotEmpty) {
- return await jsonRpcProxy.patient.findPatientByCodeAsync(
- FindPatientByCodeRequest(code: result, token: token));
- }
- return null;
- }
- ///获取用户名下所有设备
- @override
- Future<PageCollection<DeviceInfoDTO>> getDeviceListByPersonRoleAsync() async {
- try {
- return await jsonRpcProxy.device.getDeviceListByPersonRoleAsync(
- GetPersonRoleDeviceRequest(
- token: token, pageIndex: 1, pageSize: 1000));
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager getDeviceListByPersonRoleAsync ex:$e');
- }
- return PageCollection();
- }
- ///获取扫查医生
- @override
- Future<List<UserExtendDTO>> getScanDoctorsAsync() async {
- try {
- return await jsonRpcProxy.user.getUserListAsync(
- GetUserListRequest(
- token: token,
- organizationCode: Storage.user.organizationCode,
- organizationQueryType: OrganizationQueryTypeEnum.All,
- roleCodes: [RoleType.certifiedExpert, RoleType.certifiedPhysician]),
- );
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager getScanDoctorsAsync ex:$e');
- }
- return [];
- }
- ///获取扫查部位
- @override
- Future<List<String>> getScanPositionsAsync() async {
- try {
- return await jsonRpcProxy.liveConsultation.findScanPositionsAsync(
- TokenRequest(
- token: token,
- ),
- );
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager getScanPositionsAsync ex:$e');
- }
- return [];
- }
- /// 获取会诊机构
- @override
- Future<List<OrganizationBaseDTO>> findParentOrganizationsAsync() async {
- try {
- return await jsonRpcProxy.liveConsultation.findParentOrganizationsAsync(
- FindHigherOrganizationsRequest(
- token: token,
- ),
- );
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager findParentOrganizationsAsync ex:$e');
- }
- return [];
- }
- ///获取会诊专家
- @override
- Future<PageResult<OrganizationExpertDTO>> findOrganizationExpertsAsync(
- String organizationCode) async {
- try {
- return await jsonRpcProxy.liveConsultation.findOrganizationExpertsAsync(
- FindOrganizationExpertsRequest(
- token: token,
- organizationCode: organizationCode,
- pageIndex: 1,
- pageSize: 1000));
- } catch (ex) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager findOrganizationExpertsAsync ex:$ex');
- }
- return PageResult();
- }
- ///获取申请人列表
- @override
- Future<List<OrganizationExpertDTO>> findAssistantExpertsAsync() async {
- try {
- return await jsonRpcProxy.liveConsultation.findAssistantExpertsAsync(
- FindAssistantExpertsRequest(
- token: token,
- ),
- );
- } catch (ex) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager findAssistantExpertsAsync ex:$ex');
- }
- return [];
- }
- //创建会诊
- @override
- Future<String> applyConsultationAsync(
- String? patientCode,
- AppointmentInformation appointmentInformation,
- List<DataItemDTO>? patientDatas) async {
- return await jsonRpcProxy.liveConsultation
- .applyConsultationAsync(ApplyConsultationRequest(
- token: token,
- expertUserCode: appointmentInformation.appointmentCompetentExperts,
- deviceCode: appointmentInformation.appointmentDevice,
- scanPositions: appointmentInformation.appointmentScanningPosition,
- consultationTime: appointmentInformation.appointmentTime!.toUtc(),
- patientCode: patientCode,
- diseases: appointmentInformation.appointmentDiseaseName,
- scanUserCode: appointmentInformation.appointmentScanDoctor,
- expertOrganizationCode:
- appointmentInformation.appointmentConsultationInstitution,
- applyUserCode: appointmentInformation.appointmentApplicant,
- primaryDiagnosis: appointmentInformation.preliminaryDiagnosis,
- patientDatas: patientDatas, // 申请预约单的病人数据
- ));
- }
- //修改会诊
- @override
- Future<bool> updateConsultationAsync(String? consultationCode,
- AppointmentInformation appointmentInformation) async {
- return await jsonRpcProxy.liveConsultation.updateConsultationAsync(
- UpdateConsultationRequest(
- token: token,
- expertUserCode: appointmentInformation.appointmentCompetentExperts,
- deviceCode: appointmentInformation.appointmentDevice,
- scanPositions: appointmentInformation.appointmentScanningPosition,
- consultationTime: appointmentInformation.appointmentTime!.toUtc(),
- diseases: appointmentInformation.appointmentDiseaseName,
- scanUserCode: appointmentInformation.appointmentScanDoctor,
- expertOrganizationCode:
- appointmentInformation.appointmentConsultationInstitution,
- applyUserCode: appointmentInformation.appointmentApplicant,
- primaryDiagnosis: appointmentInformation.preliminaryDiagnosis,
- consultationCode: consultationCode,
- ),
- );
- }
- //完善会诊, 急诊创建的会诊单需要完善,其他不需要
- @override
- Future<bool> improveConsultationInfoAsync(
- String? patientCode,
- String? consultationCode,
- AppointmentInformation appointmentInformation,
- List<DataItemDTO>? patientDatas) async {
- return await jsonRpcProxy.liveConsultation
- .improveConsultationInfoAsync(ImproveConsultationInfoRequest(
- consultationCode: consultationCode,
- patientCode: patientCode,
- scanPositions: appointmentInformation.appointmentScanningPosition,
- diseases: appointmentInformation.appointmentDiseaseName,
- primaryDiagnosis: appointmentInformation.preliminaryDiagnosis,
- patientDatas: patientDatas,
- token: token,
- ));
- }
- //撤回会诊
- @override
- Future<bool> withdrawConsultationAsync(String? consultationCode) async {
- return await jsonRpcProxy.liveConsultation.revokeConsultationAsync(
- RevokeConsultationRequest(
- token: token,
- consultationCode: consultationCode,
- ),
- );
- }
- //拒绝会诊
- @override
- Future<bool> refuseConsultationAsync(
- String? consultationCode, String? reason) async {
- return await jsonRpcProxy.liveConsultation.rejectApplyConsultationAsync(
- RejectApplyConsultationRequest(
- token: token, consultationCode: consultationCode, reason: reason),
- );
- }
- //接收/拒绝加入会诊
- @override
- Future<bool> acceptInvitationAsync(
- String? consultationCode, bool isAgree, String? reason) async {
- return await jsonRpcProxy.liveConsultation.acceptInvitationAsync(
- AcceptInvitationRequest(
- token: token,
- consultationRecordCode: consultationCode,
- refusalCause: reason,
- isAgree: isAgree,
- ),
- );
- }
- ///获取用户信息,用于获取助理医师信息
- @override
- Future<UserInfoByCodeDTO> getUserByCodeAsync(String? userCode) async {
- return await jsonRpcProxy.user.getUserByCodeAsync(
- GetUserByCodeRequest(token: token, userCode: userCode));
- }
- ///审批同意会诊申请
- @override
- Future<bool> approveConsultationAsync(
- ApproveConsultationInfo approveConsultationInfo) async {
- return await jsonRpcProxy.liveConsultation.approvalConsultationAsync(
- ApprovalConsultationRequest(
- token: token,
- consultationCode: approveConsultationInfo.consultationCode,
- expertUserCode: approveConsultationInfo.competentExperts,
- consultationTime: approveConsultationInfo.startTime!.toUtc(),
- consultationTimeEnd: approveConsultationInfo.endTime!.toUtc(),
- consultationMemberCodes: approveConsultationInfo.participants,
- description: approveConsultationInfo.description,
- consultationReminders: approveConsultationInfo.consultationReminders,
- location: "",
- ),
- );
- }
- //会诊中添加时排除已存在的用户
- @override
- Future<List<UserExtendDTO>> getInviteableUserListAsyn(
- String consultationCode, String organizationCode) async {
- return await jsonRpcProxy.liveConsultation.getInviteableUserListAsync(
- GetInviteableUserListRequest(
- token: token,
- language: i18nBook.locale.toCodeString('-'),
- consultationCode: consultationCode,
- organizationCode: organizationCode,
- ),
- );
- }
- @override
- Future<List<ConsultationImagesDTO>> getConsultationImagesAsync(
- String consultationCode) async {
- try {
- if (consultationCode.isEmpty) {
- return [];
- }
- var realTimeConsultationImageList =
- await jsonRpcProxy.liveConsultation.getConsultationFilesAsync(
- FindConsultationDetailRequest(
- consultationCode: consultationCode, token: token),
- );
- return realTimeConsultationImageList;
- } catch (e) {
- await loggerAsyn(FISDeviceLogCategory.Error,
- 'AppointmentManager getConsultationImagesAsync ex:$e');
- }
- return [];
- }
- @override
- List<DataItemDTO> getPatientDatas(Map<String, String> patient) {
- List<DataItemDTO> patientDatas = [];
- patient.forEach((key, value) {
- if (key == 'Phone' ||
- key == 'Name' ||
- key == 'IdentityCard' ||
- key == 'InsuranceCode' ||
- key == 'AnimalInfoName' ||
- key == 'AnimalInfoPhone' ||
- key == 'AnimalInfoIdentityCard') {
- value = FEncryptHelper.encodeBase64(value);
- }
- if (value.isNotNullOrWhiteSpace) {
- patientDatas.add(DataItemDTO(
- key: key,
- value: value,
- ));
- }
- });
- return patientDatas;
- }
- }
- ///角色类型
- class RoleType {
- static String generalUser = "Role_GeneralUser"; //普通用户
- static String internshipDoctor = "Role_InternshipDoctor"; //实习医生
- static String expertAssistant = "Role_ExpertAssistant"; //专家助理
- static String certifiedPhysician = "Role_CertifiedPhysician"; //认证医师
- static String certifiedExpert = "Role_CertifiedExpert"; //认证专家
- }
|