private void GetOfflinePatients(string param)
        {
            string order_date = SelectedDate.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture);

            if (param.Equals("WardNo"))
            {
                var wbed        = SelectedBed != null ? (SelectedBed.bed_no == "All" ? "0" : SelectedBed.bed_no) : "0";
                var patientlist = new List <mstr_patient_info>();
                if (wbed == "0")
                {
                    patientlist = _patientRepo.QueryTable().Where(x => x.ward_name == SelectedWard.ward_name && x.meal_order_date == order_date).OrderBy(x => x.bed_no).ToList();
                }
                else
                {
                    patientlist = _patientRepo.QueryTable().Where(x => x.ward_name == SelectedWard.ward_name && x.bed_name == wbed && x.meal_order_date == order_date).OrderBy(x => x.bed_no).ToList();
                }


                Patients = new ObservableCollection <mstr_patient_info>(patientlist);

                if (!Patients.Any())
                {
                    DependencyService.Get <INotify>().ShowToast("No patient found!!");
                }
            }
            else
            {
                DisplayPatientListOnPatientsearch();
            }
        }
        public async void DisplayPatientListOnPatientsearch()
        {
            try
            {
                string format = SelectedDate.ToString("dd-MM-yy", CultureInfo.InvariantCulture);

                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    try
                    {
                        //start progessring
                        IsPageEnabled = true;
                        HttpClient httpClient = new System.Net.Http.HttpClient();

                        HttpRequestMessage  request  = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/PullpatientData_by_patientname/" + Library.KEY_USER_SiteCode + "/" + format + "/" + PatientName);
                        HttpResponseMessage response = await httpClient.SendAsync(request);

                        var data = await response.Content.ReadAsStringAsync();

                        // JArray jarray = JArray.Parse(data);

                        var pdataList = JsonConvert.DeserializeObject <ObservableCollection <mstr_patient_info> >(data);

                        if (!pdataList.Any())
                        {
                            IsPageEnabled = false;
                            DependencyService.Get <INotify>().ShowToast("No patient found!!");
                            return;
                        }


                        foreach (var item in pdataList)
                        {
                            item.ward_bed = item.ward_name + "-" + item.bed_name;
                            item.ID       = item.ID;
                            if (string.Equals(item.is_care_giver, "true", StringComparison.CurrentCultureIgnoreCase))
                            {
                                item.Patientname = item.Patientname + ' ' + "(Care Giver)";
                            }
                        }

                        Patients      = new ObservableCollection <mstr_patient_info>(pdataList);
                        IsPageEnabled = false;
                    }
                    catch (Exception excp)
                    {
                        // stop progressring
                        IsPageEnabled = false;
                    }
                }
                else
                {
                    var data = _patientRepo.QueryTable().Where(x => x.Patientname == PatientName && x.meal_order_date == format).OrderBy(y => y.Patientname);
                    Patients = new ObservableCollection <mstr_patient_info>(data);
                }
            }
            catch (Exception)
            {
            }
        }
Пример #3
0
        private async Task InserOrderLocal(mstr_meal_order_local p)
        {
            try
            {
                var db = DependencyService.Get <IDBInterface>().GetConnection();


                db.RunInTransaction(() =>
                {
                    db.Insert(p);
                });
                MessagingCenter.Send <App, string>((App)Xamarin.Forms.Application.Current, "LocalOrder", "lorder");

                var action = await PageDialog.DisplayAlertAsync("Alert!!", " Your order is Saved Locally ,it will be confirmed when Internet is available and syncing from menu bar. Do you want to place order for same patient?", "Yes", "No");

                if (action)
                {
                    await NavigationService.GoBackAsync(new NavigationParameters { { "NewOrder", "order" } });
                }
                else
                {
                    await NavigationService.NavigateAsync("../../../");
                }
            }
            catch (Exception)
            {
            }
        }
Пример #4
0
 private void ShowToastNotification(string title, string body)
 {
     if (isMenuNotificationAvailable || isMstrNotificationAvailable)
     {
         DependencyService.Get <INotify>().ShowLocalNotification(title, body);
     }
 }
Пример #5
0
        private async Task InserOrderLocal(mstr_meal_order_local p)
        {
            try
            {
                var db = DependencyService.Get <IDBInterface>().GetConnection();


                db.RunInTransaction(() =>
                {
                    db.Insert(p);
                });
                MessagingCenter.Send <App, string>((App)Xamarin.Forms.Application.Current, "LocalOrder", "lorder");

                var action = await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("yoff", AppResources.Culture), "Yes", "No");

                if (action)
                {
                    await NavigationService.GoBackAsync(new NavigationParameters { { "NewOrder", "order" } });
                }
                else
                {
                    await NavigationService.NavigateAsync("../../../");
                }
            }
            catch (Exception)
            {
            }
        }
