/// <summary> /// This method will be used to update the patients information health card information /// inside of the HCV database. /// </summary> /// <param name="HCN">The health card number to look up</param> /// <param name="newHCVpatient">The new information that will be replaced with</param> /// <returns>Validation</returns> public bool UpdateHCVPatient(string HCN, HCVPatient newHCVpatient) { bool retCode = false; var result = _context.HCVPatients.SingleOrDefault(x => x.HealthCardNumber == HCN); if (result != null) { if (newHCVpatient != null) { // Update the row with the new information // each row will have the three columns (HCN, VCode, PostalCode) updated if (newHCVpatient.HealthCardNumber != "" && newHCVpatient.HealthCardNumber != null) { result.HealthCardNumber = newHCVpatient.HealthCardNumber; } if (newHCVpatient.VCode != "" && newHCVpatient.VCode != null) { result.VCode = newHCVpatient.VCode; } if (newHCVpatient.PostalCode != "" && newHCVpatient.PostalCode != null) { result.PostalCode = newHCVpatient.PostalCode; } _context.SaveChanges(); retCode = true; } } return(retCode); }
/// <summary> /// This method will be called to add a patient to the HCV database /// </summary> /// <param name="newHCVpatient">The new HCVPatient that will be added</param> /// <returns>Validation</returns> public bool AddHCVPatient(HCVPatient newHCVpatient) { HCVPatient HCVpatient = _context.HCVPatients.Add(newHCVpatient); _context.SaveChanges(); return(HCVpatient == null ? false : true); }
public HCVPatient GetHCVPatient(string HCN) { HCVPatient HCVpatient = new HCVPatient(); HCVpatient = _context.HCVPatients.FirstOrDefault(x => x.HealthCardNumber == HCN); return(HCVpatient); }
public HCVPatient CreateHCVPatient(string newHCN, string newVCode, string newpostalCode) { bool retCode = true; // Validate the parameters // Validate the new healthcard number if (newHCN.Length == 10) { foreach (char c in newHCN) { if (c < '0' || c > '9') { retCode = false; } } } else { retCode = false; } // Validate the VCode if (newVCode.Length == 2) { bool FoundMatch = false; FoundMatch = Regex.IsMatch(newVCode, @"^[a-zA-Z]+$"); if (!FoundMatch) { retCode = false; } } else { retCode = false; } // Validate the Postal Code if ((newpostalCode.Length == 6) || (newpostalCode.Length == 7)) { bool FoundMatch = false; try { FoundMatch = Regex.IsMatch(newpostalCode, "[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]"); if (!FoundMatch) { retCode = false; } } catch (ArgumentException) { retCode = false; } } else { retCode = false; } HCVPatient newHCVPatient; if (retCode) { newHCVPatient = new HCVPatient { HealthCardNumber = newHCN, VCode = newVCode, PostalCode = newpostalCode }; } else { newHCVPatient = null; } return(newHCVPatient); }
public bool UpdateHCVPatient(string HCN, HCVPatient newHCVpatient) { return(_dal.UpdateHCVPatient(HCN, newHCVpatient)); }
public bool AddHCVPatient(HCVPatient newHCVpatient) { return(_dal.AddHCVPatient(newHCVpatient)); }