private async void Therapeutic_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "IsChecked")
            {
                var checkedTH = sender as mstr_therapeutic;
                if (checkedTH.IsChecked)
                {
                    var checkedQuery = Therapeutics.Where(x => x.IsChecked == true && !string.IsNullOrEmpty(x.TH_Condition) &&
                                                          x.TH_Condition == checkedTH.TH_Condition && x.TH_code != checkedTH.TH_code);

                    if (checkedQuery.Any())
                    {
                        var str1 = $"You have already selected {checkedQuery.First().TH_Condition} option , Do you want to remove {checkedQuery.FirstOrDefault().TH_code} option.";

                        var response = await PageDialog.DisplayAlertAsync("Alert!!", str1, "YES", "NO");

                        if (response)
                        {
                            var previous = Therapeutics.Where(x => x.TH_code == checkedQuery.FirstOrDefault().TH_code).FirstOrDefault();
                            previous.IsChecked = false;
                        }
                        else
                        {
                            checkedTH.IsChecked = false;
                        }
                    }
                }
            }
        }
示例#2
0
        private async void NavigateToOrderPage(string obj)
        {
            IsPageEnabled = true;
            if (obj.Equals(AppResources.ResourceManager.GetString("btnupdateContent", AppResources.Culture)))
            {
                await UpdatePatientInfo();
            }
            else
            {
                IsPageEnabled = true;
                if (!Library.KEY_PATIENT_IS_VEG.ToLower().Equals(SelectedPatient.isveg.ToLower()) || !Library.KEY_PATIENT_IS_HALAL.ToLower().Equals(SelectedPatient.ishalal.ToLower()))
                {
                    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;
                    }
                }



                var navParam = new NavigationParameters();

                //navParam.Add("Patient", SelectedPatient);
                Library.patient = SelectedPatient;
                Library.others  = OthersRadio.Where(x => x.IsChecked).FirstOrDefault();
                navParam.Add("Cuisineslist", Cuisines);
                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("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("MealOrderPage", navParam);

                IsPageEnabled = false;
            }
        }
示例#3
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;
            }
        }