Пример #6
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService)
            : base(navigationService, pageDialogService)
        {
            Title             = "Main Page";
            PrintMessage      = "";
            _blueToothService = DependencyService.Get <IBluetoothService>();
            _printer          = new Printer();
            BindDeviceList();

            PrintCommand = new DelegateCommand(async() =>
            {
                if (String.IsNullOrEmpty(SelectedDevice))
                {
                    await PageDialogService.DisplayAlertAsync("Please select a Bluetooh Printer...", null, "Ok");
                }
                else
                {
                    _printer.MyPrinter = SelectedDevice;
                    if (String.IsNullOrEmpty(PrintMessage))
                    {
                        await PageDialogService.DisplayAlertAsync("Field to Print can not be empty...", null, "Ok");
                    }
                    else
                    {
                        await _printer.Reset();
                        await _printer.SetAlignCenter();
                        await _printer.WriteLine($"Normal: {PrintMessage}");
                        await _printer.LineFeed();
                        await _printer.BoldOn();
                        await _printer.WriteLine($"Bold: {PrintMessage}");
                        await _printer.BoldOff();
                        await _printer.LineFeed();
                        await _printer.WriteLine_Big($"Grande: \n{PrintMessage}");
                        await _printer.LineFeed();
                        await _printer.SetUnderLine($"Subrayado: {PrintMessage}");
                        await _printer.LineFeed();
                        await _printer.SetAlignRight();
                        await _printer.WriteLine_Bold("Negrito en la Derecha:");
                        await _printer.BoldOn();
                        await _printer.WriteLine_Bigger($"G1: {PrintMessage}", 1);
                        await _printer.BoldOff();
                        await _printer.WriteLine_Bold("Underline...");
                        await _printer.SetUnderLineOn();
                        await _printer.WriteLine_Bigger($"G2: {PrintMessage}", 2);
                        await _printer.WriteLine_Bigger($"G3: {PrintMessage}", 3);
                        await _printer.SetUnderLineOff();
                        await _printer.LineFeed(2);
                        await _printer.SetAlignCenter();
                        await _printer.WriteLine_Bold("Texto Reverse...");
                        await _printer.SetReverseOn();
                        await _printer.WriteLine_Bigger($"Reverse: {PrintMessage}", 1);
                        await _printer.SetReverseOff();
                        await _printer.WriteLine_Bigger($"Not Reverse: {PrintMessage}", 1);
                        await _printer.LineFeed(3);
                        await _printer.Reset();
                    }
                }
            });
        }
