2018-11-18 18:49:40 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2019-01-11 22:32:18 +01:00
|
|
|
|
using System.Net.Mail;
|
2018-11-18 18:49:40 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using HospitalServerManager.InterfacesAndEnums;
|
2018-12-29 11:58:25 +01:00
|
|
|
|
using Newtonsoft.Json;
|
2018-11-18 18:49:40 +01:00
|
|
|
|
|
|
|
|
|
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; }
|
2018-12-22 15:52:17 +01:00
|
|
|
|
public PatientState PatientState { get; protected set; }
|
|
|
|
|
public Sex PatientSex { get; protected set; }
|
2019-01-11 22:32:18 +01:00
|
|
|
|
public MailAddress EmailAdress { get; protected set; }
|
2018-11-18 18:49:40 +01:00
|
|
|
|
|
|
|
|
|
protected Patient() : base()
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-12-29 11:58:25 +01:00
|
|
|
|
[JsonConstructor]
|
|
|
|
|
protected Patient(string pesel, string name, string surname, DateTime birthDate, string patientState,
|
2019-01-12 11:25:51 +01:00
|
|
|
|
string patientSex, string patientEmail) : base(pesel, "PESEL", new List<string>())
|
2018-11-18 18:49:40 +01:00
|
|
|
|
{
|
2018-12-29 11:58:25 +01:00
|
|
|
|
if (pesel.Length < 11 || pesel.Length > 11)
|
2018-11-18 18:49:40 +01:00
|
|
|
|
throw new FormatException("PESEL musi mieć 11 cyfr");
|
2018-12-29 11:58:25 +01:00
|
|
|
|
//PrimaryKey = pesel;
|
2018-11-18 18:49:40 +01:00
|
|
|
|
Surname = surname;
|
|
|
|
|
Name = name;
|
|
|
|
|
BirthDate = birthDate;
|
2018-12-29 11:58:25 +01:00
|
|
|
|
PatientState = patientState.GetEnumFromDescription<PatientState>();
|
|
|
|
|
PatientSex = patientSex.GetEnumFromDescription<Sex>();
|
2019-01-12 11:25:51 +01:00
|
|
|
|
EmailAdress = new MailAddress(patientEmail);
|
2018-11-18 18:49:40 +01:00
|
|
|
|
}
|
2018-12-29 11:58:25 +01:00
|
|
|
|
public Patient(string pesel, string name, string surname, DateTime birthDate, PatientState patientState,
|
|
|
|
|
Sex patientSex) : base(pesel, "PESEL", new List<string>())
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}/// <summary>
|
|
|
|
|
/// List have to be in right order (pesel, surname, name, birth date, patient state, patient sex).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="listOfValues"></param>
|
|
|
|
|
public Patient(List<string> listOfValues) : base(listOfValues[0], "PESEL", new List<string>())
|
2018-11-18 18:49:40 +01:00
|
|
|
|
{
|
|
|
|
|
// 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]);
|
2018-12-22 15:52:17 +01:00
|
|
|
|
PatientState = listOfValues[4].GetEnumFromDescription<PatientState>();
|
|
|
|
|
PatientSex = (Sex)Enum.Parse(typeof(Sex), listOfValues[5]);
|
2018-11-18 18:49:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|