diff --git a/assets/images/new/body/abdomin.svg b/assets/images/new/body/abdomin.svg new file mode 100644 index 00000000..c28cd70b --- /dev/null +++ b/assets/images/new/body/abdomin.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/chest.svg b/assets/images/new/body/chest.svg new file mode 100644 index 00000000..77f603cb --- /dev/null +++ b/assets/images/new/body/chest.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/head.svg b/assets/images/new/body/head.svg new file mode 100644 index 00000000..5ec9c3f3 --- /dev/null +++ b/assets/images/new/body/head.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_ankle.svg b/assets/images/new/body/left_ankle.svg new file mode 100644 index 00000000..e7bf8080 --- /dev/null +++ b/assets/images/new/body/left_ankle.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_arm.svg b/assets/images/new/body/left_arm.svg new file mode 100644 index 00000000..6445b6be --- /dev/null +++ b/assets/images/new/body/left_arm.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/left_ear.svg b/assets/images/new/body/left_ear.svg new file mode 100644 index 00000000..402f5f20 --- /dev/null +++ b/assets/images/new/body/left_ear.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/left_elbow.svg b/assets/images/new/body/left_elbow.svg new file mode 100644 index 00000000..9e741679 --- /dev/null +++ b/assets/images/new/body/left_elbow.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_eye.svg b/assets/images/new/body/left_eye.svg new file mode 100644 index 00000000..add3c780 --- /dev/null +++ b/assets/images/new/body/left_eye.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_foot.svg b/assets/images/new/body/left_foot.svg new file mode 100644 index 00000000..c3f8de42 --- /dev/null +++ b/assets/images/new/body/left_foot.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_forearm.svg b/assets/images/new/body/left_forearm.svg new file mode 100644 index 00000000..7a8224b6 --- /dev/null +++ b/assets/images/new/body/left_forearm.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_hand.svg b/assets/images/new/body/left_hand.svg new file mode 100644 index 00000000..168d05c4 --- /dev/null +++ b/assets/images/new/body/left_hand.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_knee.svg b/assets/images/new/body/left_knee.svg new file mode 100644 index 00000000..5ff004f6 --- /dev/null +++ b/assets/images/new/body/left_knee.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_leg.svg b/assets/images/new/body/left_leg.svg new file mode 100644 index 00000000..352cf2b9 --- /dev/null +++ b/assets/images/new/body/left_leg.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_soulder.svg b/assets/images/new/body/left_soulder.svg new file mode 100644 index 00000000..8bd69c8c --- /dev/null +++ b/assets/images/new/body/left_soulder.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_thigh.svg b/assets/images/new/body/left_thigh.svg new file mode 100644 index 00000000..880e1da2 --- /dev/null +++ b/assets/images/new/body/left_thigh.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/left_wrist.svg b/assets/images/new/body/left_wrist.svg new file mode 100644 index 00000000..b99c3f1c --- /dev/null +++ b/assets/images/new/body/left_wrist.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/mouth.svg b/assets/images/new/body/mouth.svg new file mode 100644 index 00000000..1dd7ca76 --- /dev/null +++ b/assets/images/new/body/mouth.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/neck.svg b/assets/images/new/body/neck.svg new file mode 100644 index 00000000..e3c0d951 --- /dev/null +++ b/assets/images/new/body/neck.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/nose.svg b/assets/images/new/body/nose.svg new file mode 100644 index 00000000..1e08b591 --- /dev/null +++ b/assets/images/new/body/nose.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/pelvis.svg b/assets/images/new/body/pelvis.svg new file mode 100644 index 00000000..77d32820 --- /dev/null +++ b/assets/images/new/body/pelvis.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/publs.svg b/assets/images/new/body/publs.svg new file mode 100644 index 00000000..40909b35 --- /dev/null +++ b/assets/images/new/body/publs.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_ankle.svg b/assets/images/new/body/right_ankle.svg new file mode 100644 index 00000000..2eec1180 --- /dev/null +++ b/assets/images/new/body/right_ankle.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_arm.svg b/assets/images/new/body/right_arm.svg new file mode 100644 index 00000000..60a03321 --- /dev/null +++ b/assets/images/new/body/right_arm.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_ear.svg b/assets/images/new/body/right_ear.svg new file mode 100644 index 00000000..65de3b24 --- /dev/null +++ b/assets/images/new/body/right_ear.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/right_elbow.svg b/assets/images/new/body/right_elbow.svg new file mode 100644 index 00000000..0a58f385 --- /dev/null +++ b/assets/images/new/body/right_elbow.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_eye.svg b/assets/images/new/body/right_eye.svg new file mode 100644 index 00000000..4642c353 --- /dev/null +++ b/assets/images/new/body/right_eye.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/right_foot.svg b/assets/images/new/body/right_foot.svg new file mode 100644 index 00000000..5faa7b58 --- /dev/null +++ b/assets/images/new/body/right_foot.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_forearm.svg b/assets/images/new/body/right_forearm.svg new file mode 100644 index 00000000..fea91ddf --- /dev/null +++ b/assets/images/new/body/right_forearm.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_hand.svg b/assets/images/new/body/right_hand.svg new file mode 100644 index 00000000..b36dd80c --- /dev/null +++ b/assets/images/new/body/right_hand.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_knee.svg b/assets/images/new/body/right_knee.svg new file mode 100644 index 00000000..16a174cf --- /dev/null +++ b/assets/images/new/body/right_knee.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_leg.svg b/assets/images/new/body/right_leg.svg new file mode 100644 index 00000000..2cd6a760 --- /dev/null +++ b/assets/images/new/body/right_leg.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_soulder.svg b/assets/images/new/body/right_soulder.svg new file mode 100644 index 00000000..cb29dc98 --- /dev/null +++ b/assets/images/new/body/right_soulder.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/images/new/body/right_thigh.svg b/assets/images/new/body/right_thigh.svg new file mode 100644 index 00000000..8d9ef522 --- /dev/null +++ b/assets/images/new/body/right_thigh.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/images/new/body/right_wrist.svg b/assets/images/new/body/right_wrist.svg new file mode 100644 index 00000000..d54c14c8 --- /dev/null +++ b/assets/images/new/body/right_wrist.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/lib/config/config.dart b/lib/config/config.dart index 6f05a414..9e17af68 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -325,6 +325,7 @@ const GET_COVID_DRIVETHRU_PROCEDURES_LIST = 'Services/Doctors.svc/REST/COVID19_G ///Smartwatch Integration Services const GET_PATIENT_LAST_RECORD = 'Services/Patients.svc/REST/Med_GetPatientLastRecord'; +const INSERT_PATIENT_HEALTH_DATA = 'Services/Patients.svc/REST/Med_InsertTransactions'; ///My Trackers const GET_DIABETIC_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage'; diff --git a/lib/models/SmartWatch/HealthData.dart b/lib/models/SmartWatch/HealthData.dart index f01c3bf8..d681f764 100644 --- a/lib/models/SmartWatch/HealthData.dart +++ b/lib/models/SmartWatch/HealthData.dart @@ -1,8 +1,37 @@ class healthData { int MedCategoryID; int MedSubCategoryID; - String Value; - String Notes; String MachineDate; + double Value; int TransactionsListID; -} + String Notes; + + healthData({ + this.MedCategoryID, + this.MedSubCategoryID, + this.MachineDate, + this.Value, + this.TransactionsListID, + this.Notes, + }); + + healthData.fromJson(Map json) { + MedCategoryID = json['MedCategoryID']; + MedSubCategoryID = json['MedSubCategoryID']; + MachineDate = json['MachineDate']; + Value = json['Value']; + TransactionsListID = json['TransactionsListID']; + Notes = json['Notes']; + } + + Map toJson() { + final Map data = new Map(); + data['MedCategoryID'] = this.MedCategoryID; + data['MedSubCategoryID'] = this.MedSubCategoryID; + data['MachineDate'] = this.MachineDate; + data['Value'] = this.Value; + data['TransactionsListID'] = this.TransactionsListID; + data['Notes'] = this.Notes; + return data; + } +} \ No newline at end of file diff --git a/lib/pages/BookAppointment/LaserBooking.dart b/lib/pages/BookAppointment/LaserBooking.dart new file mode 100644 index 00000000..b8691cf2 --- /dev/null +++ b/lib/pages/BookAppointment/LaserBooking.dart @@ -0,0 +1,128 @@ +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class LaserBooking extends StatefulWidget { + @override + _LaserBookingState createState() => _LaserBookingState(); +} + +class _LaserBookingState extends State { + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowDecPage: false, + isShowAppBar: true, + showNewAppBarTitle: true, + showNewAppBar: true, + appBarTitle: "Laser", + body: Container( + child: Column( + children: [ + HumanAnatomy(), + ], + ), + )); + } +} + +class HumanAnatomy extends StatefulWidget { + final ValueChanged onChanged; + + const HumanAnatomy({Key key, this.onChanged}) : super(key: key); + + @override + _HumanAnatomyState createState() => new _HumanAnatomyState(); +} + +class _HumanAnatomyState extends State { + var _bodyPartList = []; + + @override + void initState() { + super.initState(); + if (mounted) { + _publishSelection(_bodyPartList); + } + } + + @override + Widget build(BuildContext context) { + return humanAnatomy(); + } + + Widget humanAnatomy() { + return Container( + width: 320.0, + height: 560.0, + child: SizedBox( + child: Stack( + children: [ + bodyPart("assets/images/new/body/head.svg", "Head", 0.0, 0.0, 0.0, 70.0), + bodyPart("assets/images/new/body/left_ear.svg", "leftEar", 32.0, 50.0, 0.0, 20.0), + bodyPart("assets/images/new/body/right_ear.svg", "rightEar", 32.0, 0.0, 50.0, 20.0), + bodyPart("assets/images/new/body/left_eye.svg", "LeftEye", 22.0, 20.0, 0.0, 10.0), + bodyPart("assets/images/new/body/right_eye.svg", "rightEye", 22.0, 0.0, 20.0, 10.0), + bodyPart("assets/images/new/body/nose.svg", "Nose", 25.0, 0.0, 0.0, 20.0), + bodyPart("assets/images/new/body/mouth.svg", "Mouth", 48.0, 0.0, 0.0, 10.0), + bodyPart("assets/images/new/body/neck.svg", "Neck", 58.0, 0.0, 0.0, 40.0), + bodyPart("assets/images/new/body/chest.svg", "Chest", 93.0, 0.0, 0.0, 95.0), + bodyPart("assets/images/new/body/abdomin.svg", "Abdomin", 175.0, 0.0, 0.0, 65.0), + bodyPart("assets/images/new/body/pelvis.svg", "Pelvis", 225.0, 0.0, 0.0, 50.0), + bodyPart("assets/images/new/body/publs.svg", "Publs", 275.0, 0.0, 0.0, 15.0), + bodyPart("assets/images/new/body/left_soulder.svg", "leftSoulder", 90.0, 105.0, 0.0, 50.0), + bodyPart("assets/images/new/body/right_soulder.svg", "rightSoulder", 89.0, 0.0, 110.0, 50.0), + bodyPart("assets/images/new/body/left_arm.svg", "leftArm", 120.0, 145.0, 0.0, 70.0), + bodyPart("assets/images/new/body/right_arm.svg", "rightArm", 118.0, 0.0, 142.0, 70.0), + bodyPart("assets/images/new/body/left_elbow.svg", "leftElbow", 172.0, 172.0, 0.0, 39.0), + bodyPart("assets/images/new/body/right_elbow.svg", "rightElbow", 170.0, 0.0, 170.0, 40.0), + bodyPart("assets/images/new/body/left_forearm.svg", "leftForearm", 195.0, 190.0, 0.0, 54.0), + bodyPart("assets/images/new/body/right_forearm.svg", "rightForearm", 195.0, 0.0, 190.0, 54.0), + bodyPart("assets/images/new/body/left_wrist.svg", "leftWrist", 238.0, 220.0, 0.0, 23.0), + bodyPart("assets/images/new/body/right_wrist.svg", "rightWrist", 238.0, 0.0, 220.0, 23.0), + bodyPart("assets/images/new/body/left_hand.svg", "leftHand", 250.0, 250.0, 0.0, 60.0), + bodyPart("assets/images/new/body/right_hand.svg", "rightHand", 250.0, 0.0, 250.0, 60.0), + bodyPart("assets/images/new/body/left_thigh.svg", "leftThigh", 242.0, 63.0, 0.0, 138.0), + bodyPart("assets/images/new/body/right_thigh.svg", "rightThigh", 242.0, 0.0, 63.0, 138.0), + bodyPart("assets/images/new/body/left_knee.svg", "leftKnee", 360.0, 68.0, 0.0, 48.0), + bodyPart("assets/images/new/body/right_knee.svg", "rightKnee", 360.0, 0.0, 68.0, 48.0), + bodyPart("assets/images/new/body/left_leg.svg", "leftLeg", 395.0, 64.0, 0.0, 105.0), + bodyPart("assets/images/new/body/right_leg.svg", "rightLeg", 393.0, 0.0, 65.0, 106.0), + bodyPart("assets/images/new/body/left_ankle.svg", "leftAnkle", 495.0, 64.0, 0.0, 25.0), + bodyPart("assets/images/new/body/right_ankle.svg", "rightAnkle", 493.0, 0.0, 68.0, 25.0), + bodyPart("assets/images/new/body/left_foot.svg", "leftFoot", 510.0, 80.0, 0.0, 60.0), + bodyPart("assets/images/new/body/right_foot.svg", "rightFoot", 508.0, 0.0, 83.0, 56.0), + ], + ), + ), + ); + } + + Widget bodyPart(String svgPath, String svgName, double marginTop, double marginRight, double marginLeft, double height) { + Color _svgColor = _bodyPartList.contains(svgName) ? Colors.redAccent : null; + final Widget bodyPartSvg = new SvgPicture.asset(svgPath, semanticsLabel: svgName, color: _svgColor); + return Container( + margin: EdgeInsets.only(top: marginTop, right: marginRight, left: marginLeft), + height: height, + alignment: Alignment.topCenter, + child: GestureDetector( + onTap: () { + setState(() { + if (_bodyPartList.contains(svgName)) { + _bodyPartList.remove(svgName); + } else { + _bodyPartList.add(svgName); + // _bodyPartList.forEach((e) => print(e)); + } + }); + }, + child: bodyPartSvg), + ); + } + + void _publishSelection(List _bodyPartList) { + if (widget.onChanged != null) { + widget.onChanged(_bodyPartList); + } + } +} diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index 147cb9f9..f250bc3f 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/models/Appointments/SearchInfoModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/DentalComplaints.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/LaserBooking.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; @@ -176,9 +177,10 @@ class _SearchByClinicState extends State { ), ], ), - - Container(child: inputWidget("Age", "", ageController),margin: EdgeInsets.only(left: 20, right: 20),), - + Container( + child: inputWidget("Age", "", ageController), + margin: EdgeInsets.only(left: 20, right: 20), + ), ], ), Padding( @@ -421,15 +423,15 @@ class _SearchByClinicState extends State { prefixIcon: prefix == null ? null : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w500, - color: Color(0xff2E303A), - letterSpacing: -0.56, - ), - ), + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -446,7 +448,6 @@ class _SearchByClinicState extends State { ); } - void openDropdown(GlobalKey key) { GestureDetector detector; void searchForGestureDetector(BuildContext element) { @@ -537,6 +538,8 @@ class _SearchByClinicState extends State { searchInfo.date = DateTime.now(); navigateToDentalComplaints(context, searchInfo); + } else if (dropdownValue.split("-")[0] == "253") { + navigateToLaserClinic(context); } else if (dropdownValue.split("-")[1] == "true" // && authProvider.isLogin && // authUser.patientType == 1 @@ -625,6 +628,19 @@ class _SearchByClinicState extends State { }); } + Future navigateToLaserClinic(BuildContext context) async { + Navigator.push( + context, + FadePage( + page: LaserBooking(), + ), + ).then((value) { + setState(() { + dropdownValue = null; + }); + }); + } + Future navigateToSearchResults(context, List docList, List patientDoctorAppointmentListHospital) async { isProjectLoaded = false; Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital))) diff --git a/lib/pages/medical/smart_watch_health_data/health_data_list.dart b/lib/pages/medical/smart_watch_health_data/health_data_list.dart index f43a6e63..80a12cca 100644 --- a/lib/pages/medical/smart_watch_health_data/health_data_list.dart +++ b/lib/pages/medical/smart_watch_health_data/health_data_list.dart @@ -1,8 +1,8 @@ import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/Steps/stepsTracker.dart'; import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/distance/distanceTracker.dart'; import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/heartrate/heartrateTracker.dart'; +import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/syncHealthData.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -64,20 +64,10 @@ class _HealthDataListState extends State { ), ), ), - bottomSheet: Container( - color: Colors.white, - child: Padding( - padding: const EdgeInsets.all(20.0), - child: DefaultButton(TranslationBase.of(context).syncHealthData, () { - print("ReadLast"); - // readLast(); - }), - ), - ), + bottomSheet: syncHealthDataButton(), ); } - List myOptionsList(BuildContext context) { List medical = List(); @@ -123,7 +113,6 @@ class _HealthDataListState extends State { return medical; } - // void readLast() async { // print("ReadLast"); // final result = await FitKit.readLast(DataType.DISTANCE); diff --git a/lib/pages/medical/smart_watch_health_data/syncHealthData.dart b/lib/pages/medical/smart_watch_health_data/syncHealthData.dart new file mode 100644 index 00000000..47be3c5f --- /dev/null +++ b/lib/pages/medical/smart_watch_health_data/syncHealthData.dart @@ -0,0 +1,274 @@ +import 'package:collection/collection.dart'; +import 'package:diplomaticquarterapp/models/SmartWatch/HealthData.dart'; +import 'package:diplomaticquarterapp/services/smartwatch_integration/SmartWatchIntegrationService.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/alert_dialog.dart'; +import 'package:fit_kit/fit_kit.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class syncHealthDataButton extends StatefulWidget { + double marginTop; + + double hight; + + double minWidth; + + syncHealthDataButton({this.marginTop, this.hight, this.minWidth}); + + @override + _syncHealthDataButtonState createState() => _syncHealthDataButtonState(); +} + +class _syncHealthDataButtonState extends State { + List dataTypes = List(); + + List Med_InsertTransactionsInputsList = new List(); + List Med_InsertTransactionsInputsList2 = new List(); + + List sleepDataList = new List(); + + List healthDataList = new List(); + + int TransactionsListID = 1; + + int MedCategoryID = 0; + + @override + void initState() { + dataTypes.add(DataType.DISTANCE); + dataTypes.add(DataType.STEP_COUNT); + dataTypes.add(DataType.HEART_RATE); + // dataTypes.add(DataType.SLEEP); + // dataTypes.add(DataType.ENERGY); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(20.0), + child: DefaultButton(TranslationBase.of(context).syncHealthData, () { + print("ReadAll"); + readAll(); + }), + ), + ); + } + + void readAll() async { + TransactionsListID = 1; + var MedSubCategoryID = 0; + double value = 0.0; + + GifLoaderDialogUtils.showMyDialog(context); + Med_InsertTransactionsInputsList.clear(); + var date; + var differenceInHours; + String strDifferenceInHours; + var differenceInMinutes; + String strDifferenceInMinutes; + var today = DateTime.now(); + var yearNum = DateFormat('y').format(today).toString(); + + var firstDayOfTheYear = DateTime.parse(yearNum + "-" + "01" + "-" + "01"); + + if (await FitKit.requestPermissions(dataTypes)) { + for (DataType type in dataTypes) { + final results = await FitKit.read( + type, + dateFrom: firstDayOfTheYear, + dateTo: DateTime.now(), + limit: 1000500, + ); + + if (type == DataType.DISTANCE) { + MedCategoryID = 7; + } else if (type == DataType.STEP_COUNT) { + MedCategoryID = 6; + } else if (type == DataType.HEART_RATE) { + MedCategoryID = 3; + } + + results.forEach((result) { + // print("in forEach"); + date = result.dateTo; + if (result.value.runtimeType.toString() == "int") { + value = double.parse(result.value.toString()); + } else { + value = result.value; + } + + MedSubCategoryID = 0; + + if (MedCategoryID == 4) { + differenceInHours = null; + var sleepDate = result.dateFrom.toString().substring(0, 10); + + DateTime dateFrom = result.dateFrom; + DateTime dateTo = result.dateTo; + + differenceInMinutes = dateTo.difference(dateFrom).inMinutes; + differenceInMinutes > 59 ? differenceInHours = differenceInMinutes / 60 : differenceInMinutes = differenceInMinutes; + + if (differenceInHours != null && differenceInHours != 0) { + differenceInHours = differenceInHours.toInt(); + differenceInMinutes = differenceInMinutes % 60; + + differenceInHours < 10 ? strDifferenceInHours = "0" + differenceInHours.toString() : strDifferenceInHours = differenceInHours.toString(); + } else { + strDifferenceInHours = "00"; + differenceInHours = 00; + } + differenceInMinutes < 10 ? strDifferenceInMinutes = "0" + differenceInMinutes.toString() : strDifferenceInMinutes = differenceInMinutes.toString(); + + sleepDate = DateTime.parse(sleepDate + " " + strDifferenceInHours + ":" + strDifferenceInMinutes + ":" + "00.00").toString(); + String hours = sleepDate.substring(11, sleepDate.indexOf(":")); + print(hours); + + String minutes = sleepDate.substring(sleepDate.indexOf(":") + 1, sleepDate.indexOf(":") + 3); + print(minutes); + + if (value == 0 || value == 109) { + print("in Bed"); + MedSubCategoryID = 1; + value = double.parse(hours + "." + minutes); + print("value"); + print(value); + } else if (value == 1 || value == 110) { + print("Sleep"); + MedSubCategoryID = 2; + value = double.parse(hours + "." + minutes); + print("value"); + print(value); + } + } + date = DateUtil.convertDateToString(date); + Med_InsertTransactionsInputsList.add( + healthData(MedCategoryID: MedCategoryID, MedSubCategoryID: MedSubCategoryID, MachineDate: date, Value: value, TransactionsListID: TransactionsListID++, Notes: "")); + }); + } + } + getAllHealthDataLists(); + } + + void getAllHealthDataLists() { + var totalSteps = 0.0; + var totalDistance = 0.0; + // double totalCalories = 0.0 ; + double totalHeartRate = 0.0; + double avgTotalHeartRate = 0.0; + var counter = 0; + List data = []; + TransactionsListID = 1; + + DateTime date; + sleepDataList.clear(); + + Med_InsertTransactionsInputsList.forEach((result) { + data.add(result.toJson()); + }); + + Med_InsertTransactionsInputsList2.clear(); + + var newMap = groupBy(data, (obj) => DateUtil.convertStringToDate(obj['MachineDate']).toString().substring(0, 10)); + + newMap.forEach((key, value) { + totalSteps = 0.0; + totalDistance = 0.0; + totalHeartRate = 0.0; + avgTotalHeartRate = 0.0; + counter = 0; + + date = DateTime.parse(key); + + value.forEach((element) { + if (element['MedCategoryID'] == 6) { + MedCategoryID = 6; + + totalSteps += element['Value']; + } else if (element['MedCategoryID'] == 7) { + MedCategoryID = 7; + // to convert from meter to km + totalDistance += (element['Value'] * 0.001); + } else if (element['MedCategoryID'] == 3) { + print("HeartRate"); + MedCategoryID = 3; + counter++; + totalHeartRate += element['Value']; + } else if (element['MedCategoryID'] == 4) { + print("sleeeeep"); + sleepDataList.add(new healthData( + MedCategoryID: 4, + MedSubCategoryID: element['MedSubCategoryID'], + MachineDate: DateUtil.convertDateToString(date), + Value: element['Value'], + TransactionsListID: TransactionsListID++, + Notes: "")); + + Med_InsertTransactionsInputsList2.add(new healthData( + MedCategoryID: 4, + MedSubCategoryID: element['MedSubCategoryID'], + MachineDate: DateUtil.convertDateToString(date), + Value: element['Value'], + TransactionsListID: TransactionsListID++, + Notes: "")); + } + // else if(element['MedCategoryID'] == 8){ + // + // totalCalories += element['Value'] ; + // } + }); + + if (counter == 0) { + counter = 1; + } + if (totalHeartRate == 0) { + avgTotalHeartRate = 0; + } else { + avgTotalHeartRate = totalHeartRate / counter; + } + + Med_InsertTransactionsInputsList2.add( + new healthData(MedCategoryID: 6, MedSubCategoryID: 0, MachineDate: DateUtil.convertDateToString(date), Value: totalSteps, TransactionsListID: TransactionsListID++, Notes: "")); + Med_InsertTransactionsInputsList2.add( + new healthData(MedCategoryID: 7, MedSubCategoryID: 0, MachineDate: DateUtil.convertDateToString(date), Value: totalDistance, TransactionsListID: TransactionsListID++, Notes: "")); + Med_InsertTransactionsInputsList2.add( + new healthData(MedCategoryID: 3, MedSubCategoryID: 0, MachineDate: DateUtil.convertDateToString(date), Value: avgTotalHeartRate, TransactionsListID: TransactionsListID++, Notes: "")); + + // Med_InsertTransactionsInputsList2.add(new healthData(MedCategoryID: 8 , MedSubCategoryID: 0 , MachineDate: DateUtil.convertDateToStringWithBackSlash(date) , Value: totalCalories , TransactionsListID: TransactionsListID++ , Notes: "")); + }); + + GifLoaderDialogUtils.hideDialog(context); + + AlertDialogBox dialog = new AlertDialogBox( + context: context, + confirmMessage: TranslationBase.of(context).alreadySynced, + okText: TranslationBase.of(context).ok, + okFunction: () => { + AlertDialogBox.closeAlertDialog(context), + }, + ); + + dialog.showAlertDialog(context); + } + + addInsertTransactionsInputsList() { + if (Med_InsertTransactionsInputsList2.isNotEmpty) { + SmartWatchIntegrationService service = new SmartWatchIntegrationService(); + service.insertPatientHealthData(Med_InsertTransactionsInputsList2, context).then((res) { + print(res); + }).catchError((err) { + print(err); + }); + } else { + return; + } + } +} diff --git a/lib/services/smartwatch_integration/SmartWatchIntegrationService.dart b/lib/services/smartwatch_integration/SmartWatchIntegrationService.dart index 3bfe62e3..459c0e83 100644 --- a/lib/services/smartwatch_integration/SmartWatchIntegrationService.dart +++ b/lib/services/smartwatch_integration/SmartWatchIntegrationService.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; +import 'package:diplomaticquarterapp/models/SmartWatch/HealthData.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/material.dart'; @@ -18,8 +19,7 @@ class SmartWatchIntegrationService extends BaseService { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { - var data = AuthenticatedUser.fromJson( - await this.sharedPref.getObject(USER_PROFILE)); + var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); authUser = data; } @@ -42,13 +42,29 @@ class SmartWatchIntegrationService extends BaseService { dynamic localRes; - await baseAppClient.post(GET_PATIENT_LAST_RECORD, - onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: request); + await baseAppClient.post(GET_PATIENT_LAST_RECORD, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); return Future.value(localRes); + } + Future insertPatientHealthData(List healthData, BuildContext context) async { + Map request; + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + request = { + "Med_InsertTransactionsInputsList": healthData, + }; + dynamic localRes; + await baseAppClient.post(INSERT_PATIENT_HEALTH_DATA, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); } } diff --git a/pubspec.yaml b/pubspec.yaml index 49700d97..c871fdb2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,6 +30,8 @@ dependencies: #Dependency Injection get_it: ^4.0.2 + #Google Fit & Apple HealthKit + fit_kit: ^1.1.2 #chart fl_chart: ^0.12.3 @@ -250,6 +252,7 @@ flutter: - assets/images/new/services/ - assets/images/new/appointment-rating/ - assets/images/new/payment/ + - assets/images/new/body/ fonts: - family: WorkSans