Пример #7
0
        protected override void OnInitialized()
        {
            var credentialService = DependencyService.Get <ICredentialsService>();

            NavigationService.NavigateAsync(credentialService.DoCredentialsExist()
                ? new Uri("/NavigationPage/DashboardPage", UriKind.Absolute)
                : new Uri("/NavigationPage/AccountCreatePage", UriKind.Absolute));
        }
        private async void CancelBtn_Clicked(object sender, EventArgs e)
        {
            var selectedRecord = (sender as Button).BindingContext as mstr_meal_history;

            if (string.IsNullOrEmpty(selectedRecord.remarks))
            {
                var msg = Library.KEY_USER_LANGUAGE == "Thai" ? "กรุณาใส่ข้อสังเกต" : "Please Enter Remarks";
                await PageDialog.DisplayAlertAsync("Error!!", msg, "OK");

                return;
            }
            else
            {
                dynamic p = new JObject();
                p.Id              = selectedRecord.Id;//id;
                p.createdby       = selectedRecord.createdby;
                p.meal_detail_id  = selectedRecord.meal_detail_id;
                p.mealtimeid      = selectedRecord.mealtimeid;
                p.mealtimename    = selectedRecord.mealtimename;
                p.orderdate       = selectedRecord.orderdate;
                p.remark          = selectedRecord.remarks;
                p.ward_bed        = "";
                p.wardid          = "";
                p.work_station_IP = DependencyService.Get <ILocalize>().GetIpAddress();
                p.system_module   = DependencyService.Get <ILocalize>().GetDeviceName();//GetMachineNameFromIPAddress(p.work_station_IP);

                string json = JsonConvert.SerializeObject(p);

                var httpClient = new HttpClient();

                var result = await httpClient.PostAsync($"{Library.URL}/OrderCanceled", new StringContent(json, Encoding.UTF8, "application/json"));

                var contents = await result.Content.ReadAsStringAsync();


                if (contents == "true")
                {
                    await PageDialog.DisplayAlertAsync("Alertt!!", AppResources.ResourceManager.GetString("ml1", AppResources.Culture), "OK");

                    HistoryList.ItemsSource = new List <mstr_meal_history>();
                    PatientMealHistoryList.Remove(selectedRecord);
                    HistoryList.ItemsSource = PatientMealHistoryList;
                    IsChanged = true;
                }
                else
                {
                    await DisplayAlert("", AppResources.ResourceManager.GetString("ml12", AppResources.Culture), "OK");
                }

                if (!PatientMealHistoryList.Any())
                {
                    await Navigation.PopAllPopupAsync();
                }
            }
        }
 private async void FillMealTime()
 {
     try
     {
         var db = DependencyService.Get <IDBInterface>().GetConnection();
         MealTimeList = new ObservableCollection <mstr_meal_time>(db.Query <mstr_meal_time>("Select * From mstr_meal_time where status_id ='1' order by ID"));
     }
     catch (Exception exp)
     {
         await PageDialog.DisplayAlertAsync("Alert!!", exp.Message, "OK");
     }
 }
        private async void FillWard()
        {
            try
            {
                var db = DependencyService.Get <IDBInterface>().GetConnection();

                WardData = new ObservableCollection <mstr_ward_details>(db.Query <mstr_ward_details>("Select ID,ward_name From mstr_ward_details where ward_type_name not like '%staff%' and status_id ='1' order by ID"));
                //SelectedWard = WardData.FirstOrDefault();
            }
            catch (Exception exp)
            {
                await PageDialog.DisplayAlertAsync("Alert!!", exp.Message, "OK");
            }
        }
        private async void SelectionForFoodAllergies()
        {
            var response = await DependencyService.Get <INotify>().ShowAlert("Alert!", "Choose preferred menu", "Allergic Menu", "Regular Menu");

            if (response == "Allergic Menu")
            {
                // IsAllergiesEnable = true;
                Library.IsFAGeneralEnable = true;
            }
            else
            {
                //IsAllergiesEnable = false;
                Library.IsFAGeneralEnable = false;
            }
        }
 protected async Task Reload(StatesPageViewModel instance)
 {
     var hud = DependencyService.Get <IHud>();
     await Task.Run(() => {
         try
         {
             Thread.Sleep(100);
             instance.ReloadItems();
             hud.Hide();
         }
         catch (Exception e)
         {
             hud.Hide();
             UserDialogs.Instance.Alert("Exception:" + e.Message, "Error", "Ok");
         }
     });
 }
Пример #13
0
        internal async void NavigateToInfoPage(mstr_patient_info patient)
        {
            IsPageEnabled = true;

            var sqlite         = DependencyService.Get <IDBInterface>().GetConnection();
            var MasterMenuInfo = sqlite.Table <mstr_menu_master>();

            if (!MasterMenuInfo.Any())
            {
                await PageDialog.DisplayAlertAsync("Alert!!", "Please sync 'Sync Menu Items' from drawer menu to proceed further.", "OK");

                Library.KEY_SYNC_NOTIFICATION = "1";
                IsPageEnabled = false;
                return;
            }

            if (patient.is_care_giver)
            {
                return;
            }


            if (Library.KEY_USER_ROLE == "FSA")
            {
                if (!String.IsNullOrEmpty(patient.Last_Order_by))
                {
                    AssignPatientInfo(patient);
                }
                else
                {
                    IsPageEnabled = false;
                    await PageDialog.DisplayAlertAsync("Alert!!", "SORRY, You Are Not Authorised To Take First Order Of Patient", "OK");

                    return;
                }
            }
            else
            {
                AssignPatientInfo(patient);
            }

            await NavigationService.NavigateAsync($"{nameof(PatientInformationPage)}", new NavigationParameters { { "PatientInfo", patient } });

            IsPageEnabled = false;
        }
Пример #14
0
        public async Task GetPatientsFromServer()
        {
            var wbed = 0;

            try
            {
                if (SelectedWard == null)
                {
                    return;
                }

                IsPageEnabled = true;
                string format = SelectedDate.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture);
                wbed = SelectedBed != null ? SelectedBed.ID : 0;
                var patientsData = await _patientManager.GetPatientsByWardBed(format, SelectedWard.ID, wbed);

                if (!patientsData.Any())
                {
                    IsPageEnabled = false;
                    DependencyService.Get <INotify>().ShowToast("No patient found!!");
                    return;
                }

                foreach (var patient in patientsData)
                {
                    patient.ward_bed = $"{patient.ward_name}-{patient.bed_name}";
                    if (patient.is_care_giver)
                    {
                        patient.Patientname = $"{patient.Patientname} (Care Giver {patient.caregiverno})";
                    }
                    patient.Therapeutic_Condition = string.IsNullOrEmpty(patient.Therapeutic_Condition) ? "NA" : patient.Therapeutic_Condition;
                }

                var list = patientsData.OrderBy(x => x.bed_no);
                Patients = new ObservableCollection <mstr_patient_info>(list);

                IsPageEnabled = false;
            }
            catch (Exception ex)
            {
                IsPageEnabled = false;
                await PageDialog.DisplayAlertAsync("Alert!!", ex.Message, "OK");
            }
        }
