internal IList <Patient> GetPatientsByFullName(string fName, string lName) { var patientList = new List <Patient>(); var adapter = new patientTableAdapter(); try { using (adapter) { foreach ( var row in adapter.GetData() .Where(pat => pat.firstName.ToLower() == fName && pat.lastName.ToLower() == lName)) { var patient = this.getPatientFromRow(row); patientList.Add(patient); } } return(patientList); } catch (Exception e) { throw e; } }
internal IList <Patient> GetFirst30() { var patientList = new List <Patient>(); var adapter = new patientTableAdapter(); try { using (adapter) { foreach (var row in adapter.GetData().Rows) { var patient = this.getPatientFromRow((cs3230f16bDataSet.patientRow)row); patientList.Add(patient); if (patientList.Count >= 30) { return(patientList); } } } return(patientList); } catch (Exception e) { throw e; } }
internal void Update(Patient patient) { var adapter = new patientTableAdapter(); try { DataRow patRow; using (adapter) { patRow = adapter.GetData().FirstOrDefault(pat => pat.patientID == patient.PatientId); } if (patRow != null) { patRow[1] = patient.FirstName; patRow[2] = patient.LastName; patRow[3] = patient.Dob; patRow[4] = patient.Sex.ToString(); patRow[5] = patient.Street1; patRow[6] = patient.Street2; patRow[7] = patient.City; patRow[8] = patient.State; patRow[9] = patient.Zip; patRow[10] = patient.Country; patRow[11] = patient.PhoneNo; using (adapter) { adapter.Update(patRow); } } } catch (Exception e) { throw e; } }
internal int GetMaxYear() { var adapter = new patientTableAdapter(); try { using (adapter) { var youngest = adapter.GetData().Max(pat => pat.dateOfBirth); return(youngest.Year); } } catch (Exception e) { throw e; } }
internal IList <Patient> GetPatientsByDateOfBirth(string dob) { var patientList = new List <Patient>(); var adapter = new patientTableAdapter(); try { using (adapter) { foreach (var row in adapter.GetData().Where(pat => pat.dateOfBirth.ToShortDateString() == dob)) { var patient = this.getPatientFromRow(row); patientList.Add(patient); } } return(patientList); } catch (Exception e) { throw e; } }
/// <summary> /// Gets the patient by patientID. /// </summary> /// <param name="id">The patientID.</param> /// <returns>Patient with specified patientID</returns> public Patient GetById(int id) { var adapter = new patientTableAdapter(); try { using (adapter) { try { var patient = adapter.GetData().First(pat => pat.patientID == id); return(this.getPatientFromRow(patient)); } catch (Exception) { return(null); } } } catch (Exception e) { throw e; } }