kaveer
1/10/2020 - 4:07 PM

Save Patient

 private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    AssignValue();
                    SavePatient();

                    MessageBox.Show("New patient added");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
private void SavePatient()
        {
            int patientId = 0;

            patientDetails = new clsPatientDetails();
            patientId = patientDetails.Save(patient.PatientDetails);

            if (patientId == 0)
                throw new Exception("Cannot save patient");

            dateEntry = new clsDateEntry();
            dateEntry.Save(patientId, patient.DateEntry);

            if (patient.Appointments.Count > 0)
            {
                var selectedAppointment = patient.Appointments.First();
                if (selectedAppointment.Appointment.Date != DateTime.Today.Date)
                {
                    appointment = new clsAppointment();
                    appointment.Save(patientId, selectedAppointment.Appointment);
                }
            }

            medicalRecord = new clsMedicalRecord();
            medicalRecord.Save(patientId, patient.MedicalRecords);

            assessment = new clsAssessment();
            assessment.Save(patientId, patient.Assessment);

            prescription = new clsPrescription();
            prescription.Save(patientId, patient.Prescription);
        }