|
|
|
|
@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/core/service/VideoCallService.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart';
|
|
|
|
|
@ -31,7 +32,8 @@ class PatientProfileScreen extends StatefulWidget {
|
|
|
|
|
_PatientProfileScreenState createState() => _PatientProfileScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PatientProfileScreenState extends State<PatientProfileScreen> with SingleTickerProviderStateMixin {
|
|
|
|
|
class _PatientProfileScreenState extends State<PatientProfileScreen>
|
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
|
PatiantInformtion patient;
|
|
|
|
|
LiveCarePatientViewModel _liveCareViewModel = LiveCarePatientViewModel();
|
|
|
|
|
|
|
|
|
|
@ -54,6 +56,7 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
|
|
|
|
|
StreamController<String> videoCallDurationStreamController;
|
|
|
|
|
Stream<String> videoCallDurationStream = (() async* {})();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
_tabController = TabController(length: 2, vsync: this);
|
|
|
|
|
@ -108,15 +111,17 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamSubscription callTimer;
|
|
|
|
|
|
|
|
|
|
callConnected() {
|
|
|
|
|
callTimer = CountdownTimer(Duration(minutes: 90), Duration(seconds: 1)).listen(null)
|
|
|
|
|
..onDone(() {
|
|
|
|
|
callTimer.cancel();
|
|
|
|
|
})
|
|
|
|
|
..onData((data) {
|
|
|
|
|
var t = Helpers.timeFrom(duration: data.elapsed);
|
|
|
|
|
videoCallDurationStreamController.sink.add(t);
|
|
|
|
|
});
|
|
|
|
|
callTimer =
|
|
|
|
|
CountdownTimer(Duration(minutes: 90), Duration(seconds: 1)).listen(null)
|
|
|
|
|
..onDone(() {
|
|
|
|
|
callTimer.cancel();
|
|
|
|
|
})
|
|
|
|
|
..onData((data) {
|
|
|
|
|
var t = Helpers.timeFrom(duration: data.elapsed);
|
|
|
|
|
videoCallDurationStreamController.sink.add(t);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callDisconnected() {
|
|
|
|
|
@ -133,12 +138,12 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
final screenSize = MediaQuery.of(context).size;
|
|
|
|
|
return BaseView<LiveCarePatientViewModel>(
|
|
|
|
|
onModelReady: (model) async {
|
|
|
|
|
if (isFromLiveCare && patient.patientStatus == 1) await model.addPatientToDoctorList(patient.vcId);
|
|
|
|
|
if (isFromLiveCare && patient.patientStatus == 1)
|
|
|
|
|
await model.addPatientToDoctorList(patient.vcId);
|
|
|
|
|
},
|
|
|
|
|
builder: (_, model, w) => AppScaffold(
|
|
|
|
|
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
|
|
|
|
|
isLoading: true,
|
|
|
|
|
appBarTitle: TranslationBase.of(context).patientProfile,
|
|
|
|
|
isShowAppBar: false,
|
|
|
|
|
body: Column(
|
|
|
|
|
@ -147,11 +152,13 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
PatientProfileHeaderNewDesignAppBar(patient, arrivalType ?? '0', patientType,
|
|
|
|
|
PatientProfileHeaderNewDesignAppBar(
|
|
|
|
|
patient, arrivalType ?? '0', patientType,
|
|
|
|
|
videoCallDurationStream: videoCallDurationStream,
|
|
|
|
|
isInpatient: isInpatient,
|
|
|
|
|
isFromLiveCare: isFromLiveCare,
|
|
|
|
|
height: (patient.patientStatusType != null && patient.patientStatusType == 43)
|
|
|
|
|
height: (patient.patientStatusType != null &&
|
|
|
|
|
patient.patientStatusType == 43)
|
|
|
|
|
? 210
|
|
|
|
|
: isDischargedPatient
|
|
|
|
|
? 240
|
|
|
|
|
@ -183,7 +190,8 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
isInpatient: isInpatient,
|
|
|
|
|
from: from,
|
|
|
|
|
to: to,
|
|
|
|
|
isDischargedPatient: isDischargedPatient,
|
|
|
|
|
isDischargedPatient:
|
|
|
|
|
isDischargedPatient,
|
|
|
|
|
isFromSearch: isFromSearch,
|
|
|
|
|
)
|
|
|
|
|
: ProfileGridForOther(
|
|
|
|
|
@ -204,25 +212,34 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if ( (isInpatient )? true:isFromLiveCare
|
|
|
|
|
? patient.episodeNo != null
|
|
|
|
|
: patient.patientStatusType != null && patient.patientStatusType == 43)
|
|
|
|
|
if ((isInpatient)
|
|
|
|
|
? true
|
|
|
|
|
: isFromLiveCare
|
|
|
|
|
? patient.episodeNo != null
|
|
|
|
|
: patient.patientStatusType != null &&
|
|
|
|
|
patient.patientStatusType == 43)
|
|
|
|
|
BaseView<SOAPViewModel>(
|
|
|
|
|
onModelReady: (model) async {
|
|
|
|
|
model.getDoctorProfile();
|
|
|
|
|
if (isInpatient) {
|
|
|
|
|
await model.getEpisodeForInpatient(patient);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
builder: (_, model, w) => Positioned(
|
|
|
|
|
top: 180,
|
|
|
|
|
left: 20,
|
|
|
|
|
right: 20,
|
|
|
|
|
child: Row(
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(child: Container()),
|
|
|
|
|
if (patient.episodeNo == 0)
|
|
|
|
|
AppButton(
|
|
|
|
|
loading: model.state== ViewState.BusyLocal,
|
|
|
|
|
disabled: model.state== ViewState.BusyLocal,
|
|
|
|
|
|
|
|
|
|
title:
|
|
|
|
|
"${TranslationBase.of(context).createNew}\n${TranslationBase.of(context).episode}",
|
|
|
|
|
color: isFromLiveCare ||isInpatient
|
|
|
|
|
color: isFromLiveCare || isInpatient
|
|
|
|
|
? Colors.red.shade700
|
|
|
|
|
: patient.patientStatusType == 43
|
|
|
|
|
? Colors.red.shade700
|
|
|
|
|
@ -239,29 +256,22 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
height: 30,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
if ((isFromLiveCare && patient.appointmentNo != null) ||
|
|
|
|
|
patient.patientStatusType == 43) {
|
|
|
|
|
await locator<AnalyticsService>().logEvent(
|
|
|
|
|
eventCategory: "Patient Profile",
|
|
|
|
|
eventAction: "Create Episode",
|
|
|
|
|
);
|
|
|
|
|
PostEpisodeReqModel postEpisodeReqModel = PostEpisodeReqModel(
|
|
|
|
|
appointmentNo: int.parse(patient.appointmentNo.toString()),
|
|
|
|
|
patientMRN: patient.patientMRN);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model.postEpisode(postEpisodeReqModel);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
patient.episodeNo = model.episodeID;
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.pushNamed(CREATE_EPISODE, arguments: {'patient': patient});
|
|
|
|
|
if ((isFromLiveCare &&
|
|
|
|
|
patient.appointmentNo != null) ||
|
|
|
|
|
patient.patientStatusType == 43 || isInpatient ) {
|
|
|
|
|
createEpisode(
|
|
|
|
|
patient: patient, model: model);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (patient.episodeNo != 0)
|
|
|
|
|
AppButton(
|
|
|
|
|
loading: model.state== ViewState.BusyLocal,
|
|
|
|
|
disabled: model.state== ViewState.BusyLocal,
|
|
|
|
|
|
|
|
|
|
title:
|
|
|
|
|
"${TranslationBase.of(context).update}\n${TranslationBase.of(context).episode}",
|
|
|
|
|
color: (isInpatient ) || isFromLiveCare
|
|
|
|
|
color: ((isInpatient) || isFromLiveCare) && model.state!= ViewState.BusyLocal
|
|
|
|
|
? Colors.red.shade700
|
|
|
|
|
: patient.patientStatusType == 43
|
|
|
|
|
? Colors.red.shade700
|
|
|
|
|
@ -278,16 +288,19 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
height: 30,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
await locator<AnalyticsService>().logEvent(
|
|
|
|
|
await locator<AnalyticsService>()
|
|
|
|
|
.logEvent(
|
|
|
|
|
eventCategory: "Patient Profile ",
|
|
|
|
|
eventAction: "Update Episode",
|
|
|
|
|
);
|
|
|
|
|
if ((isFromLiveCare &&
|
|
|
|
|
patient.appointmentNo != null &&
|
|
|
|
|
patient.appointmentNo != 0) ||
|
|
|
|
|
patient.patientStatusType == 43 ||isInpatient ) {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.pushNamed(UPDATE_EPISODE, arguments: {'patient': patient});
|
|
|
|
|
patient.patientStatusType == 43 ||
|
|
|
|
|
isInpatient) {
|
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
|
UPDATE_EPISODE,
|
|
|
|
|
arguments: {'patient': patient});
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
@ -319,11 +332,14 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
child: Center(
|
|
|
|
|
child: AppButton(
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
color: isCallFinished ? Colors.red[600] : Colors.green[600],
|
|
|
|
|
color: isCallFinished
|
|
|
|
|
? Colors.red[600]
|
|
|
|
|
: Colors.green[600],
|
|
|
|
|
title: isCallFinished
|
|
|
|
|
? TranslationBase.of(context).endCall
|
|
|
|
|
: TranslationBase.of(context).initiateCall,
|
|
|
|
|
disabled: isCallStarted || model.state == ViewState.BusyLocal,
|
|
|
|
|
disabled: isCallStarted ||
|
|
|
|
|
model.state == ViewState.BusyLocal,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
// TODO MOSA TEST
|
|
|
|
|
// AppPermissionsUtils
|
|
|
|
|
@ -339,37 +355,52 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
// });
|
|
|
|
|
if (isCallFinished) {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (BuildContext context) => EndCallScreen(patient: patient),settings: RouteSettings(name: 'EndCallScreen'),),);
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (BuildContext context) =>
|
|
|
|
|
EndCallScreen(patient: patient),
|
|
|
|
|
settings:
|
|
|
|
|
RouteSettings(name: 'EndCallScreen'),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model.startCall(isReCall: false, vCID: patient.vcId);
|
|
|
|
|
await model.startCall(
|
|
|
|
|
isReCall: false, vCID: patient.vcId);
|
|
|
|
|
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Helpers.showErrorToast(model.error);
|
|
|
|
|
} else {
|
|
|
|
|
await model.getDoctorProfile();
|
|
|
|
|
patient.appointmentNo = int.parse(model.startCallRes.appointmentNo.toString());
|
|
|
|
|
patient.appointmentNo = int.parse(model
|
|
|
|
|
.startCallRes.appointmentNo
|
|
|
|
|
.toString());
|
|
|
|
|
patient.episodeNo = 0;
|
|
|
|
|
model.updateInCallPatient(
|
|
|
|
|
patient: patient,
|
|
|
|
|
appointmentNo: int.parse(model.startCallRes.appointmentNo.toString()));
|
|
|
|
|
appointmentNo: int.parse(model
|
|
|
|
|
.startCallRes.appointmentNo
|
|
|
|
|
.toString()));
|
|
|
|
|
setState(() {
|
|
|
|
|
isCallStarted = true;
|
|
|
|
|
});
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppPermissionsUtils.requestVideoCallPermission(
|
|
|
|
|
context: context,
|
|
|
|
|
onTapGrant: () {
|
|
|
|
|
locator<VideoCallService>().openVideo(
|
|
|
|
|
model.startCallRes,
|
|
|
|
|
patient,
|
|
|
|
|
model.startCallRes != null ? model.startCallRes.isRecording : true,
|
|
|
|
|
callConnected,
|
|
|
|
|
callDisconnected);
|
|
|
|
|
});
|
|
|
|
|
AppPermissionsUtils
|
|
|
|
|
.requestVideoCallPermission(
|
|
|
|
|
context: context,
|
|
|
|
|
onTapGrant: () {
|
|
|
|
|
locator<VideoCallService>()
|
|
|
|
|
.openVideo(
|
|
|
|
|
model.startCallRes,
|
|
|
|
|
patient,
|
|
|
|
|
model.startCallRes != null
|
|
|
|
|
? model.startCallRes
|
|
|
|
|
.isRecording
|
|
|
|
|
: true,
|
|
|
|
|
callConnected,
|
|
|
|
|
callDisconnected);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -387,6 +418,36 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createEpisode({PatiantInformtion patient, SOAPViewModel model}) async {
|
|
|
|
|
await locator<AnalyticsService>().logEvent(
|
|
|
|
|
eventCategory: "Patient Profile",
|
|
|
|
|
eventAction: "Create Episode",
|
|
|
|
|
);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
if (patient.admissionNo != null && patient.admissionNo.isNotEmpty) {
|
|
|
|
|
PostEpisodeForInpatientRequestModel postEpisodeReqModel =
|
|
|
|
|
PostEpisodeForInpatientRequestModel(
|
|
|
|
|
admissionNo: int.parse(patient.admissionNo),
|
|
|
|
|
patientID: patient.patientId);
|
|
|
|
|
await model.postEpisodeForInPatient(postEpisodeReqModel);
|
|
|
|
|
} else {
|
|
|
|
|
PostEpisodeReqModel postEpisodeReqModel = PostEpisodeReqModel(
|
|
|
|
|
appointmentNo: int.parse(patient.appointmentNo.toString()),
|
|
|
|
|
patientMRN: patient.patientMRN);
|
|
|
|
|
|
|
|
|
|
await model.postEpisode(postEpisodeReqModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
Helpers.showErrorToast(model.error);
|
|
|
|
|
} else {
|
|
|
|
|
patient.episodeNo = model.episodeID;
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.pushNamed(CREATE_EPISODE, arguments: {'patient': patient});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AvatarWidget extends StatelessWidget {
|
|
|
|
|
@ -398,7 +459,12 @@ class AvatarWidget extends StatelessWidget {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
boxShadow: [BoxShadow(color: Color.fromRGBO(0, 0, 0, 0.08), offset: Offset(0.0, 5.0), blurRadius: 16.0)],
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.08),
|
|
|
|
|
offset: Offset(0.0, 5.0),
|
|
|
|
|
blurRadius: 16.0)
|
|
|
|
|
],
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(35.0)),
|
|
|
|
|
color: Color(0xffCCCCCC),
|
|
|
|
|
),
|
|
|
|
|
|