Пример #15
0
        public async Task HandleWidgetAction()
        {
            var credentialService = DependencyService.Get <ICredentialsService>();

            //
            //  unable to resume activity ???   prism error

//            await NavigationService.NavigateAsync(credentialService.DoCredentialsExist()
//                ? new Uri("/NavigationPage/DashboardPage", UriKind.Absolute)
//                : new Uri("/NavigationPage/AccountCreatePage", UriKind.Absolute));
            if (credentialService.DoCredentialsExist())
            {
                await Current.MainPage.Navigation.PushAsync(new DashboardPage());
            }
            else
            {
                await Current.MainPage.Navigation.PushAsync(new AccountCreatePage());
            }
        }
Пример #16
0
        public MapPageViewModel(INavigationService navigationService,
                                IFirebaseHelper firebaseHelper,
                                IDialogService dialogService,
                                IEventAggregator eventAggregator,
                                IPageDialogService pageDialogService
                                )
        {
            _navigationService = navigationService;
            _dialogService     = dialogService;
            _eventAggregator   = eventAggregator;
            _pageDialogService = pageDialogService;
            _firebaseHelper    = firebaseHelper;

            _firebaseAuth = DependencyService.Get <IFirebaseAuthentication>();

            PinDragStartCommand = new DelegateCommand <PinDragEventArgs>((args) => PinDragStart(args));
            PinDragEndCommand   = new DelegateCommand <PinDragEventArgs>((args) => PinDragEnd(args));
            PinDraggingCommand  = new DelegateCommand <PinDragEventArgs>((args) => PinDragging(args));
            MapClickedCommand   = new DelegateCommand <MapClickedEventArgs>((args) => MapTappedToCreatePin(args));
            LogOutCommand       = new DelegateCommand(() => LogOut());

            Pins = new ObservableCollection <Pin>();
        }
