using System; using System.Collections.Generic; using System.Linq; using System.Net.Mail; using System.Text; using System.Threading.Tasks; using HospitalServerManager.InterfacesAndEnums; using Newtonsoft.Json; namespace HospitalServerManager.Model.Basic { internal class Patient : SqlTable { public string Surname { get; protected set; } public string Name { get; protected set; } public DateTime BirthDate { get; protected set; } public PatientState PatientState { get; protected set; } public Sex PatientSex { get; protected set; } public MailAddress EmailAdress { get; protected set; } protected Patient() : base() { } [JsonConstructor] protected Patient(string pesel, string name, string surname, DateTime birthDate, string patientState, string patientSex, string patientEmail) : base(pesel, "PESEL", new List()) { if (pesel.Length < 11 || pesel.Length > 11) throw new FormatException("PESEL musi mieć 11 cyfr"); //PrimaryKey = pesel; Surname = surname; Name = name; BirthDate = birthDate; PatientState = patientState.GetEnumFromDescription(); PatientSex = patientSex.GetEnumFromDescription(); EmailAdress = new MailAddress(patientEmail); } public Patient(string pesel, string name, string surname, DateTime birthDate, PatientState patientState, Sex patientSex) : base(pesel, "PESEL", new List()) { if (pesel.Length < 11 || pesel.Length > 11) throw new FormatException("PESEL musi mieć 11 cyfr"); //PrimaryKey = pesel; Surname = surname; Name = name; BirthDate = birthDate; PatientState = patientState; PatientSex = patientSex; }/// /// List have to be in right order (pesel, surname, name, birth date, patient state, patient sex). /// /// public Patient(List listOfValues) : base(listOfValues[0], "PESEL", new List()) { // TODO: Dodać zabezpieczenia dla pozostałych wartosci // TODO: VALIDATOR! Lista kolumn nazw; if (listOfValues[0].Length < 11 || listOfValues[0].Length > 11) throw new FormatException("PESEL musi mieć 11 cyfr"); PrimaryKey = listOfValues[0]; Surname = listOfValues[1]; Name = listOfValues[2]; BirthDate = DateTime.Parse(listOfValues[3]); PatientState = listOfValues[4].GetEnumFromDescription(); PatientSex = (Sex)Enum.Parse(typeof(Sex), listOfValues[5]); } } }