private async void refresh() { if (IsSearched && !string.IsNullOrEmpty(patientNumber)) { try { record = await ViewModel.GetPatientData(patientNumber); //patientNumber = eSearch.Text; } catch { await DisplayAlert("Sorry!", "Something went wrong", "OK"); } if (record != null) { if (record.Success) { eSearch.Unfocus(); if (record.Patient.Forms.Count > 0) { listPatientDeatils.ItemsSource = record.Patient.Forms; stkTop.IsVisible = true; Settings.SetVisitId(record.Patient.VisitID); Settings.SetFormsList(record.Patient.Forms); string accountNumber = eSearch.Text; string accNumber = Convert.ToString(eSearch.Text); Settings.SetAccoiuntNumber(accNumber); IsSearched = true; Application.Current.MainPage = new NavigationPage(new MainViewsMasters()); } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Records Found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; } } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No records found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; } } if (record.Success) { if (record != null) { DateTime vardate = record.Patient.DateOfBirth; string dateformat = vardate.ToString("MM/dd/yyyy"); String patient = String.Format("{0}, {1}", "Patient:" + " " + record.Patient.FirstName, record.Patient.LastName); lblPatient.FormattedText = patient; lblPatientDateOfBirth.Text = dateformat; } if (record != null) { lblMobileNumber.Text = record.Patient.AccountNumber; } } listPatientDeatils.IsVisible = true; stkSearch.IsVisible = false; eSearch.Text = String.Empty; } }
async void onScan() { //setup options var options = new MobileBarcodeScanningOptions { AutoRotate = false, UseFrontCameraIfAvailable = false, TryHarder = true, TryInverted = true, PossibleFormats = new List <ZXing.BarcodeFormat> { ZXing.BarcodeFormat.EAN_13, ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.QR_CODE } }; var scanPage = new ZXingScannerPage(options) { DefaultOverlayTopText = "Align the barcode within the frame", DefaultOverlayBottomText = string.Empty, DefaultOverlayShowFlashButton = true, Title = "Scan Code", }; scanPage.OnScanResult += (result) => { scanPage.IsScanning = false; Device.BeginInvokeOnMainThread(async() => { await Navigation.PopAsync(); await DisplayAlert("Scanned Code", result.Text, "OK"); if (result != null) { try { patientNumber = result.Text; record = await ViewModel.GetPatientData(result.Text); } catch { await DisplayAlert("Sorry!", "Something went wrong", "OK"); } if (record != null) { if (record.Success) { listPatientDeatils.ItemsSource = record.Patient.Forms; stkTop.IsVisible = true; Settings.SetVisitId(record.Patient.VisitID); IsSearched = true; } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Record Found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; } } if (record.Success) { if (record != null) { DateTime vardate = record.Patient.DateOfBirth; string dateformat = vardate.ToString("MM/dd/yyyy"); String patient = String.Format("{0}, {1}", "Patient:" + " " + record.Patient.FirstName, record.Patient.LastName); lblPatient.FormattedText = patient; lblPatientDateOfBirth.Text = dateformat; } if (record != null) { lblMobileNumber.Text = record.Patient.AccountNumber; } } listPatientDeatils.IsVisible = true; stkSearch.IsVisible = false; eSearch.Text = ""; } }); }; App.IsLoggedInFirstTime = false; // Navigate to our scanner page // await Navigation.PushAsync(scanPage); await Navigation.PushAsync(scanPage).ConfigureAwait(true); }
protected override async void OnAppearing() { base.OnAppearing(); try { if (App.IsLoggedInFirstTime) { onScan(); return; } else { App.IsLoggedInFirstTime = false; } stkTop.IsVisible = false; stkForms.IsVisible = false; listPatientDeatils.IsVisible = false; stkSearch.IsVisible = true; if (IsSearched && record != null) { stkTop.IsVisible = true; listPatientDeatils.IsVisible = true; if (record != null && record.Success) { listPatientDeatils.ItemsSource = record.Patient.Forms; } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Record Found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; } //IsSearched if (record.Success) { if (record != null) { DateTime vardate = record.Patient.DateOfBirth; string dateformat = vardate.ToString("MM/dd/yyyy"); String patient = String.Format("{0}, {1}", "Patient:" + " " + record.Patient.FirstName, record.Patient.LastName); lblPatient.FormattedText = patient; lblPatientDateOfBirth.Text = dateformat; } if (record != null) { lblMobileNumber.Text = record.Patient.AccountNumber; } } stkSearch.IsVisible = false; eSearch.Text = ""; } if (App.IsFormsAdded) { try { if (MainViews.patientNumber != null) { record = await ViewModel.GetPatientData(MainViews.patientNumber); } } catch { await DisplayAlert("Sorry!", "Something went wrong", "OK"); } if (record != null) { if (record.Success) { if (record.Patient.Forms.Count > 0) { listPatientDeatils.ItemsSource = record.Patient.Forms; stkTop.IsVisible = true; Settings.SetVisitId(record.Patient.VisitID); Settings.SetFormsList(record.Patient.Forms); string accountNumber = eSearch.Text; string accNumber = Convert.ToString(MainViews.patientNumber); Settings.SetAccoiuntNumber(accNumber); IsSearched = true; App.IsFormsAdded = false; } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Record Found"; App.IsFormsAdded = false; listF.Add(F); listPatientDeatils.ItemsSource = listF; } } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Record Found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; App.IsFormsAdded = false; } } if (record.Success) { if (record != null) { DateTime vardate = record.Patient.DateOfBirth; string dateformat = vardate.ToString("MM/dd/yyyy"); String patient = String.Format("{0}, {1}", "Patient:" + " " + record.Patient.FirstName, record.Patient.LastName); lblPatient.FormattedText = patient; lblPatientDateOfBirth.Text = dateformat; } if (record != null) { lblMobileNumber.Text = record.Patient.AccountNumber; } } listPatientDeatils.IsVisible = true; stkSearch.IsVisible = false; eSearch.Text = ""; } } catch { } }
private async void OnBtnSearchClicked(object sender, EventArgs e) { using (UserDialogs.Instance.Loading("Loading", null, null, true, MaskType.Black)) { await Task.Delay(7000); } if (string.IsNullOrEmpty(eSearch.Text)) { await DisplayAlert("Account Number Search", "Please enter an Account Number on which to search", "OK"); return; } try { record = await ViewModel.GetPatientData(eSearch.Text); patientNumber = eSearch.Text; } catch { await DisplayAlert("Sorry!", "Something went wrong", "OK"); } if (record != null) { using (UserDialogs.Instance.Loading("Loading", null, null, true, MaskType.Black)) { await Task.Delay(1000); } if (record.Success) { eSearch.Unfocus(); if (record.Patient.Forms.Count > 0) { listPatientDeatils.ItemsSource = record.Patient.Forms; stkTop.IsVisible = true; Settings.SetVisitId(record.Patient.VisitID); Settings.SetFormsList(record.Patient.Forms); string accountNumber = eSearch.Text; string accNumber = Convert.ToString(eSearch.Text); Settings.SetAccoiuntNumber(accNumber); IsSearched = true; Application.Current.MainPage = new NavigationPage(new MainViewsMasters()); } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Record Found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; } } else { stkTop.IsVisible = false; List <Domain.Models.ResponseModels.Form> listF = new List <Domain.Models.ResponseModels.Form>(); Domain.Models.ResponseModels.Form F = new Domain.Models.ResponseModels.Form(); F.Name = "No Record Found"; listF.Add(F); listPatientDeatils.ItemsSource = listF; } } if (record.Success) { if (record != null) { DateTime vardate = record.Patient.DateOfBirth; string dateformat = vardate.ToString("MM/dd/yyyy"); // string patients = ""; String patient = String.Format("{0}, {1}", "Patient:" + " " + record.Patient.FirstName, record.Patient.LastName); lblPatient.FormattedText = patient; lblPatientDateOfBirth.Text = dateformat; } if (record != null) { lblMobileNumber.Text = record.Patient.AccountNumber; } } listPatientDeatils.IsVisible = true; stkSearch.IsVisible = false; eSearch.Text = ""; }