Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the specified patient.
        /// </summary>
        /// <param name="patient">The patient.</param>
        private void Initialize(Patient patient)
        {
            this._isSkipUpdatingFigure = true;

            try
            {
                // this._patient = patient;

                // Initialize combobox
                // thangnn edit
                var figures = _figureRepo.GetByClinicId(AppContext.CurrentClinic.Id);

                this.cboFigure.DataSource = figures;

                // Get Doctor Name
                this.txtDoctor.Text = AppContext.LoggedInUser.Name;
                var medicines = _medicineRepo.GetAll();
                medicines.Insert(0, new Medicine()
                {
                    Id = 0, Name = "..."
                });
                this.bdsMedicine.DataSource = medicines;

                // Get existing prescription
                this._prescription = _precriptionRepo.GetCurrent(patient.Id);
                // var lastPrescription = _precriptionRepo.GetLastByPatient(patient.Id);

                // Binding data
                if (this._prescription == null)
                {
                    this._isEditable   = true;
                    this._isUpdate     = false;
                    this._prescription = new Prescription
                    {
                        Date            = DateTime.Today,
                        RecheckDate     = DateTime.Today.AddDays(DefaultVolumn),
                        DoctorId        = AppContext.LoggedInUser.Id,
                        PatientId       = patient.Id,
                        CreatedUser     = AppContext.LoggedInUser.Id,
                        LastUpdatedUser = AppContext.LoggedInUser.Id,
                        ClinicId        = AppContext.CurrentClinic.Id
                    };

                    this._prescriptionDetailList           = new List <PrescriptionDetail>();
                    this._prescription.PrescriptionDetails = this._prescriptionDetailList;
                }
                else
                {
                    var delivered = _medicineDeliveryRepo.GetByPrescriptionId(this._prescription.Id);
                    this._prescriptionDetailList = this._prescription.PrescriptionDetails;
                    this._isEditable             = delivered == null;
                    this._isUpdate = true;
                    this._prescription.DoctorId        = AppContext.LoggedInUser.Id;
                    this._prescription.LastUpdatedUser = AppContext.LoggedInUser.Id;
                    foreach (var detailItem in this._prescription.PrescriptionDetails)
                    {
                        detailItem.MedicineName = detailItem.Medicine.Name;
                        detailItem.TradeName    = detailItem.Medicine.TradeName;
                        detailItem.UnitName     = detailItem.Medicine.Define.Name;
                    }
                }

                Initialize(this._prescription);
            }
            finally
            {
                this._isSkipUpdatingFigure = false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the specified patient.
        /// </summary>
        /// <param name="patient">The patient.</param>
        private void Initialize(Patient patient)
        {
            this._isSkipUpdatingFigure = true;

            try
            {
                this._patient = patient;

                // Initialize combobox
                //var figures = _figureRepo.GetAll();
                // thangnn edit
                var figures = _figureRepo.GetByClinicId(AppContext.CurrentClinic.Id);
                // end
                this.cboFigure.DataSource = figures;
                // Get Doctor Name
                this.txtDoctor.Text = AppContext.LoggedInUser.Name;
                var medicines = _medicineRepo.GetAll();
                medicines.Insert(0, new Medicine()
                {
                    Id = 0, Name = "..."
                });
                this.bdsMedicine.DataSource = medicines;

                // Get existing prescription
                this._prescription = _precriptionRepo.GetCurrent(patient.Id);
                var lastPrescription = _precriptionRepo.GetLastByPatient(patient.Id);

                // Binding data
                if (this._prescription == null)
                {
                    this._isUpdate     = false;
                    this._prescription = new Prescription
                    {
                        Date        = DateTime.Today,
                        RecheckDate = DateTime.Today.AddDays(DefaultVolumn),
                        DoctorId    = AppContext.LoggedInUser.Id,
                        //Doctor = AppContext.LoggedInUser,
                        PatientId       = patient.Id,
                        CreatedUser     = AppContext.LoggedInUser.Id,
                        LastUpdatedUser = AppContext.LoggedInUser.Id,
                        ClinicId        = AppContext.CurrentClinic.Id
                    };

                    this._prescriptionDetailList = new List <PrescriptionDetail>();

                    if (lastPrescription != null)
                    {
                        // this._prescription.Note = lastPrescription.Note;
                        // this._prescription.FigureId = lastPrescription.FigureId;

                        // Create FigureId
                        //var figureDetails = this._figureDetailRepo.GetByFigure(lastPrescription.FigureId);
                        //foreach (var figureDetail in figureDetails)
                        //{
                        //    var prescriptionDetail = new PrescriptionDetail
                        //                                 {
                        //                                     No = this._prescriptionDetailList.Count + 1,
                        //                                     FigureDetailId = figureDetail.Id,
                        //                                     MedicineId = figureDetail.MedicineId,
                        //                                     Medicine = figureDetail.Medicine,
                        //                                     VolumnPerDay = figureDetail.Volumn,
                        //                                     Day = DefaultVolumn,
                        //                                     Amount = DefaultVolumn*figureDetail.Volumn,
                        //                                     Version = 0
                        //                                 };
                        //    this._prescriptionDetailList.Add(prescriptionDetail);
                        //}
                    }

                    this._prescription.PrescriptionDetails = this._prescriptionDetailList;
                }
                else
                {
                    this._isUpdate = true;
                    this._prescription.DoctorId = AppContext.LoggedInUser.Id;
                    //this._prescription.Doctor = AppContext.LoggedInUser;
                    this._prescription.LastUpdatedUser = AppContext.LoggedInUser.Id;
                }

                Initialize(this._prescription);
            }
            finally
            {
                this._isSkipUpdatingFigure = false;
            }
        }