Exemple #1
0
        public FormGroupForms()
        {
            InitializeComponent();
            this.Title = Constants.Title_FormGroupForms;

            this.BackgroundColor = Color.FromHex(AppStyle.PageBackgroundColorforIndicator);
            this.Opacity         = 0.5;
            ac.Color             = Color.FromHex(AppStyle.ActivityIndicatorColor);

            listForms.ItemSelected += async(object sender, SelectedItemChangedEventArgs args) =>
            {
                var msg = " is null: FormGroupForms.xaml.cs -> ctr -> listForms.ItemSelected +=....";

                if (null == sender)
                {
                    Debug.WriteLine($"'sender' argument {msg}");
                    return;
                }
                if (null == args)
                {
                    Debug.WriteLine($"'args' argument {msg}");
                    return;
                }

                var item   = (Domain.Models.ResponseModels.FormTypeModel)args.SelectedItem;
                var answer = await DisplayAlert("Add Form", "Would you like to add this form to their list?", "Yes", "No");

                if (answer)
                {
                    _recordForAddForms = await ViewModel.AddFormsAsync(item.FormKey);

                    if (_recordForAddForms != null && _recordForAddForms.Success)
                    {
                        //if (_recordForAddForms.Success)
                        //{
                        await DisplayAlert("Add Form", "Form added successfully", "OK");

                        App.IsFormsAdded = true;

                        if (CrossDevice.Hardware.OperatingSystem == "WINDOWS")
                        {
                            Application.Current.MainPage = new NavigationPage(new MainViewsMasters());
                        }
                        else
                        {
                            await Navigation.PushAsync(new MainViewsMasters());
                        }


                        //await Navigation.PopAsync();
                    }
                    else
                    {
                        await DisplayAlert(Constants.ErrorMsgTitleOops, Constants.ErrorMsgSorry, "OK");
                    }
                    //}
                }
            };
        }
Exemple #2
0
        public async Task <Domain.Models.ResponseModels.AddFormModel> AddFormsAsync(string formKey)
        {
            Domain.Models.RequestModels.AddFormModel domainUser = new Domain.Models.RequestModels.AddFormModel();
            SetBaseProperties(domainUser);
            domainUser.FormKey = formKey;
            domainUser.VisitId = Settings.GetVisitId();

            // Call REST service
            Domain.Models.ResponseModels.AddFormModel res = await _authService.AddFormsAsync(domainUser);

            return(res);
        }
Exemple #3
0
        public async System.Threading.Tasks.Task <Domain.Models.ResponseModels.AddFormModel> AddFormsAsync(string formKey)
        {
            Domain.Models.RequestModels.AddFormModel domainUser = new Domain.Models.RequestModels.AddFormModel();
            domainUser.ApplicationId = Settings.GetApplicationId();
            domainUser.SerialNumber  = Settings.GetSerialNumber();
            domainUser.Version       = Settings.GetVersion();
            domainUser.AuthToken     = Settings.GetAuthorizationToken();
            domainUser.AccessToken   = Settings.GetAccessToken();
            domainUser.FormKey       = formKey;
            domainUser.VisitID       = Settings.GetVisitId();

            // TODO: Call the REST Service for authentication
            Domain.Models.ResponseModels.AddFormModel res = await _authService.AddFormsAsync(domainUser);

            return(res);
        }
        public FormGroupForms(int formGroupId)
        {
            InitializeComponent();
            this.Title = "Add Form";

            this.BackgroundColor = Color.FromHex(AppStyle.pageBackgroundColorforIndicator);
            this.Opacity         = 0.5;

            listForms.ItemSelected += async(object sender, SelectedItemChangedEventArgs args) =>
            {
                var item = (Domain.Models.ResponseModels.Forms)args.SelectedItem;

                var answer = await DisplayAlert("Add Form", "Would you like to add this form to the Patient", "Yes", "No");

                if (answer)
                {
                    recordForAddForms = await ViewModel.AddFormsAsync(item.FormKey);

                    if (recordForAddForms != null)
                    {
                        if (recordForAddForms.Success)
                        {
                            await DisplayAlert("Success", "Form added successfully", "OK");

                            App.IsFormsAdded             = true;
                            Application.Current.MainPage = new NavigationPage(new MainViewsMasters());
                            await Navigation.PopAsync().ConfigureAwait(false);
                        }
                        else
                        {
                            await DisplayAlert("Sorry!", "Something went wrong", "OK");
                        }
                    }
                }
                else
                {
                }
            };
        }
Exemple #5
0
        //
        //  FORMS   -- TODO: Forms need to be broken out into their own service, viewModel and interface
        //

        public async Task <Domain.Models.ResponseModels.AddFormModel> AddFormsAsync(
            Domain.Models.RequestModels.AddFormModel addFormReq)
        {
            Domain.Models.ResponseModels.AddFormModel result = null;

            try
            {
                var client = new HttpClient();
                client.BaseAddress = new Uri(Settings.GetBaseUrl());

                var data    = JsonConvert.SerializeObject(addFormReq);
                var content = new StringContent(data, Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync(Settings.GetBaseUrl() + "/efr/patient/form", content);

                result = JsonConvert.DeserializeObject <Domain.Models.ResponseModels.AddFormModel>(
                    response.Content.ReadAsStringAsync().Result);
            }
            catch (Exception erf)
            {
                Debug.Write(erf);
            }

            return(result);
        }