Пример #17
0
        public async Task InsertIntoMealOrder()
        {
            try
            {
                int mtype1 = 0;
                int mtype2 = 0;
                int mtype3 = 0;


                int mymeal_time_id = MealTime.ID;


                if (MealTime.meal_name == "Breakfast")
                {
                    if (Others.ID == 1 || Others.ID == 9 || Others.ID == 10)
                    {
                        mtype1 = 3;
                    }
                    else
                    {
                        mtype1 = 1;
                    }
                }
                else if (MealTime.meal_name == "Lunch")
                {
                    if (Others.ID == 1 || Others.ID == 9 || Others.ID == 10)
                    {
                        mtype2 = 3;
                    }
                    else
                    {
                        mtype2 = 1;
                    }
                }
                else if (MealTime.meal_name == "Dinner")
                {
                    if (Others.ID == 1 || Others.ID == 9 || Others.ID == 10)
                    {
                        mtype3 = 3;
                    }
                    else
                    {
                        mtype3 = 1;
                    }
                }
                else
                {
                    mtype1 = 0;
                    mtype2 = 0;
                    mtype3 = 0;
                }


                int _meal_soup_id            = 0;
                int _meal_menu_juice_item_id = 0;
                int _meal_entree_id          = 0;
                int _meal_beverage_id        = 0;
                int _meal_desert_id          = 0;



                var entreecount = carts.Where(item => item.mealtimename.ToLower().Contains("entree".ToLower()) || item.mealtimename.ToLower().Contains("entrée".ToLower())).FirstOrDefault();
                var soupcount   = carts.Where(item => item.mealtimename.ToLower().Contains("soup".ToLower())).FirstOrDefault();
                var juicecount  = carts.Where(item => item.mealtimename.ToLower().Contains("juice".ToLower())).FirstOrDefault();
                var bevcount    = carts.Where(item => item.mealtimename.ToLower().Contains("beverage".ToLower())).FirstOrDefault();
                var desscount   = carts.Where(item => item.mealtimename.ToLower().Contains("dessert".ToLower())).FirstOrDefault();

                if (soupcount != null)
                {
                    _meal_soup_id = Convert.ToInt32(soupcount.mealitemid.ToString() == null ? "1" : soupcount.mealitemid.ToString());
                }
                if (juicecount != null)
                {
                    _meal_menu_juice_item_id = Convert.ToInt32(juicecount.mealitemid.ToString() == null ? "1" : juicecount.mealitemid.ToString());
                }

                if (entreecount != null)
                {
                    _meal_entree_id = Convert.ToInt32(entreecount.mealitemid.ToString() == null ? "1" : entreecount.mealitemid.ToString());
                }
                if (bevcount != null)
                {
                    _meal_beverage_id = Convert.ToInt32(bevcount.mealitemid.ToString() == null ? "1" : bevcount.mealitemid.ToString());
                }
                if (desscount != null)
                {
                    _meal_desert_id = Convert.ToInt32(desscount.mealitemid.ToString() == null ? "1" : desscount.mealitemid.ToString());
                }


                string _Therapeutic_ids;
                string _ingredeint_ids;   //optional
                string _allergies_ids;    //optional

                string _other_ids   = ""; //optional
                string _cusinie_ids = "";

                var theraArray = Therapeutics.Select(x => x.ID).ToArray();
                _Therapeutic_ids = string.Join(",", theraArray);

                var ingridentArray = Ingredients.Select(x => x.ID).ToArray();
                _ingredeint_ids = string.Join(",", ingridentArray);

                var allergyArray = Allergies.Select(x => x.ID).ToArray();
                _allergies_ids = string.Join(",", allergyArray);

                var cusinieArray = Cuisines.Select(x => x.ID).ToArray();
                _cusinie_ids = string.Join(",", cusinieArray);


                var otehrArray = OthersList.Select(x => x.ID).ToArray();
                _other_ids = string.Join(",", otehrArray);

                var p = new mstr_meal_order_local();
                p.isdietician       = false;
                p.is_staff          = false;
                p.staff_name        = "";
                p.dietician_comment = "";

                p.age_id       = Convert.ToInt32(Patient.Age_ID);
                p.ward_id      = Convert.ToInt32(Patient.Ward_ID);
                p.ward_type_id = Library.KEY_PATIENT_WARD_TYPE_ID;

                p.bed_id = Convert.ToInt32(Patient.Bed_ID);


                p.is_vegitarian = Convert.ToBoolean(Patient.isveg);
                p.is_halal      = Convert.ToBoolean(Patient.ishalal);



                p.disposable_tray = Library.IsDisposableEnable;



                p.order_id   = Convert.ToInt32(Library.KEY_ORDER_ID);
                p.order_date = Library.KEY_ORDER_DATE;

                p.order_no = "1";



                p.site_code = Patient.Site_Code;

                p.createdby = Convert.ToInt32(Library.KEY_USER_ID);

                p.meal_option_id          = MealOption.ID;
                p.meal_diet_id            = DietType.ID;
                p.meal_soup_id            = _meal_soup_id;
                p.meal_menu_juice_item_id = _meal_menu_juice_item_id;
                p.meal_entree_id          = _meal_entree_id;
                p.meal_beverage_id        = _meal_beverage_id;
                p.meal_desert_id          = _meal_desert_id;


                p.P_id = Patient.ID;
                p.BF   = mtype1;
                p.LH   = mtype2;
                p.DN   = mtype3;

                p.Therapeutic_ids = _Therapeutic_ids;
                p.Meal_Type       = _cusinie_ids;
                p.ingredeint_ids  = _ingredeint_ids;

                if (_other_ids == "NA" || _other_ids == "0")
                {
                    p.other_ids = "";
                }
                else
                {
                    p.other_ids = _other_ids;
                }
                p.allergies_ids = _allergies_ids;


                if (carts.Any())
                {
                    var data = carts.Where(x => x.addonid != 0).FirstOrDefault();
                    if (data == null)
                    {
                        p.meal_addon_id = 0;
                    }
                    else
                    {
                        p.meal_addon_id = data.addonid;
                    }
                }
                else
                {
                    p.meal_addon_id = 0;
                }


                p.meal_time_id = mymeal_time_id;
                p.meal_type_id = 0;
                p.remark_id    = 0;

                p.meal_remark = Remarks;


                p.ID               = 10;
                p.adult_child      = Patient.category;
                p.bedclass_id      = Convert.ToInt32(Patient.Bed_Class_ID);
                p.bedclass_name    = Patient.Bed_Class_Name;
                p.doctor_comment   = Patient.Doctorcomment;
                p.general_comment  = Patient.Generalcomment;
                p.patient_age      = Patient.Patient_Age;
                p.patient_id       = Patient.ID;//23;//Library.KEY_PATIENT_NRIC);// Library.KEY_PATIENT_ID);
                p.patient_name     = Patient.Patientname;
                p.patient_race     = Patient.patient_race;
                p.preferred_server = Patient.Preferredserver;
                p.ward_bed         = Patient.ward_bed;
                p.Is_Late_Ordered  = Convert.ToInt32(Library.KEY_IS_LATE_ORDERED);
                p.role             = Library.KEY_USER_ROLE.ToString();

                if (Others.ID == 1)
                {
                    p.orderstatus = "3";
                }
                else if (Others.ID == 9)
                {
                    p.orderstatus = "5";
                }
                else if (Others.ID == 10)
                {
                    p.orderstatus = "6";
                }
                else
                {
                    p.orderstatus = "0";
                }

                p.is_care_giver   = false;
                p.mode_of_payment = 0;
                p.payment_remark  = "";


                //p.Fluid_Consistency = Library.KEY_FLUID_INFO;
                p.fluid           = Patient.FluidInfo == "NA" ? 0 : 1; // temporary need to fix(20/6/819)
                p.role_Id         = Convert.ToInt32(Library.KEY_USER_roleid);
                p.work_station_IP = DependencyService.Get <ILocalize>().GetIpAddress();
                p.system_module   = Xamarin.Forms.DependencyService.Get <ILocalize>().GetDeviceName(); //GetMachineNameFromIPAddress(p.work_station_IP);

                //-----------------

                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    try
                    {
                        // Serialize our concrete class into a JSON String
                        //var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(p));
                        string stringPayload = JsonConvert.SerializeObject(p);
                        // Wrap our JSON inside a StringContent which then can be used by the HttpClient class
                        var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");

                        // display a message jason conversion
                        //var message1 = new MessageDialog("Data is converted in json.");
                        //await message1.ShowAsync();

                        using (var httpClient = new System.Net.Http.HttpClient())
                        {
                            var httpResponse = new System.Net.Http.HttpResponseMessage();
                            // Do the actual request and await the response
                            if (Library.KEY_IS_CARE_GIVER.ToString() == "yes")
                            {
                                httpResponse = await httpClient.PostAsync(Library.URL + "/" + Library.METHODE_SAVEORDER, httpContent);
                            }
                            else if (Convert.ToInt32(Library.KEY_ORDER_ID) > 0)
                            {
                                // httpResponse = new Uri(URL + "/" + Library.METHODE_UPDATE_ORDER); //replace your Url
                                httpResponse = await httpClient.PostAsync(Library.URL + "/" + Library.METHODE_UPDATE_ORDER, httpContent);
                            }
                            else
                            {
                                // httpResponse = new Uri(URL + "/" + Library.METHODE_SAVEORDER); //replace your Url
                                httpResponse = await httpClient.PostAsync(Library.URL + "/" + Library.METHODE_SAVEORDER, httpContent);
                            }
                            // display a message jason conversion
                            //var message2 = new MessageDialog(httpResponse.ToString());
                            //await message2.ShowAsync();
                            //var httpResponse = await httpClient.PostAsync(URL + "/" + Library.METHODE_SAVEORDER, httpContent);

                            // If the response contains content we want to read it!
                            if (httpResponse.Content != null)
                            {
                                var responseContent = await httpResponse.Content.ReadAsStringAsync();

                                if (responseContent == "true")
                                {
                                    if (p.Is_Late_Ordered == 1)
                                    {
                                        var orderAction = await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("lateorder", AppResources.Culture), "Yes", "No");
                                        await OrderConfirmationMsg(orderAction);
                                    }
                                    else
                                    {
                                        var action = await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("yo", AppResources.Culture), "Yes", "No");
                                        await OrderConfirmationMsg(action);
                                    }
                                }
                                else
                                {
                                    await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("yon", AppResources.Culture), "OK");
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        await InserOrderLocal(p);
                    }
                }
                else
                {
                    await InserOrderLocal(p);
                }
            }
            catch (Exception excp)
            {
                await PageDialog.DisplayAlertAsync("Alert!!", excp.Message, "OK");
            }
        }
        private async void NavigateToOrderPage(string obj)
        {
            IsPageEnabled = true;
            if (obj.Equals("Update"))
            {
                await UpdatePatientInfo();
            }
            else
            {
                IsPageEnabled = true;


                if (!Library.KEY_PATIENT_IS_VEG.Equals(SelectedPatient.isveg) || !Library.KEY_PATIENT_IS_HALAL.Equals(SelectedPatient.ishalal))
                {
                    var response = await PageDialog.DisplayAlertAsync("Meal Prefrence Changed!", "Do you want to Change the (Veg/Nonveg)/(Halal/Non-Halal) Status.", "Yes", "No");

                    if (response)
                    {
                        Library.KEY_PATIENT_IS_VEG   = SelectedPatient.isveg;
                        Library.KEY_PATIENT_IS_HALAL = SelectedPatient.ishalal;
                    }
                    else
                    {
                        IsPageEnabled = false;
                        return;
                    }
                }

                #region Future_Order

                bool isChangeTher        = CompareStrings(string.IsNullOrEmpty(SelectedPatient.Therapeutic) ? string.Empty : SelectedPatient.Therapeutic, Therapeutics.Where(x => x.IsChecked).Select(x => x.TH_code).ToList());
                bool isChangeAllergy     = CompareStrings(SelectedPatient.Allergies == "0" ? string.Empty : SelectedPatient.Allergies, Allergies.Where(x => x.IsChecked).Select(x => x.ID.ToString()).ToList());
                bool isChangeIngredient  = CompareStrings(string.IsNullOrEmpty(SelectedPatient.Ingredient) ? string.Empty : SelectedPatient.Ingredient, Ingredients.Where(x => x.IsChecked).Select(x => x.ingredient_name).ToList());
                bool isChangeDietTexture = CompareStrings(string.IsNullOrEmpty(SelectedPatient.Diet_Texture) ? string.Empty : SelectedPatient.Diet_Texture, DietTextures.Where(x => x.IsChecked).Select(x => x.diet_texture_name).ToList());
                bool isChangeMealType    = CompareStrings(string.IsNullOrEmpty(SelectedPatient.Meal_Type) ? string.Empty : SelectedPatient.Meal_Type, Cuisines.Where(x => x.IsChecked).Select(x => x.meal_type_name).ToList());

                bool isChange = (isChangeTher || isChangeAllergy || isChangeIngredient || isChangeDietTexture || isChangeMealType);

                if (isChangeMealType && !isChangeTher && !isChangeAllergy && !isChangeIngredient && !isChangeDietTexture)
                {
                    bool resp = await PageDialog.DisplayAlertAsync("", $"Patient's cuisine choice has been changed, \npress OK to proceed", "OK", "Cancel");

                    if (!resp)
                    {
                        IsPageEnabled = false;
                        return;
                    }
                }
                else
                {
                    if (isChange)
                    {
                        if (CrossConnectivity.Current.IsConnected)
                        {
                            string check_order_date = Library.KEY_CHECK_ORDER_DATE;

                            HttpClient          httpClientGet = new System.Net.Http.HttpClient();
                            HttpRequestMessage  request       = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/checkfutureorder/" + check_order_date + "/" + SelectedPatient.ID);
                            HttpResponseMessage response      = await httpClientGet.SendAsync(request);

                            // jarray= await response.Content.ReadAsStringAsync();
                            var data = await response.Content.ReadAsStringAsync();

                            if (data != "\"NULL\"" && data != string.Empty)
                            {
                                List <string> alertMsg = new List <string>();


                                if (isChangeTher)
                                {
                                    alertMsg.Add("Therapeutic Condition");
                                }
                                if (isChangeAllergy)
                                {
                                    alertMsg.Add("Allergic Condition");
                                }
                                if (isChangeIngredient)
                                {
                                    alertMsg.Add("Ingredient exclusion");
                                }

                                if (isChangeDietTexture)
                                {
                                    alertMsg.Add("Diet Texture");
                                }
                                if (isChangeMealType)
                                {
                                    alertMsg.Add("Cuisine Choice");
                                }

                                var msgArray = alertMsg.ToArray();
                                var msgStr   = string.Join(",", msgArray);
                                msgStr = msgStr.Replace(",", " and ");

                                var result = await DependencyService.Get <INotify>().ShowAlert("Preference Changed!!", $"Patient’s {msgStr} has been changed. Do you want to delete the future order of this patient?", "Yes", "No", "Cancel");

                                if (result == "Yes")
                                {
                                    dynamic p = new JObject();

                                    p.orderdetailsids = data.Replace("\"", "");
                                    p.system_module   = DependencyService.Get <ILocalize>().GetDeviceName();
                                    p.work_station_IP = DependencyService.Get <ILocalize>().GetIpAddress();

                                    string json = JsonConvert.SerializeObject(p);

                                    var httpClient = new HttpClient();

                                    var msg = await httpClient.PostAsync($"{Library.URL}/DeleteunprocessOrder", new StringContent(json, Encoding.UTF8, "application/json"));

                                    var contents = await msg.Content.ReadAsStringAsync();

                                    if (!string.IsNullOrEmpty(contents))
                                    {
                                        await PageDialog.DisplayAlertAsync("Delete", $"Total Orders deleted : {contents}", "OK");
                                    }
                                }
                                else if (result == "Cancel")
                                {
                                    IsPageEnabled = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            IsPageEnabled = false;
                            await PageDialog.DisplayAlertAsync("Error!!", "Unable to change patient settings during offline mode. Please undo the changes and try again", "OK");

                            return;
                        }
                    }
                }

                #endregion

                var navParam = new NavigationParameters();
                navParam.Add("Patient", SelectedPatient);
                navParam.Add("Allergies", Allergies.Where(x => x.IsChecked).ToList());
                navParam.Add("Ingredients", Ingredients.Where(x => x.IsChecked).ToList());
                navParam.Add("Therapeutics", Therapeutics.Where(x => x.IsChecked).ToList());
                navParam.Add("DietTextures", DietTextures.Where(x => x.IsChecked).ToList());
                navParam.Add("Cuisines", Cuisines.Where(x => x.IsChecked).ToList());
                navParam.Add("Other", OthersRadio.Where(x => x.IsChecked).FirstOrDefault());
                navParam.Add("Othercheckbox", OthersChecBox.Where(x => x.IsChecked).ToList());

                await NavigationService.NavigateAsync(nameof(MealOrderPage), navParam);

                IsPageEnabled = false;
            }
        }
        public override void OnNavigatingTo(NavigationParameters parameters)
        {
            var hud = DependencyService.Get <IHud>();

            hud.Show();
        }
        public async Task GetMealDeliveredData()
        {
            try
            {
                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    try
                    {
                        MealDeliveredCollection = new ObservableCollection <mstr_mealdelivered>();
                        IsPageEnabled           = true;

                        HttpClient httpClient = new System.Net.Http.HttpClient();

                        DateTime dt = SelectedDate;

                        string format_date = dt.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);

                        HttpRequestMessage  request  = new HttpRequestMessage(HttpMethod.Get, Library.URL + "/" + Library.METHODE_GETDELIVEREDDATA + "/" + format_date + "/" + SelectedMealTime.ID + "/" + Library.KEY_USER_ccode + "/" + Library.KEY_USER_regcode + "/" + Library.KEY_USER_siteid);
                        HttpResponseMessage response = await httpClient.SendAsync(request);

                        var data = await response.Content.ReadAsStringAsync();

                        var orderData = JsonConvert.DeserializeObject <ObservableCollection <mstr_mealdelivered> >(data);

                        if (!orderData.Any())
                        {
                            IsPageEnabled = false;
                            DependencyService.Get <INotify>().ShowToast("No records found!!");
                            return;
                        }


                        foreach (var item in orderData)
                        {
                            item.istrue = false;
                            if (!SelectedBed.bed_no.Equals("All"))
                            {
                                if (item.Ward == SelectedWard.ward_name && item.Bed == SelectedBed.bed_no && item.MealTime == SelectedMealTime.meal_name)
                                {
                                    if ((IsCareGiver) && (item.Guest.ToLowerInvariant() == "True".ToLowerInvariant()))
                                    {
                                        MealDeliveredCollection.Add(item);
                                    }
                                    if (!IsCareGiver && (item.Guest.ToLowerInvariant() == "False".ToLowerInvariant()))
                                    {
                                        MealDeliveredCollection.Add(item);
                                    }
                                }
                            }
                            else
                            {
                                if (item.Ward == SelectedWard.ward_name && item.MealTime == SelectedMealTime.meal_name)
                                {
                                    if (IsCareGiver && (item.Guest.ToLowerInvariant() == "True".ToLowerInvariant()))
                                    {
                                        MealDeliveredCollection.Add(item);
                                    }
                                    if (!IsCareGiver && (item.Guest.ToLowerInvariant() == "False".ToLowerInvariant()))
                                    {
                                        MealDeliveredCollection.Add(item);
                                        //await DisplayAlert("alert", item.is_verifed.ToString(), "OK");
                                    }
                                }
                                else
                                {
                                    //if ((is_caregiver == true) && (item.Guest == "True"))
                                    //{

                                    //    meal_deliveredNew.Add(item);

                                    //}
                                    //if (!is_caregiver && (item.Guest == "False"))
                                    //{

                                    //    meal_deliveredNew.Add(item);
                                    //}
                                }
                            }



                            // stop
                            IsPageEnabled = false;
                        }

                        if (!MealDeliveredCollection.Any())
                        {
                            IsPageEnabled = false;
                            DependencyService.Get <INotify>().ShowToast("No records found!!");
                            return;
                        }
                    }
                    catch (Exception excp)
                    {
                        // stop progressring
                        IsPageEnabled = false;
                    }
                    IsPageEnabled = false;
                }
                else
                {
                    await PageDialog.DisplayAlertAsync("Alert!!", AppResources.ResourceManager.GetString("msg10", AppResources.Culture), "OK");

                    IsPageEnabled = false;
                }
            }
            catch (Exception excp)
            {
                // stop progressring
                IsPageEnabled = false;
            }
        }