/// <summary> /// Updates the form. /// </summary> /// <param name="patient">The patient.</param> private void UpdateForm(Patient patient) { this.bdsPrescription.Clear(); this.bdsPrescriptionDetail.Clear(); this.bdsPatient.DataSource = patient; this.selectedPatient = patient; if (patient == null) { this.btnCheck.Enabled = false; return; } this.btnCheck.Enabled = true; lastPrescription = prescriptionRepo.GetLastByPatient(patient.Id); if (lastPrescription == null) return; this.bdsPrescription.DataSource = lastPrescription; List<PrescriptionDetail> detailList = prescriptionDetailRepo.GetByPrescription(lastPrescription.Id); if (detailList != null) { for (int i = 0; i < detailList.Count; i++) { detailList[i].No = i + 1; } this.bdsPrescriptionDetail.DataSource = detailList; } }
private void GrdPatientCellDoubleClick(object sender, DataGridViewCellEventArgs e) { this.SelectedPatient = (Patient) this.bdgPatient.List[e.RowIndex]; if (this.SelectedPatient == null) return; this.DialogResult = DialogResult.Yes; this.Close(); }
/// <summary> /// Handles the Click event of the btnRegister control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BtnRegisterClick(object sender, EventArgs e) { var registerform = new PatientRegister(); var result = registerform.ShowDialog(); if (result != DialogResult.Yes) return; this._selectedPatient = registerform.Patient; UpdateForm(registerform.Patient); UpdateButtonStatus(); }
/// <summary> /// Initializes a new instance of the <see cref="PatientRegister"/> class. /// </summary> public PatientRegister(Patient patient) { InitializeComponent(); this.Patient = patient; this.bdsPatient.DataSource = Patient; this._isAddNew = false; this._patientRepository = new PatientRepository(); }
/// <summary> /// Inserts the specified user. /// </summary> /// <param name="patient">The user.</param> public void Insert(Patient patient) { patient.StartDate = DateTime.Today; patient.Version = 0; patient.ClinicId = AppContext.CurrentClinic.Id; patient.CreatedDate = DateTime.Now; patient.CreatedUser = AppContext.LoggedInUser.Id; patient.LastUpdatedDate = DateTime.Now; patient.LastUpdatedUser = AppContext.LoggedInUser.Id; this.Context.Patients.Add(patient); this.Context.SaveChanges(); }
private void grdPatient_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { this.SelectedPatient = (Patient)this.bdgPatient.List[e.RowIndex]; if (this.SelectedPatient == null) return; var historyForm = new CheckUpHistory(SelectedPatient.Id); historyForm.ShowDialog(this); this.bdgPatient.Clear(); if (AppContext.LoggedInUser.Role > MedicineRoles.SupperManager) this.bdgPatient.DataSource = patientRepo.GetByNameAndYear(this.txtPatientName.Text, (int?)this.txtBirthYear.ValueObject, AppContext.CurrentClinic.Id); else this.bdgPatient.DataSource = patientRepo.GetByNameAndYear(this.txtPatientName.Text, (int?)this.txtBirthYear.ValueObject); }
/// <summary> /// Updates the specified user. /// </summary> /// <param name="user">The user.</param> public void Update(Patient patient) { var origin = this.Context.Patients.FirstOrDefault(x => x.Id == patient.Id); if (origin == null) return; origin.Address = patient.Address; origin.BirthYear = patient.BirthYear; origin.ClinicId = patient.ClinicId; origin.Code = patient.Code; origin.Description = patient.Description; origin.SetInfo(true); this.Context.SaveChanges(); this.Context.Entry(origin).Reload(); }
/// <summary> /// Updates the form. /// </summary> /// <param name="patient">The patient.</param> private void UpdateForm(Patient patient) { Patient ptn = _patientRepo.GetById(patient.Id); this.bdsPatient.DataSource = ptn; _lastPrescription = _prescriptionRepo.GetLastByPatient(ptn.Id); if (_lastPrescription != null) { this.bdsPrescription.DataSource = _lastPrescription; var detailList = _prescriptionDetailRepo.GetByPrescription(_lastPrescription.Id); foreach (var detailItem in detailList) { detailItem.MedicineName = detailItem.Medicine.Name; detailItem.TradeName = detailItem.Medicine.TradeName; detailItem.UnitName = detailItem.Medicine.Define.Name; } //this.bdsPrescription.DataSource = this.bdsPrescription; this.bdsPrescriptionDetail.DataSource = detailList; this.bdsPrescriptionDetail.ResetBindings(false); this.dataGridViewX1.Refresh(); } else { this.bdsPrescription.Clear(); this.bdsPrescriptionDetail.Clear(); } }
/// <summary> /// Handles the ButtonCustomClick event of the textBoxX1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void TextBoxX1ButtonCustomClick(object sender, EventArgs e) { var patientBrowse = new PatientBrowseForm(); var result = patientBrowse.ShowDialog(this); if (result != DialogResult.Yes) return; this._selectedPatient = patientBrowse.SelectedPatient; UpdateForm(patientBrowse.SelectedPatient); UpdateButtonStatus(); }
/// <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; } }
/// <summary> /// Initializes a new instance of the <see cref="CheckUpRegister"/> class. /// </summary> /// <param name="patient">The patient.</param> public CheckUpRegister(Patient patient) : this() { Initialize(patient); }
/// <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; } }