Пример #1
0
 public BookAppointmentDetails(int MPID, MedicalPractitionerType MPType, ImageSource MPImage, String MedPractName, String Address, String BookingTime)
 {
     this.MPID         = MPID;
     this.MPType       = MPType;
     this.MPImage      = MPImage;
     this.MedPractName = MedPractName;
     this.Address      = Address;
     this.BookingTime  = BookingTime;
 }
Пример #2
0
 public MedPractProfileDetails(int MPID, MedicalPractitionerType MPType, double Stars, double Fee, String WorkTime, double Location, ImageSource MPImage, String MPName, String Address, String Description)
 {
     this.MPID        = MPID;
     this.MPType      = MPType;
     this.Stars       = Stars;
     this.Fee         = Fee;
     this.WorkTime    = WorkTime;
     this.Location    = Location;
     this.MPImage     = MPImage;
     this.MPName      = MPName;
     this.Address     = Address;
     this.Description = Description;
 }
        public BookAppointmentDoctor(int MPID, MedicalPractitionerType MPType, ImageSource MPImage, String MedPractName, String Address, String BookingTime)
        {
            try
            {
                InitializeComponent();
                _CountryCode.Items.Add("+234");
                _CountryCode.Items.Add("+235");
                _CountryCode.Items.Add("+236");
                _CountryCode.SelectedIndex = 0;

                dp_doctor.Source = MPImage;
                this.MPID        = MPID;
                this.MPType      = MPType;
            }
            catch (Exception ex) { DisplayAlert("Alert", ex.Message, "Ok"); }
        }
        public static async Task ListMedicalPractioner(StackLayout Stack, MedicalPractitionerType MPType)
        {
            Device.BeginInvokeOnMainThread(delegate { Stack.Children.Clear(); });

            //posting empty values as the PostAsync requires a FormUrlEncodedContent
            Dictionary <int, String[]> Data = new Dictionary <int, string[]>
            {
                { 0, new String[] { "n/a", "n/a" } },
            };

            String ResponseJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), (MPType == MedicalPractitionerType.Doctor)? "user/search/medics" : "user/search/institutions");

            var DecodedJson = JObject.Parse(ResponseJson);

            await Utilities.RunTask(async delegate
            {
                foreach (var Medic in DecodedJson["medics"])
                {
                    String MedicBioData = (MPType == MedicalPractitionerType.Doctor) ? await MedicalPractitionerController.GetBioDetails((int)Medic["medic"]["id"]) : "No Bio Data Provided";
                    MedicBioData        = (String.IsNullOrEmpty(MedicBioData) ? "No Bio Data provided." : MedicBioData);



                    Device.BeginInvokeOnMainThread(() =>
                    {
                        ///only add the child if it is of the same specialty type
                        //if ( Enum.GetName(typeof(MedicalPractitionerType),MPType) ==  ((MPType == MedicalPractitionerType.Doctor) ? Enum.GetName(typeof(MedicalPractitionerType), Medic["medic"]["specialty"]) : Enum.GetName(typeof(MedicalPractitionerType), Medic["specialty"]))) Stack.Children.Add(MedPractListTemplate.ListTemplate02((MPType == MedicalPractitionerType.Doctor) ? (int)Medic["medic"]["id"] : (int)Medic["id"], MPType, Medic["name"].ToString(), (MedicBioData.Length >= 25) ? MedicBioData.Substring(0, 25) : MedicBioData, new Random().Next(1, 6), Utilities.Source("doc_anim.jpg", typeof(AppointmentController)), 4.1, Medic["address"].ToString(), (MPType == MedicalPractitionerType.Doctor) ? Convert.ToDouble(Medic["medic"]["charge"]) : 0, String.Empty));
                        if (MPType == MedicalPractitionerType.Doctor)
                        {
                            Stack.Children.Add(MedPractListTemplate.ListTemplate02((MPType == MedicalPractitionerType.Doctor) ? (int)Medic["medic"]["id"] : (int)Medic["id"], MPType, Medic["name"].ToString(), (MedicBioData.Length >= 25) ? MedicBioData.Substring(0, 25) : MedicBioData, new Random().Next(1, 6), Utilities.Source("doc_anim.jpg", typeof(AppointmentController)), 4.1, Medic["address"].ToString(), (MPType == MedicalPractitionerType.Doctor) ? Convert.ToDouble(Medic["medic"]["charge"]) : 0, String.Empty));
                        }
                        else
                        {
                            if (Enum.GetName(typeof(MedicalPractitionerType), MPType).ToLower() == Medic["category"].ToString().ToLower())
                            {
                                Stack.Children.Add(MedPractListTemplate.ListTemplate02((int)Medic["id"], MPType, Medic["name"].ToString(), (MedicBioData.Length >= 25) ? MedicBioData.Substring(0, 25) : MedicBioData, new Random().Next(1, 6), Utilities.Source("doc_anim.jpg", typeof(AppointmentController)), 4.1, Medic["address"].ToString(), 0, String.Empty));
                            }
                        }
                    });
                }
            });
        }
        public static async Task SearchMedicalPractioner(String Name, MedicalPractitionerType MPType, StackLayout Stack)
        {
            Device.BeginInvokeOnMainThread(delegate
            {
                Stack.Children.Clear();
            });

            Dictionary <int, String[]> Data = new Dictionary <int, string[]>
            {
                { 0, new String[] { "name", Name } },
            };

            String ResponseJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), (MPType == MedicalPractitionerType.Doctor)? "user/search/medics" : "user/search/institutions");

            var DecodedJson = JObject.Parse(ResponseJson);

            await Utilities.RunTask(async delegate
            {
                foreach (var Medic in DecodedJson["medics"])
                {
                    String MedicBioData = (MPType == MedicalPractitionerType.Doctor) ? await MedicalPractitionerController.GetBioDetails((int)Medic["medic"]["id"]) : "No Bio Data Provided";
                    MedicBioData        = (String.IsNullOrEmpty(MedicBioData) ? "No Bio Data provided." : MedicBioData);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Stack.Children.Add(MedPractListTemplate.ListTemplate02((int)Medic["medic"]["id"], MPType, Medic["name"].ToString(), MedicBioData.Substring(0, 25), new Random().Next(1, 6), Utilities.Source("doc_anim.jpg", typeof(AppointmentController)), 4.1, Medic["address"].ToString(), Convert.ToDouble(Medic["medic"]["charge"]), String.Empty));
                    });
                }
            });

            //no result
            Device.BeginInvokeOnMainThread(delegate
            {
                if (Stack.Children.Count == 0)
                {
                    Stack.Children.Add(new Label {
                        Text = "Search returned no result. Please verify supplied name.", Style = App.Current.Resources["_EmptyLabelTemplate"] as Style
                    });
                }
            });
        }
        public static async Task <bool> BookAppointment(int UserID, String DateBooked, TimeSpan TimeBooked, MedicalPractitionerType AppointmentType, int MedPRactID, String Description, String PhoneNo)
        {
            String Time12Hours = "", Meridiem = "";
            int    hours = Convert.ToInt32(TimeBooked.ToString("hh"));

            if (hours > 12)
            {
                Time12Hours += (hours - 12);
                Meridiem    += "PM";
            }
            else if (hours == 0)
            {
                Time12Hours += "12";
                Meridiem    += "AM";
            }
            else if (hours == 12)
            {
                Time12Hours += "12";
                Meridiem    += "PM";
            }
            else
            {
                Time12Hours += hours;
                Meridiem    += "AM";
            }

            Time12Hours += ":" + TimeBooked.ToString("mm");
            Time12Hours += " ";
            Time12Hours += Meridiem;

            Dictionary <int, String[]> Data = new Dictionary <int, string[]>
            {
                { 0, new String[] { "user_id", Utilities.ID.ToString() } },
                { 1, new String[] { "entity_id", MedPRactID.ToString() } },
                { 2, new String[] { "appointment_type", (AppointmentType == MedicalPractitionerType.Doctor) ? "p" : "i" } },
                { 3, new String[] { "time", Time12Hours } },
                { 4, new String[] { "phone_number", PhoneNo } },
                { 5, new String[] { "description", Description } },
                { 6, new String[] { "date", DateBooked } },
            };

            try
            {
                String ResponseJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), "user/appointments/new");

                var DecodedJson = JObject.Parse(ResponseJson);
                if (!(bool)DecodedJson["status"])
                {
                    await App.Current.MainPage.DisplayAlert("Alert", DecodedJson["message"].ToString(), "ok");
                }
                return(Convert.ToBoolean(DecodedJson["status"]));
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "ok");

                return(false);
            }
        }
