private void FillPatientObjectWithData(Patient patient) { patient.Surname = tbSurname.Text; patient.Name = tbName.Text; patient.Patronymic = tbPatronymic.Text; patient.DateOfBirth = dtpBirthDate.GetNullOrValue(); patient.Address = tbAddress.Text; patient.Telephone = tbTelephone.Text; }
private void btSave_Click(object sender, EventArgs e) { var patient = new Patient(); FillPatientObjectWithData(patient); var collection = ServerConnection.GetCollection<Patient>(); collection.Save<Patient>(patient); var patientArgs = new PersonIdentityEventArgs(patient.Id.ToString(), patient.Name, patient.Surname, patient.Patronymic); PatientAddEvent(this, patientArgs); this.Close(); }
/// <summary> /// Fills the nodes in TreeView control with health log cases and entries. Every node's tag is filled with ObjectId of according record. /// </summary> /// <param name="patient">Patient instance for who to populate TreeView</param> private void populateTreeView(Patient patient) { //TODO: Make population process fail-safe. var rootNode = treeHealthLog.Nodes.Add(patient.GetFullName()); rootNode.Tag = patient.Id; if(patient.HealthLog != null) { TreeNode currentNode; var caseCollection = ServerConnection.GetCollection<HealthLogCase>(); var entryCollection = ServerConnection.GetCollection<HealthLogEntry>(); foreach(var caseItem in patient.HealthLog) { var currentCase = caseCollection.FindOneById(caseItem); currentNode = rootNode.Nodes.Add(currentCase.StartDate.ToString("d")); currentNode.Tag = currentCase.Id; if(currentCase.HealthLogEntries != null) { foreach(var entryItem in currentCase.HealthLogEntries) { var currentEntry = entryCollection.FindOneById(entryItem); currentNode.Nodes.Add(currentEntry.AppointmentTime.ToString()).Tag = currentEntry.Id; } } } } }
/// <summary> /// Removes all the cases and entries related to the patient. /// </summary> /// <param name="patient">Patient instance.</param> private void RemovePatientLog(Patient patient) { var caseCollection = ServerConnection.GetCollection<HealthLogCase>(); var entryCollection = ServerConnection.GetCollection<HealthLogEntry>(); if(patient.HealthLog != null) { foreach(var caseItem in patient.HealthLog) { var currentCase = caseCollection.FindOneById(caseItem); if(currentCase.HealthLogEntries != null) { entryCollection.Remove(Query.In("_id", new BsonArray(currentCase.HealthLogEntries))); } } caseCollection.Remove(Query.In("_id", new BsonArray(patient.HealthLog))); } }
/// <summary> /// Fills the right panel with patient's data. /// </summary> /// <param name="patient">mongoClient.Patient instance to get the info from.</param> private void FillRightPanelWithPatientInfo(Patient patient) { // TODO: Fill all the fields after class is done. tbID.Text = patient.Id.ToString(); tbSurname.Text = patient.Surname; tbName.Text = patient.Name; tbPatronymic.Text = patient.Patronymic; dtpBirthDate.TryToAssignValue(patient.DateOfBirth); dtpBirthDate.ChangeFormatDependingOnCheckbox(); dtpDeathDate.TryToAssignValue(patient.DateOfDeath); dtpDeathDate.ChangeFormatDependingOnCheckbox(); tbAddress.Text = patient.Address; tbTelephone.Text = patient.Telephone; }