Beispiel #1
0
        public bool AddVisit(PatientVisit model, List<PatientLabData> labmodel, List<PatientImagingData> imagingmodel, List<Prescription> presriptionmodel)
        {
            int _visitid = 0;
            try
            {
                entities.PatientVisits.Add(model);
                entities.SaveChanges();
                _visitid = model.VisitId;
            }
            catch (Exception x)
            {
                throw x;
            }

            if (_visitid != 0)
            {
                //add Lab Data
                foreach (PatientLabData data in labmodel)
                {
                    data.UniqueId = 0;
                    data.VisitId = _visitid;
                    entities.PatientLabDatas.Add(data);
                }
                //add Imaging data
                foreach (PatientImagingData data in imagingmodel)
                {
                    data.UniqueId = 0;
                    data.VisitId = _visitid;
                    entities.PatientImagingDatas.Add(data);
                }
                //add Prescription data
                foreach (Prescription data in presriptionmodel)
                {
                    data.UniqueId = 0;
                    data.VisitId = _visitid;
                    entities.Prescriptions.Add(data);
                }

                //save db
                entities.SaveChanges();
            }
            else
            {
                throw new Exception("Error adding vist");
            }

            return true;
        }
        private void btnAddNewVisit_Click(object sender, EventArgs e)
        {
            int _visitid = 0;
            VisitData db = new VisitData();
            try
            {
                PatientVisit visit = new PatientVisit()
                {
                    PatientId = _patiendid,
                    ComplaintHistory = txtComplaint.Text.Trim(),
                    ExaminationNotes = txtExamination.Text.Trim(),
                    Diagnosis = txtDiagnosis.Text.Trim(),
                    OtherAdvise = txtOtherAdvise.Text.Trim(),
                    IsFolowUpRequired = chkFollowUp.Checked,
                    FollowUpDate = datetimeFollowUp.Value,
                    CreatedOn = DateTime.Now,
                    UpdatedOn = DateTime.Now
                };

                bool result = db.AddVisit(visit, labdatalist, imagingdatalist, prescriptionlist);

                if (result)
                {
                    RefreshVisit();
                    MessageBox.Show("Visit added successfully. Please print results from [Previous Visits] section");
                }
                else
                {
                    MessageBox.Show("Error adding visit : Please contact support");
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Error adding visit. Please try again.");
                return;
            }
        }