Пример #7
0
        public static Frame ListTemplate02(int MedPractID, MedicalPractitionerType MPT, String MedPractName, String Description, double Stars, ImageSource MedPractImage, double Distance, String Address, double Fee, String WorkTime)
        {
            Color  TypeColour = (Color)App.Current.Resources["colorGreen"];
            String TypeName   = Enum.GetName(typeof(MedicalPractitionerType), MPT);

            deftime = (String.IsNullOrEmpty(WorkTime)) ? deftime : WorkTime;

            Page page = new MedPractProfile(new MedPractProfileDetails(MedPractID, MedicalPractitionerType.Doctor, Stars, Fee, deftime, Distance, MedPractImage, MedPractName, Address, Description));

            switch (MPT)
            {
            case MedicalPractitionerType.Hospital:
                TypeColour = (Color)App.Current.Resources["colorRed"];
                page       = new MedPractProfile(new MedPractProfileDetails(MedPractID, MedicalPractitionerType.Hospital, Stars, Fee, deftime, Distance, MedPractImage, MedPractName, Address, Description));
                break;

            case MedicalPractitionerType.Laboratory:
                TypeColour = (Color)App.Current.Resources["colorGold"];
                page       = new MedPractProfile(new MedPractProfileDetails(MedPractID, MedicalPractitionerType.Laboratory, Stars, Fee, deftime, Distance, MedPractImage, MedPractName, Address, Description));
                break;

            case MedicalPractitionerType.Pharmacy:
                TypeColour = (Color)App.Current.Resources["_MedAppBlack"];
                page       = new MedPractProfile(new MedPractProfileDetails(MedPractID, MedicalPractitionerType.Pharmacy, Stars, Fee, deftime, Distance, MedPractImage, MedPractName, Address, Description));
                break;
            }
            ;


            Grid ParentGrid = new Grid
            {
                Margin          = 5,
                BackgroundColor = (Color)App.Current.Resources["_MedAppLightBlue"],
            };



            TapGestureRecognizer ParentGridTapped = new TapGestureRecognizer();

            ParentGridTapped.Tapped += delegate
            {
                Application.Current.MainPage.Navigation.PushAsync(page);
            };

            ParentGrid.GestureRecognizers.Add(ParentGridTapped);

            ParentGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1.2, GridUnitType.Star)
            });
            ParentGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(.8, GridUnitType.Star)
            });

            /**Left Stack for the Name, description and etc**/
            StackLayout LeftStack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding     = 5,
            };

            Grid.SetColumn(LeftStack, 0);

            Label NameLabel = new Label
            {
                Text                    = MedPractName,
                FontAttributes          = FontAttributes.Bold,
                TextDecorations         = TextDecorations.Underline,
                TextColor               = Color.White,
                FontSize                = 22,
                HorizontalOptions       = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Start
            };

            LeftStack.Children.Add(NameLabel);

            Label DescriptionLabel = new Label
            {
                Text          = (Description.Length > 150) ? Description.Substring(0, 150) + "..." : Description,
                HeightRequest = 100,
                TextColor     = Color.White
            };

            LeftStack.Children.Add(DescriptionLabel);

            LeftStack.Children.Add(new Label
            {
                Text                    = "Rating",
                TextDecorations         = TextDecorations.Underline,
                FontSize                = 18,
                HorizontalTextAlignment = TextAlignment.Start,
                TextColor               = Color.White
            });

            StackLayout StarsStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
            };

            Utilities.CreateStars(StarsStack, Stars, typeof(MedPractListTemplate));

            LeftStack.Children.Add(StarsStack);

            /**Right Stack for the image and etc**/
            StackLayout RightStack = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = 5,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            Grid.SetColumn(RightStack, 1);

            StackLayout ImageAndTypeStack = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            Image MedPractPicture = new Image
            {
                Source            = MedPractImage,
                Aspect            = Aspect.AspectFit,
                HeightRequest     = 100,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            ImageAndTypeStack.Children.Add(MedPractPicture);

            ImageAndTypeStack.Children.Add(new Label
            {
                Text                    = TypeName,
                BackgroundColor         = TypeColour,
                TextColor               = Color.White,
                HorizontalTextAlignment = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            });


            RightStack.Children.Add(ImageAndTypeStack);

            RightStack.Children.Add(new Label
            {
                Text      = "Location",
                TextColor = Color.White,
                HorizontalTextAlignment = TextAlignment.Start,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontSize = 18
            });

            RightStack.Children.Add(new Label
            {
                Text      = Distance + Utilities.DistanceType,
                TextColor = Color.White,
                HorizontalTextAlignment = TextAlignment.Start,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand
            });

            ParentGrid.Children.Add(LeftStack);
            ParentGrid.Children.Add(RightStack);



            return(new Frame {
                Content = ParentGrid, CornerRadius = 10, Margin = 5, Padding = 5, BackgroundColor = (Color)App.Current.Resources["_MedAppLightBlue"]
            });
        }