Exemple #1
0
        /// <summary>
        /// Delete patient detils by changing status to inactive.
        /// </summary>
        /// <param name="e"></param>
        private void DeletePatient(int id)
        {
            IObservable <PatientEntity> patientEntity = Observable.Start <PatientEntity>(
                () =>
            {
                PatientEntity patientEntiy = BLFactory.CreateInstance(CallingContext.ContextTypeA).DeletePatient(new PatientEntity()
                {
                    Id = id
                });
                return(patientEntiy);
            });

            patientEntity.SubscribeOn(NewThreadScheduler.Default)
            .ObserveOn(SynchronizationContext.Current)

            .Subscribe(loadedPatient =>
            {
                BindPatientsGrid();
                if (loadedPatient.Id > 0)
                {
                    MessageBox.Show("Patient details deleted successfully.");
                    ClearFields();
                }
                else
                {
                    MessageBox.Show("OOPs!! Something went wrong. Please contact administrator.");
                }
            });
        }
Exemple #2
0
        /// <summary>
        /// Bind grid that populates local data.
        /// </summary>
        private void BindPatientsGrid()
        {
            IObservable <IEnumerable <PatientEntity> > patients = Observable.Start <IEnumerable <PatientEntity> >(
                () =>
            {
                IEnumerable <PatientEntity> patientEntities = BLFactory.CreateInstance(CallingContext.ContextTypeA).GetPatients();
                return(patientEntities);
            });

            patients.SubscribeOn(NewThreadScheduler.Default)
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(loadedData =>
            {
                grdPatientsHolmusk.AutoGenerateColumns = false;
                grdPatientsHolmusk.DataSource          = loadedData;
            });
        }
Exemple #3
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in gridPatientsFHIR.Rows)
     {
         if (row.Cells["IsSelected"].Value != null && row.Cells["IsSelected"].Value.Equals(true))
         {
             PatientEntity patient = new PatientEntity
             {
                 Address       = row.Cells["Address"].Value.ToString(),
                 BirthDate     = Convert.ToDateTime(row.Cells["DateOfBirth"].Value),
                 ContactNumber = row.Cells["ContactNumber"].Value.ToString(),
                 Gender        = row.Cells["Gender"].Value.ToString(),
                 IsActive      = Convert.ToBoolean(row.Cells["IsActive"].Value),
                 Name          = row.Cells["PatientName"].Value.ToString()
             };
             PatientEntity patientEntiy = BLFactory.CreateInstance(CallingContext.ContextTypeA).AddPatient(patient);
             row.Cells["IsSelected"].Value = false;
         }
     }
     BindPatientsGrid();
     MessageBox.Show("Data imported successfully (Duplicate data will be ignored).");
 }
Exemple #4
0
        /// <summary>
        /// Update patient object.
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        private void UpdatePatient()
        {
            PatientEntity patient = new PatientEntity()
            {
                Id                                   = Convert.ToInt32(txtIdForEdit.Text),
                Address                              = txtAddress.Text,
                BirthDate                            = Convert.ToDateTime(dtpBirthDate.Text),
                ContactNumber                        = txtContactNumber.Text,
                Name                                 = txtPatientName.Text,
                Gender                               = rbnMale.Checked == true?EnumGender.Male.ToString() : EnumGender.Female.ToString(),
                                            IsActive = chkIsActive.Checked
            };
            IObservable <PatientEntity> patientEntity = Observable.Start <PatientEntity>(
                () =>
            {
                PatientEntity patientEntiy = BLFactory.CreateInstance(CallingContext.ContextTypeA).UpdatePatient(patient);
                return(patientEntiy);
            });

            patientEntity.SubscribeOn(NewThreadScheduler.Default)
            .ObserveOn(SynchronizationContext.Current)

            .Subscribe(loadedPatient =>
            {
                BindPatientsGrid();
                if (loadedPatient.Id > 0)
                {
                    MessageBox.Show("Patient details updated successfully.");
                    ClearFields();
                }
                else
                {
                    MessageBox.Show("OOPs!! Something went wrong. Please contact administrator.");
                }
            });
        }