Health plugin updated

merge-requests/567/head
haroon amjad 3 years ago
parent 7bc8f69dfb
commit 4c2410cfd5

@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers';
const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items';
const PACKAGES_ORDERS = '/api/orders';
const PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara';
// const BASE_URL = 'https://uat.hmgwebservices.com/';
const BASE_URL = 'https://hmgwebservices.com/';
const BASE_URL = 'https://uat.hmgwebservices.com/';
// const BASE_URL = 'https://hmgwebservices.com/';
// Pharmacy UAT URLs
// const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/';
@ -257,7 +257,7 @@ const GET_PATIENT_SHARE =
//URL to get patient appointment history
const GET_PATIENT_APPOINTMENT_HISTORY =
"Services/Doctors.svc/REST/PateintHasAppoimentHistory";
"Services/Doctors.svc/REST/PateintHasAppoimentHistory_Async";
const DOCTOR_SCHEDULE_URL =
'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable';

@ -201,7 +201,7 @@ class OrderPreviewService extends BaseService {
orderBody['custom_values_xml'] = "PaymentOption:${getPaymentOptionName(paymentCheckoutData.paymentOption)}";
orderBody['shippingOption'] = paymentCheckoutData.shippingOption;
orderBody['shipping_address'] = paymentCheckoutData.address;
orderBody['lakum_amount'] = paymentCheckoutData.usedLakumPoints;
// orderBody['lakum_amount'] = paymentCheckoutData.usedLakumPoints;
List<Map<String, dynamic>> itemsList = List();
shoppingCarts.forEach((item) {

@ -24,6 +24,8 @@ class _LiveCareBookAppointmentState extends State<LiveCareBookAppointment> {
@override
Widget build(BuildContext context) {
return AppScaffold(
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: TranslationBase.of(context).bookAppo,
isShowAppBar: true,
isShowDecPage: false,

@ -8,10 +8,8 @@ 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:fit_kit/fit_kit.dart';
import 'package:flutter/material.dart';
import 'package:health/health.dart';
import 'package:intl/intl.dart';
class syncHealthDataButton extends StatefulWidget {
double marginTop;
@ -27,8 +25,6 @@ class syncHealthDataButton extends StatefulWidget {
}
class _syncHealthDataButtonState extends State<syncHealthDataButton> {
List<DataType> dataTypes = List();
List<HealthDataPoint> _healthDataList = [];
List<healthData> Med_InsertTransactionsInputsList = new List();
@ -44,12 +40,6 @@ class _syncHealthDataButtonState extends State<syncHealthDataButton> {
@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();
}
@ -61,53 +51,13 @@ class _syncHealthDataButtonState extends State<syncHealthDataButton> {
padding: const EdgeInsets.all(20.0),
child: DefaultButton(TranslationBase.of(context).syncHealthData, () {
print("ReadAll");
fetchData();
// readAll();
// fetchData();
readAll();
}),
),
);
}
Future fetchData() async {
// get everything from midnight until now
DateTime startDate = DateTime(2021, 11, 01, 0, 0, 0);
DateTime endDate = DateTime(2021, 12, 06, 23, 59, 59);
HealthFactory health = HealthFactory();
// define the types to get
List<HealthDataType> types = [
HealthDataType.STEPS,
HealthDataType.HEART_RATE,
Platform.isAndroid ? HealthDataType.DISTANCE_DELTA : HealthDataType.DISTANCE_WALKING_RUNNING
];
// you MUST request access to the data types before reading them
// bool accessWasGranted = await health.requestAuthorization(types);
await health.requestAuthorization(types);
int steps = 0;
try {
List<HealthDataPoint> healthData = await health.getHealthDataFromTypes(startDate, endDate, types);
_healthDataList.addAll(healthData);
} catch (e) {
print("Caught exception in getHealthDataFromTypes: $e");
}
// filter out duplicates
_healthDataList = HealthFactory.removeDuplicates(_healthDataList);
// print the results
_healthDataList.forEach((x) {
if(x.type == HealthDataType.STEPS) {
print("Data point: $x");
steps += x.value.round();
}
});
print("Steps: $steps");
}
void readAll() async {
TransactionsListID = 1;
var MedSubCategoryID = 0;
@ -115,91 +65,37 @@ class _syncHealthDataButtonState extends State<syncHealthDataButton> {
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: 1000,
);
if (type == DataType.DISTANCE) {
MedCategoryID = 7;
} else if (type == DataType.STEP_COUNT) {
MedCategoryID = 6;
} else if (type == DataType.HEART_RATE) {
MedCategoryID = 3;
}
DateTime startDate = DateTime.now().subtract(new Duration(days: 30));
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++));
});
}
HealthFactory health = HealthFactory();
List<HealthDataType> types = [HealthDataType.STEPS, HealthDataType.HEART_RATE, Platform.isAndroid ? HealthDataType.DISTANCE_DELTA : HealthDataType.DISTANCE_WALKING_RUNNING];
await health.requestAuthorization(types);
try {
List<HealthDataPoint> healthData = await health.getHealthDataFromTypes(startDate, DateTime.now(), types);
_healthDataList.addAll(healthData);
} catch (e) {
print("Caught exception in getHealthDataFromTypes: $e");
}
_healthDataList = HealthFactory.removeDuplicates(_healthDataList);
_healthDataList.forEach((x) {
if (x.type == HealthDataType.STEPS) {
Med_InsertTransactionsInputsList.add(
healthData(MedCategoryID: 6, MedSubCategoryID: MedSubCategoryID, MachineDate: DateUtil.convertDateToString(x.dateFrom), Value: x.value, TransactionsListID: TransactionsListID++));
}
if (x.type == HealthDataType.HEART_RATE) {
Med_InsertTransactionsInputsList.add(
healthData(MedCategoryID: 3, MedSubCategoryID: MedSubCategoryID, MachineDate: DateUtil.convertDateToString(x.dateFrom), Value: x.value, TransactionsListID: TransactionsListID++));
}
if (x.type == HealthDataType.DISTANCE_DELTA || x.type == HealthDataType.DISTANCE_WALKING_RUNNING) {
Med_InsertTransactionsInputsList.add(
healthData(MedCategoryID: 7, MedSubCategoryID: MedSubCategoryID, MachineDate: DateUtil.convertDateToString(x.dateFrom), Value: x.value, TransactionsListID: TransactionsListID++));
}
});
getAllHealthDataLists();
}
@ -238,10 +134,8 @@ class _syncHealthDataButtonState extends State<syncHealthDataButton> {
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'];

@ -28,13 +28,13 @@ var _InAppBrowserOptions = InAppBrowserClassOptions(
class MyInAppBrowser extends InAppBrowser {
_PAYMENT_TYPE paymentType;
static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT
// static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT
// static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE
static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE
static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT
// static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT
// static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store
static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store
// static String PRESCRIPTION_PAYMENT_WITH_ORDERID =
// 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID=';

@ -30,7 +30,7 @@ dependencies:
get_it: ^4.0.2
#Google Fit & Apple HealthKit
fit_kit: ^1.1.2
health: ^3.0.3
#chart
fl_chart: ^0.12.3

Loading…
Cancel
Save