Ejemplo n.º 1
0
        public async Task <NewPatientResults> postNewPatient(NewPatient newPatient)
        {
            NewPatientResults newPatientResults = new NewPatientResults();
            var uri = new Uri($"{urlWebServices}/pasienbaruybyktp/");

            try
            {
                var jsonObj = JsonConvert.SerializeObject(newPatient);
                var content = new StringContent(jsonObj,
                                                Encoding.UTF8, "application/json");
                var response = await client.PostAsync(uri, content);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Gagal Proses Pembuatan Pasien Baru");
                }
                else
                {
                    var result = await response.Content.ReadAsStringAsync();

                    newPatientResults = JsonConvert.DeserializeObject <NewPatientResults>(result);
                    return(newPatientResults);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public RegistrationSuccessNewPatientForm(RegistrationResults registrationResults, NewPatientResults newPatientResults)
        {
            InitializeComponent();

            this.registrationResults = registrationResults;
            this.newPatientResults   = newPatientResults;
            TxtNoKTP.Text            = newPatientResults.vc_no_ktp;
            txtTgl.Text     = registrationResults.tglreg;
            txtNama.Text    = newPatientResults.NamaPasien;
            txtKlinik.Text  = registrationResults.namaklinik;
            txtDokter.Text  = registrationResults.namadokter;
            txtCatatan.Text = registrationResults.deskripsiresponse;
        }
        private async void prosesSimpan()
        {
            using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Proses Simpan Pasien"))
            {
                try
                {
                    newPatientResults = new NewPatientResults();
                    newPatientResults = await patientServices.postNewPatient(newPatient4);
                }
                catch (Exception ex)
                {
                    await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Error", ex.Message));
                }

                if (!string.IsNullOrEmpty(newPatientResults.response))
                {
                    if (newPatientResults.response.ToString() == "gagal")
                    {
                        await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Warning", newPatientResults.deskripsiresponse));
                    }
                    else
                    {
                        registrationResults = new RegistrationResults();
                        registrationResults = await registrationServices.postRegistrationNewPatient(newRegistration);

                        if (registrationResults.response.ToString() == ("ok"))
                        {
                            await Navigation.PushAsync(new RegistrationSuccessNewPatientForm(registrationResults, newPatientResults));

                            Navigation.RemovePage(this);
                        }
                        else
                        {
                            await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Peringatan", registrationResults.deskripsiresponse));
                        }
                    }
                }
                else
                {
                    await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Warning", "Maaf Terjadi Kegagalan saat simpan, Mohon Dicoba Kembali"));
                }
            }
        }