123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922 |
- import 'dart:convert';
- import 'package:fis_common/event/event_type.dart';
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flyinsonolite/jsonrpc/jsonrpcclient.dart';
- import 'package:flyinsonolite/managers/basemanager.dart';
- import 'package:flyinsonolite/managers/interfaces/iappointmentmanager.dart';
- import 'package:flyinsonolite/managers/interfaces/iliveconsultationmanager.dart';
- import 'package:flyinsonolite/managers/interfaces/irtmpmockrtcmanager.dart';
- import 'package:flyinsonolite/consultation/records/models/consultationmember.dart';
- import 'package:flyinsonolite/consultation/records/models/liveconsultation.dart';
- import 'package:flyinsonolite/infrastructure/storage.dart';
- import 'package:flyinsonolite/notifications/handlers/acceptliveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/cancelinvitinginliveconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/cancelinvitinginlivecoursenotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/cancelliveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/changeconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/closeLiveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/closeconsultationduetochangenotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/consultationanswertimeouthandler.dart';
- import 'package:flyinsonolite/notifications/handlers/emergencycallnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/heartRatejoinconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/heartrateleaveconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/inviteinliveconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/inviteliveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/joininliveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/joinliveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/leaveconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/muteliveconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/networkerrconsultationnotificationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/rejectinviteliveconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/rejectliveconsultationhandler.dart';
- import 'package:flyinsonolite/notifications/handlers/sendinteractiveboarddatahandler.dart';
- import 'package:flyinsonolite/notifications/handlers/switchvideoplayconsultationhandler.dart';
- import 'package:get/get.dart';
- class LiveConsultationManager extends BaseManager
- implements ILiveConsultationManager {
- @override
- late ConsultationDetailDTO consultationDetail;
- ///急诊的时候用到
- @override
- late LiveConsultation liveConsultation;
- @override
- late String currentConsultationCode = "";
- /// 白板数据接收
- @override
- FEventHandler<String> onWhiteboardDataReceive = FEventHandler<String>();
- ///开始会诊通知事件 11
- @override
- FEventHandler<LiveConsultation> onInviteLiveConsultation =
- FEventHandler<LiveConsultation>();
- ///会诊过程中邀请成员的通知(通知被邀请者) 8
- @override
- final FEventHandler<LiveConsultation> onInviteeInLiveConsultation =
- FEventHandler<LiveConsultation>();
- ///取消会诊过程中邀请成员的通知(通知被邀请者) 7
- @override
- final FEventHandler<LiveConsultation> onCancelInvitingConsultation =
- FEventHandler<LiveConsultation>();
- ///邀请者接受会诊通知事件(通知发起者)12
- @override
- final FEventHandler<LiveConsultation> onAcceptConsultation =
- FEventHandler<LiveConsultation>();
- ///邀请者拒绝会诊事件(通知发起者) 13
- @override
- final FEventHandler<LiveConsultation> onRejectConsultation =
- FEventHandler<LiveConsultation>();
- ///邀请者取消接听会诊事件(通知发起者) 7
- @override
- final FEventHandler<LiveConsultation> onCancelConsultation =
- FEventHandler<LiveConsultation>();
- ///关闭会诊事件(通知所有成员) 16
- @override
- final FEventHandler<LiveConsultation> onCloseConsultation =
- FEventHandler<LiveConsultation>();
- //成员加入会诊事件(通知所有成员)-
- @override
- FEventHandler<LiveConsultation> onAcceptLiveConsultation =
- FEventHandler<LiveConsultation>();
- ///成员加入会诊事件(通知所有成员)
- @override
- final FEventHandler<LiveConsultation> onJoinConsultation =
- FEventHandler<LiveConsultation>();
- ///成员加入会诊事件(通知所有成员) 被邀请者进入房间通知
- @override
- final FEventHandler<LiveConsultation> onJoinInConsultation =
- FEventHandler<LiveConsultation>();
- ///成员离开会诊事件(通知所有成员)19
- @override
- final FEventHandler<LiveConsultation> onLeaveConsultation =
- FEventHandler<LiveConsultation>();
- ///某个成员网络不佳通知事件(通知所有成员) 18
- @override
- final FEventHandler<LiveConsultation> onNetworkErrConsultation =
- FEventHandler<LiveConsultation>();
- /// 68 取消呼叫 to 客户端
- @override
- FEventHandler<CancelInvitingInLiveCourseNotification>
- onCancelInvitingInLiveCourseNotification =
- FEventHandler<CancelInvitingInLiveCourseNotification>();
- ///开启会诊事件
- @override
- FEventHandler<LiveConsultation> onStartLiveConsultation =
- FEventHandler<LiveConsultation>();
- //成员静音通知
- @override
- final FEventHandler<ConsultationMember> onMemberMute =
- FEventHandler<ConsultationMember>();
- //成员视频关闭与否通知
- @override
- final FEventHandler<ConsultationMember> onSwitchVideoPlay =
- FEventHandler<ConsultationMember>();
- ///会诊间改变
- @override
- final FEventHandler<LiveConsultation> onChangeConsultation =
- FEventHandler<LiveConsultation>();
- ///会诊间改变,成员不在新的会诊间,需退出
- @override
- FEventHandler<LiveConsultation> onCloseConsultationDueToChange =
- FEventHandler<LiveConsultation>();
- LiveConsultationManager() {
- // 互动白板数据通知
- var sendInteractiveBoardDataHandler =
- Get.find<SendInteractiveBoardDataHandler>();
- sendInteractiveBoardDataHandler
- .subscribe(_onSendInteractiveBoardDataHandler);
- // 取消会诊过程中邀请成员的通知 7
- var cancelInvitingHandler =
- Get.find<CancelInvitingInLiveConsultationHandler>();
- cancelInvitingHandler.subscribe(_onCancelInvitingHandler);
- //会诊过程中邀请成员的通知 8
- var inviteInLiveConsulationHandler =
- Get.find<InviteInLiveConsultationHandler>();
- inviteInLiveConsulationHandler.subscribe(_onInviteInLiveHandler);
- //开始会诊的通知 11
- var inviteLiveConsultHandler =
- Get.find<InviteLiveConsultationNotificationHandler>();
- inviteLiveConsultHandler.subscribe(_onInviteLiveConsultHandler);
- //接受会诊的通知 12
- var acceptLiveConsultationHandler =
- Get.find<AcceptLiveConsultationNotificationHandler>();
- acceptLiveConsultationHandler.subscribe(_onAcceptLiveConsultationHandler);
- //拒绝会诊的通知 13
- var rejectLiveConsultationHandler =
- Get.find<RejectLiveConsultationHandler>();
- rejectLiveConsultationHandler.subscribe(_onRejectLiveConsultationHandler);
- //拒绝会诊的通知 21
- var rejectInviteLiveConsultationHandler =
- Get.find<RejectInviteLiveConsultationHandler>();
- rejectInviteLiveConsultationHandler
- .subscribe(_onRejectInviteLiveConsultationHandler);
- //取消会诊通知 15
- var cancelLiveConsultation =
- Get.find<CancelLiveConsultationNotificationHandler>();
- cancelLiveConsultation.subscribe(_onCancelLiveConsultation);
- //关闭会诊通知, 基层一直不接自动取消后会发送这个通知 16
- var closeLiveConsultHandler =
- Get.find<CloseLiveConsultationNotificationHandler>();
- closeLiveConsultHandler.subscribe(_onCloseLiveConsultHandler);
- // 进入会诊通知 17
- var joinLiveConsultHandler =
- Get.find<JoinLiveConsultationNotificationHandler>();
- joinLiveConsultHandler.subscribe(_onJoinLiveConsultHandler);
- //网络质量不佳会诊通知 18
- var networkErrConsultationHandler =
- Get.find<NetworkErrConsultationNotificationHandler>();
- networkErrConsultationHandler.subscribe(_onNetworkErrConsultationHandler);
- //离开会诊通知 19
- var leaveConsultationHandler =
- Get.find<LeaveConsultationNotificationHandler>();
- leaveConsultationHandler.subscribe(_onleaveConsultationHandler);
- //20 邀请的成员加入会诊
- var joinInHandler = Get.find<JoinInLiveConsultationNotificationHandler>();
- joinInHandler.subscribe(_onJoinInLiveConsultationHandler);
- //成员静音通知 27
- var muteLiveConsultationHandler = Get.find<MuteLiveConsultationHandler>();
- muteLiveConsultationHandler.subscribe(_onMuteLiveConsultationHandler);
- //成员启用或关闭摄像头通知 28
- var switchVideoPlayConsultationHandler =
- Get.find<SwitchVideoPlayConsultationHandler>();
- switchVideoPlayConsultationHandler
- .subscribe(_onSwitchVideoPlayConsultationHandler);
- ///心跳加入
- var heartRateJoinConsultationHandler =
- Get.find<HeartRateJoinConsultationHandler>();
- heartRateJoinConsultationHandler
- .subscribe(_onHeartRateJoinConsultationHandler);
- //成员心跳断开离开 30
- var heartRateLeaveConsultationHandler =
- Get.find<HeartRateLeaveConsultationHandler>();
- heartRateLeaveConsultationHandler
- .subscribe(_onHeartRateLeaveConsultationHandler);
- //切换房间,但成员需离开
- var closeConsultationDueToChangeNotificationHandler =
- Get.find<CloseConsultationDueToChangeNotificationHandler>();
- closeConsultationDueToChangeNotificationHandler
- .subscribe(_onCloseConsultationDueToChangeHandler);
- //切换房间,但成员需离开
- var changeConsultationNotification =
- Get.find<ChangeConsultationNotificationHandler>();
- changeConsultationNotification.subscribe(_onChangeConsultationHandler);
- ///急诊呼叫专家通知 37
- var emergencyCallNotificationHandler =
- Get.find<EmergencyCallNotificationHandler>();
- emergencyCallNotificationHandler
- .subscribe(_onEmergencyCallNotificationHandler);
- ///呼叫超时
- var consultationAnswerTimeoutHandler =
- Get.find<ConsultationAnswerTimeoutHandler>();
- consultationAnswerTimeoutHandler.subscribe(_onAnswerTimeoutHandler);
- /// 取消呼叫 to 客户端 68
- var cancelInvitingInLiveCourseNotificationHandler =
- Get.find<CancelInvitingInLiveCourseNotificationHandler>();
- cancelInvitingInLiveCourseNotificationHandler
- .subscribe(_onCancelInvitingInLiveCourseNotificationHandler);
- }
- void _onInviteInLiveHandler(InviteInLiveConsultationNotification message) {
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- roomNo: message.roomNo,
- operator: message.operator,
- );
- consulation.consultationMemberConvert(message.memberLiveDatas ?? []);
- onInviteeInLiveConsultation.emit(
- this,
- consulation,
- );
- }
- void _onCancelInvitingHandler(
- CancelInvitingInLiveConsultationNotification message) {
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- userCode: message.userCodes!.first,
- );
- onCancelInvitingConsultation.emit(
- this,
- consulation,
- );
- }
- void _onEmergencyCallNotificationHandler(EmergencyCallNotification message) {
- var liveConsultation = LiveConsultation(
- consultationCode: message.consultationCode,
- roomNo: message.roomNo,
- );
- var initiator = message.initiator;
- if (initiator != null) {
- liveConsultation.memberLiveDatas.value = [
- ConsultationMember.fromDto(initiator)
- .fixMergedVideoOutputSize()
- .fixOnlyCamera()
- ];
- }
- onInviteLiveConsultation.emit(this, liveConsultation);
- }
- void _onAnswerTimeoutHandler(ConsultationAnswerTimeoutNotification message) {
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- userCode: message.userCode,
- );
- onCancelInvitingConsultation.emit(
- this,
- consulation,
- );
- }
- void _onCancelInvitingInLiveCourseNotificationHandler(
- CancelInvitingInLiveCourseNotification message) {
- var notification = message;
- onCancelInvitingInLiveCourseNotification.emit(
- this,
- notification,
- );
- }
- void _onleaveConsultationHandler(LeaveLiveConsultationNotification message) {
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- var leaverInfo = message.leaverInfo;
- if (leaverInfo != null) {
- consulation.memberLiveDatas.value = [
- ConsultationMember(
- id: leaverInfo.id,
- name: leaverInfo.name,
- headImageToken: leaverInfo.headImageUrl,
- )
- ];
- }
- onLeaveConsultation.emit(
- this,
- consulation,
- );
- }
- void _onChangeConsultationHandler(ChangeConsultationNotification message) {
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- roomNo: message.roomNo,
- );
- currentConsultationCode = message.consultationCode!;
- consulation.consultationMemberConvert(message.memberLiveDatas ?? []);
- onChangeConsultation.emit(this, consulation);
- }
- void _onCloseConsultationDueToChangeHandler(
- CloseConsultationDueToChangeNotification message) {
- onCloseConsultationDueToChange.emit(
- this, LiveConsultation(consultationCode: message.consultationCode));
- }
- void _onSendInteractiveBoardDataHandler(
- SendInteractiveBoardDataNotification message) {
- message.boardData;
- if (message.boardData != null) {
- if (message.isClear) {
- onWhiteboardDataReceive.emit(
- this, jsonEncode({'isClear': 'true', 'u_Id': message.userCode}));
- } else {
- onWhiteboardDataReceive.emit(this, message.boardData!);
- }
- }
- }
- void _onHeartRateJoinConsultationHandler(
- HeartRateJoinConsultationNotification message) {
- var accepter = message.joiner;
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- if (accepter != null) {
- consultation.memberLiveDatas.value = [
- ConsultationMember(
- isOnline: accepter.isOnline,
- mute: accepter.mute,
- liveData: accepter.liveData,
- id: accepter.id,
- name: accepter.name,
- headImageToken: accepter.headImageUrl,
- mergedChannel:
- accepter.consultationDeviceInfo?.mergedChannel ?? false,
- consultationDeviceInfo: accepter.consultationDeviceInfo,
- videoDeviceInfos:
- accepter.consultationDeviceInfo?.videoDeviceOutputList,
- isOldPlatform: accepter.isOldPlatform,
- supportRtc: accepter.supportRtc,
- mergedVideoOutputWidth:
- accepter.consultationDeviceInfo?.mergedVideoOutputWidth ?? 0,
- mergedVideoOutputHeight:
- accepter.consultationDeviceInfo?.mergedVideoOutputHeight ?? 0,
- ).fixMergedVideoOutputSize().fixOnlyCamera()
- ];
- }
- onJoinConsultation.emit(
- this,
- consultation,
- );
- }
- //会诊成员心跳断开离开
- void _onHeartRateLeaveConsultationHandler(
- HeartRateLeaveConsultationNotification message) {
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- var leaverInfo = message.leaverInfo;
- if (leaverInfo != null) {
- consulation.memberLiveDatas.value = [
- ConsultationMember(
- id: leaverInfo.id,
- name: leaverInfo.name,
- headImageToken: leaverInfo.headImageUrl,
- )
- ];
- Get.find<IRtmpMockRtcManager>().handleRemoteLeave(leaverInfo);
- }
- onLeaveConsultation.emit(
- this,
- consulation,
- );
- }
- void _onJoinLiveConsultHandler(JoinLiveConsultationNotification message) {
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- var joiner = message.joiner;
- if (joiner != null) {
- consultation.memberLiveDatas.value = [
- ConsultationMember(
- id: joiner.id,
- name: joiner.name,
- isOnline: joiner.isOnline,
- mute: joiner.mute,
- isInitiator: joiner.id == Storage.user.userCode,
- liveData: joiner.liveData,
- headImageToken: joiner.headImageUrl,
- index: joiner.sortNumber,
- )
- ];
- }
- onJoinConsultation.emit(
- this,
- consultation,
- );
- }
- void _onJoinInLiveConsultationHandler(
- JoinInLiveConsultationNotification message) {
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- var joiner = message.joiner;
- if (joiner != null) {
- consultation.memberLiveDatas.value = [
- ConsultationMember(
- id: joiner.id,
- name: joiner.name,
- isOnline: joiner.isOnline,
- mute: joiner.mute,
- isInitiator: joiner.isInitiator,
- liveData: joiner.liveData,
- headImageToken: joiner.headImageUrl,
- sortLevel: joiner.sortLevel,
- )
- ];
- }
- onJoinInConsultation.emit(
- this,
- consultation,
- );
- }
- void _onMuteLiveConsultationHandler(
- MuteLiveConsultationNotification message) {
- var member = message.muterInfo;
- var memberId = '';
- if (member != null) {
- memberId = member.id ?? '';
- }
- Get.find<IRtmpMockRtcManager>().handleRemoteMuteAudio(
- memberId,
- message.mute,
- );
- onMemberMute.emit(
- this,
- ConsultationMember(mute: message.mute, id: memberId),
- );
- }
- void _onCloseLiveConsultHandler(
- CloseLiveConsultationNotification message) async {
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- initiatorCode: message.initiatorCode,
- );
- onCloseConsultation.emit(
- this,
- consultation,
- );
- }
- void _onRejectInviteLiveConsultationHandler(
- RejectInviteLiveConsultationNotification message) {
- var accepter = message.rejecter;
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- if (accepter != null) {
- consultation.memberLiveDatas.value = [
- ConsultationMember(
- id: accepter.id,
- name: accepter.name,
- headImageToken: accepter.headImageUrl,
- )
- ];
- }
- onRejectConsultation.emit(
- this,
- consultation,
- );
- }
- void _onAcceptLiveConsultationHandler(
- AcceptLiveConsultationNotification message) {
- var accepter = message.accepter;
- var consultation =
- LiveConsultation(consultationCode: message.consultationCode);
- if (accepter != null) {
- consultation.memberLiveDatas.value = [
- ConsultationMember(
- isOnline: accepter.isOnline,
- mute: accepter.mute,
- liveData: accepter.liveData,
- id: accepter.id,
- name: accepter.name,
- headImageToken: accepter.headImageUrl,
- )
- ];
- }
- onAcceptConsultation.emit(
- this,
- consultation,
- );
- }
- void _onRejectLiveConsultationHandler(
- RejectLiveConsultationNotification message) async {
- var accepter = message.rejecter;
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- if (accepter != null) {
- consultation.memberLiveDatas.value = [
- ConsultationMember(
- id: accepter.id,
- name: accepter.name,
- headImageToken: accepter.headImageUrl,
- )
- ];
- }
- onRejectConsultation.emit(
- this,
- consultation,
- );
- }
- void _onInviteLiveConsultHandler(InviteLiveConsultationNotification message) {
- var liveConsultation = LiveConsultation(
- consultationCode: message.consultationCode,
- roomNo: message.roomNo,
- );
- var initiator = message.initiator;
- if (initiator != null) {
- liveConsultation.memberLiveDatas.value = [
- ConsultationMember.fromDto(initiator)
- .fixMergedVideoOutputSize()
- .fixOnlyCamera()
- ];
- }
- onInviteLiveConsultation.emit(this, liveConsultation);
- }
- void _onCancelLiveConsultation(CancelLiveConsultationNotification message) {
- var consultation = LiveConsultation(
- consultationCode: message.consultationCode,
- initiatorCode: message.initiatorCode,
- );
- onCancelConsultation.emit(
- this,
- consultation,
- );
- }
- void _onSwitchVideoPlayConsultationHandler(
- SwitchLiveConsultationVideoNotification message) {
- var member = message.switcherInfo;
- var memberId = '';
- if (member != null) {
- memberId = member.id ?? '';
- }
- Get.find<IRtmpMockRtcManager>().handleRemoteMuteVideo(
- memberId,
- !message.opened,
- );
- onSwitchVideoPlay.emit(
- this,
- ConsultationMember(videoOpend: message.opened, id: memberId),
- );
- }
- void _onNetworkErrConsultationHandler(
- NetworkErrConsultationNotification message) {
- var networkErrMemberInfo = message.networkErrMemberInfo;
- var consulation = LiveConsultation(
- consultationCode: message.consultationCode,
- );
- if (networkErrMemberInfo != null) {
- consulation.memberLiveDatas.value = [
- ConsultationMember(
- id: networkErrMemberInfo.id,
- name: networkErrMemberInfo.name,
- headImageToken: networkErrMemberInfo.headImageUrl,
- )
- ];
- }
- onNetworkErrConsultation.emit(
- this,
- consulation,
- );
- }
- ///开始会诊
- @override
- Future<LiveConsultation?> startConsultationAsync(
- ConsultationDetailDTO consultationDetailDTO,
- {bool isJoin = false,
- bool checkOnly = false,
- bool checkMedia = false}) async {
- var expertUserCode = consultationDetailDTO.expertUserCode;
- if (isJoin) {
- liveConsultation = await joinInLiveConsultationAsync(
- consultationDetailDTO.consultationCode!,
- checkOnly: checkOnly);
- } else if (consultationDetailDTO.isEmergency &&
- consultationDetailDTO.applyUserCode != Storage.user.userCode) {
- liveConsultation = await acceptLiveConsultationAsync(
- consultationDetailDTO.consultationCode!,
- checkOnly: checkOnly);
- } else if (expertUserCode == Storage.user.userCode ||
- (consultationDetailDTO.isEmergency &&
- consultationDetailDTO.applyUserCode == Storage.user.userCode)) {
- liveConsultation = await initiateLiveConsultationAsync(
- consultationDetailDTO.consultationCode!,
- checkOnly: checkOnly);
- } else {
- liveConsultation = await acceptLiveConsultationAsync(
- consultationDetailDTO.consultationCode!,
- checkOnly: checkOnly);
- }
- return liveConsultation;
- }
- @override
- Future<LiveConsultation> initiateLiveConsultationAsync(
- String consultationCode,
- {bool checkOnly = false}) async {
- final result =
- await jsonRpcProxy.liveConsultation.initiateLiveConsultationAsync(
- InitiateLiveConsultationRequest(
- token: token,
- consultationCode: consultationCode,
- checkOnly: checkOnly,
- ),
- );
- var liveConsultation = LiveConsultation(
- consultationCode: result.consultationCode,
- initiatorCode: result.initiatorCode,
- roomNo: result.roomNo,
- appId: result.appId,
- userSign: result.userSign,
- );
- liveConsultation.consultationMemberConvert(result.memberLiveDatas ?? []);
- //this.onStartLiveConsultation.emit(this, liveConsultation);
- return liveConsultation;
- }
- ///会诊心跳
- @override
- Future<LiveConsultationHeartRateResult> heartRateAsync(
- String consultationCode) async {
- return await jsonRpcProxy.liveConsultation.heartRateAsync(
- LiveConsultationHeartRateRequest(
- token: token,
- consultationCode: consultationCode,
- ),
- );
- }
- //根据会诊单号查询会诊中可直接切换的会诊单列表
- @override
- Future<List<ConsultationPageDTO>> findCanSwitchConsultationsAsync(
- String consultationCode) async {
- return await jsonRpcProxy.liveConsultation.findCanSwitchConsultationsAsync(
- FindCanSwitchConsultationsRequest(
- consultationCode: consultationCode,
- language: i18nBook.locale.toCodeString('-'),
- token: token,
- ),
- );
- }
- ///离开房间
- @override
- Future<LeaveLiveConsultationResult> leaveLiveConsultationAsync(
- String consultationCode) async {
- return jsonRpcProxy.liveConsultation.leaveLiveConsultationAsync(
- LeaveLiveConsultationRequest(
- consultationCode: consultationCode,
- token: token,
- ),
- );
- }
- ///接受会诊
- @override
- Future<LiveConsultation> acceptLiveConsultationAsync(String consultationCode,
- {bool checkOnly = false}) async {
- var result =
- await jsonRpcProxy.liveConsultation.acceptLiveConsultationAsync(
- AcceptLiveConsultationRequest(
- token: token,
- consultationCode: consultationCode,
- checkOnly: checkOnly,
- ),
- );
- var liveConsultation = LiveConsultation(
- consultationCode: result.consultationCode,
- userCode: result.userCode,
- roomNo: result.roomNo,
- appId: result.appId,
- userSign: result.userSign,
- interactiveBoardDatas: result.interactiveBoardDatas,
- );
- liveConsultation.consultationMemberConvert(result.memberLiveDatas ?? []);
- onAcceptLiveConsultation.emit(this, liveConsultation);
- return liveConsultation;
- }
- ///拒绝会诊
- @override
- Future<RejectLiveConsultationResult> rejectLiveConsultationAsync(
- String consultationCode) async {
- return jsonRpcProxy.liveConsultation
- .rejectLiveConsultationAsync(RejectLiveConsultationRequest(
- consultationCode: consultationCode,
- token: token,
- ));
- }
- @override
- Future<LiveConsultation> joinInLiveConsultationAsync(String consultationCode,
- {bool checkOnly = false}) async {
- final result =
- await jsonRpcProxy.liveConsultation.joinInLiveConsultationAsync(
- JoinLiveConsultationRequest(
- token: token,
- consultationCode: consultationCode,
- checkOnly: checkOnly,
- ),
- );
- var liveConsultation = LiveConsultation(
- consultationCode: result.consultationCode,
- userCode: result.userCode,
- roomNo: result.roomNo,
- appId: result.appId,
- userSign: result.userSign,
- interactiveBoardDatas: result.interactiveBoardDatas,
- );
- liveConsultation.consultationMemberConvert(result.memberLiveDatas ?? []);
- return liveConsultation;
- }
- ///会诊设备重试进入房间
- @override
- Future<void> retryLoadDeviceAsync(String consultationCode) async {
- await jsonRpcProxy.liveConsultation.deviceJoinInLiveConsultationAsync(
- JoinLiveConsultationRequest(
- consultationCode: consultationCode,
- token: token,
- ),
- );
- }
- /// 发送白板数据
- @override
- Future sendInteractiveBoardDataAsync(
- String consultationCode, String boardData,
- [bool isClear = false]) async {
- await jsonRpcProxy.liveConsultation.sendInteractiveBoardDataAsync(
- SendInteractiveBoardDataRequest(
- consultationCode: consultationCode,
- token: token,
- boardData: boardData,
- isClear: isClear,
- ),
- );
- }
- @override
- Future<QueryEmergencyDataResult> queryEmergencyDataAsync() async {
- return await jsonRpcProxy.liveConsultation.queryEmergencyDataAsync(
- TokenRequest(token: token),
- );
- }
- @override
- Future<GetEmergencySettingResult> getEmergencySettingAsync() async {
- return await jsonRpcProxy.liveConsultation.getEmergencySettingAsync(
- GetEmergencySettingRequest(token: token),
- );
- }
- @override
- Future<String> applyEmergencyTreatment(String selectedUser, String deviceCode,
- String? patientCode, List<DataItemDTO>? patientDatas) async {
- return await jsonRpcProxy.liveConsultation.applyEmergencyTreatment(
- ApplyEmergencyTreatmentRequest(
- token: token,
- expertCode: selectedUser,
- deviceCode: deviceCode,
- patientCode: patientCode,
- patientDatas: patientDatas),
- );
- }
- @override
- Future<bool> startEmergencyConsultationAsync(String consultationId) async {
- var appointmentManager = Get.find<IAppointmentManager>();
- var consultationInfo =
- await appointmentManager.findConsultationDetailAsync(consultationId);
- if (consultationInfo == null) {
- return false;
- }
- consultationDetail = consultationInfo;
- var result = await startConsultationAsync(consultationInfo,
- checkMedia: true, checkOnly: true);
- return result != null;
- }
- @override
- Future<bool> updateConsultationFilesInfoAsync(
- String consultationCode,
- String coverUrl,
- String previewUrl,
- String sourceUrl,
- bool isSingle) async {
- final UpdateConsultationFilesInfoRequest request =
- UpdateConsultationFilesInfoRequest(
- token: token,
- consultationCode: consultationCode,
- fileInfos: [
- ConsultationFileBaseDTO(
- coverImageUrl: coverUrl,
- previewImageUrl: previewUrl,
- sourceUrl: sourceUrl,
- fileDataType: isSingle
- ? RemedicalFileDataTypeEnum.ThirdVidSingle
- : RemedicalFileDataTypeEnum.ThirdVidMovie)
- ]);
- return await jsonRpcProxy.liveConsultation
- .updateConsultationFilesInfoAsync(request);
- }
- ///取消会诊过程邀请中的成员
- @override
- Future<CancelInvitingInLiveConsultationResult>
- cancelInvitingInLiveConsultationAsync(
- String consultationCode, List<String> inviteCodes) {
- return jsonRpcProxy.liveConsultation.cancelInvitingInLiveConsultationAsync(
- CancelInvitingInLiveConsultationRequest(
- consultationCode: consultationCode,
- inviteCodes: inviteCodes,
- token: token,
- ));
- }
- ///切换会诊病人
- @override
- Future<ChangeConsultationResult> changeConsultationAsync(
- String originalConsultationId, String currentConsultationId) async {
- var result = await jsonRpcProxy.liveConsultation.changeConsultationAsync(
- ChangeConsultationRequest(
- token: token,
- originalCode: originalConsultationId,
- currentCode: currentConsultationId,
- ),
- );
- return result;
- }
- ///会诊过程中邀请其他成员
- @override
- Future<InviteInLiveConsultationResult> inviteInLiveConsultationAsync(
- String consultationCode, List<String> inviteCodes, int roomNo) async {
- return await jsonRpcProxy.liveConsultation
- .inviteInLiveConsultationAsync(InviteInLiveConsultationRequest(
- token: token,
- consultationCode: consultationCode,
- inviteCodes: inviteCodes,
- roomNo: roomNo,
- ));
- }
- }
|