static public List <TestContact> BuildContactsFromDataBaseData(string idPerson) { List <TestContact> contacts = new List <TestContact>(); using (SqlConnection connection = Global.GetSqlConnection()) { string findPatient = "SELECT * FROM Contact WHERE IdPerson = '" + idPerson + "'"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader contactReader = person.ExecuteReader()) { while (contactReader.Read()) { ContactDto cont = new ContactDto(); if (contactReader["IdContactType"].ToString() != "") { cont.IdContactType = Convert.ToByte(contactReader["IdContactType"]); } if (contactReader["ContactValue"].ToString() != "") { cont.ContactValue = Convert.ToString(contactReader["ContactValue"]); } TestContact contact = new TestContact(cont); contacts.Add(contact); } } } if (contacts.Count != 0) { return(contacts); } else { return(null); } }
public override bool Equals(Object obj) { TestContact p = obj as TestContact; if ((object)p == null) { return(false); } if (this.contact == p.contact) { return(true); } if ((this.contact == null) || (p.contact == null)) { return(false); } if ((this.contact.ContactValue == p.contact.ContactValue) && (this.contact.IdContactType == p.contact.IdContactType)) { return(true); } else { this.FindMismatch(p); Global.errors3.Add("несовпадение TestContact"); return(false); } }
public static List<TestContact> BuildContactsFromDataBaseData(string idPerson) { List<TestContact> contacts = new List<TestContact>(); using (SqlConnection connection = Global.GetSqlConnection()) { string findPatient = "SELECT * FROM Contact WHERE IdPerson = '" + idPerson + "'"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader contactReader = person.ExecuteReader()) { while (contactReader.Read()) { ContactDto cont = new ContactDto(); if (contactReader["IdContactType"].ToString() != "") cont.IdContactType = Convert.ToByte(contactReader["IdContactType"]); if (contactReader["ContactValue"].ToString() != "") cont.ContactValue = Convert.ToString(contactReader["ContactValue"]); TestContact contact = new TestContact(cont); contacts.Add(contact); } } } if (contacts.Count != 0) return contacts; else return null; }
private void FindMismatch(TestContact b) { if (this.contact.ContactValue != b.contact.ContactValue) { Global.errors3.Add("Несовпадение ContactValue TestContact"); } if (this.contact.IdContactType != b.contact.IdContactType) { Global.errors3.Add("Несовпадение IdContactType TestContact"); } }
public void ChangePatientField(PatientDto b) { if ((b.FamilyName != null) && (this.patient.FamilyName != b.FamilyName)) this.patient.FamilyName = b.FamilyName; if ((b.MiddleName != null) && (this.patient.MiddleName != b.MiddleName)) this.patient.MiddleName = b.MiddleName; if ((b.GivenName != null) && (this.patient.GivenName != b.GivenName)) this.patient.GivenName = b.GivenName; if ((b.BirthDate != DateTime.MinValue) && (this.patient.BirthDate != b.BirthDate)) this.patient.BirthDate = b.BirthDate; if ((b.Sex != 0) && (this.patient.Sex != b.Sex)) this.patient.Sex = b.Sex; this.patient.IsVip = b.IsVip; if ((b.SocialStatus != null) && (this.patient.SocialStatus != b.SocialStatus)) this.patient.SocialStatus = b.SocialStatus; if ((b.IdLivingAreaType != null) && (this.patient.IdLivingAreaType != b.IdLivingAreaType)) this.patient.IdLivingAreaType = b.IdLivingAreaType; if ((b.IdBloodType != null) && (this.patient.IdBloodType != b.IdBloodType)) this.patient.IdBloodType = b.IdBloodType; if ((b.DeathTime != null) && (this.patient.DeathTime != b.DeathTime)) this.patient.DeathTime = b.DeathTime; if (b.Documents != null) { foreach (DocumentDto d in b.Documents) { if (this.documents != null) { bool mark = false; foreach (TestDocument td in this.documents) { if (d.IdDocumentType == td.document.IdDocumentType) { td.document = d; mark = true; } } if (!mark) this.documents.Add(new TestDocument(d)); } else { this.documents = new List<TestDocument>(); documents.Add(new TestDocument(d)); } } } if (b.Addresses != null) { foreach (AddressDto a in b.Addresses) { if (this.addreses != null) { bool mark = false; foreach (TestAddress ta in this.addreses) { if (a.IdAddressType == ta.address.IdAddressType) { ta.address = a; mark = true; } } if (!mark) this.addreses.Add(new TestAddress(a)); } else { this.addreses = new List<TestAddress>(); addreses.Add(new TestAddress(a)); } } } if (b.Contacts != null) foreach (ContactDto c in b.Contacts) { TestContact tc = new TestContact(c); if (this.contacts != null) { bool mark = false; foreach (TestContact c1 in this.contacts) if (tc == c1) mark = true; if (!mark) this.contacts.Add(tc); } else this.contacts.Add(tc); } if (b.Job != null) this.job = new TestJob(b.Job); if (b.Privilege != null) this.privilege = new TestPrivilege(b.Privilege); if (b.BirthPlace != null) this.birthplace = new TestBirthplace(b.BirthPlace); }
public void ChangePatientField(PatientDto b) { if ((b.FamilyName != null) && (this.patient.FamilyName != b.FamilyName)) { this.patient.FamilyName = b.FamilyName; } if ((b.MiddleName != null) && (this.patient.MiddleName != b.MiddleName)) { this.patient.MiddleName = b.MiddleName; } if ((b.GivenName != null) && (this.patient.GivenName != b.GivenName)) { this.patient.GivenName = b.GivenName; } if ((b.BirthDate != DateTime.MinValue) && (this.patient.BirthDate != b.BirthDate)) { this.patient.BirthDate = b.BirthDate; } if ((b.Sex != 0) && (this.patient.Sex != b.Sex)) { this.patient.Sex = b.Sex; } this.patient.IsVip = b.IsVip; if ((b.SocialStatus != null) && (this.patient.SocialStatus != b.SocialStatus)) { this.patient.SocialStatus = b.SocialStatus; } if ((b.IdLivingAreaType != null) && (this.patient.IdLivingAreaType != b.IdLivingAreaType)) { this.patient.IdLivingAreaType = b.IdLivingAreaType; } if ((b.IdBloodType != null) && (this.patient.IdBloodType != b.IdBloodType)) { this.patient.IdBloodType = b.IdBloodType; } if ((b.DeathTime != null) && (this.patient.DeathTime != b.DeathTime)) { this.patient.DeathTime = b.DeathTime; } if (b.Documents != null) { foreach (DocumentDto d in b.Documents) { if (this.documents != null) { bool mark = false; foreach (TestDocument td in this.documents) { if (d.IdDocumentType == td.document.IdDocumentType) { td.document = d; mark = true; } } if (!mark) { this.documents.Add(new TestDocument(d)); } } else { this.documents = new List <TestDocument>(); documents.Add(new TestDocument(d)); } } } if (b.Addresses != null) { foreach (AddressDto a in b.Addresses) { if (this.addreses != null) { bool mark = false; foreach (TestAddress ta in this.addreses) { if (a.IdAddressType == ta.address.IdAddressType) { ta.address = a; mark = true; } } if (!mark) { this.addreses.Add(new TestAddress(a)); } } else { this.addreses = new List <TestAddress>(); addreses.Add(new TestAddress(a)); } } } if (b.Contacts != null) { foreach (ContactDto c in b.Contacts) { TestContact tc = new TestContact(c); if (this.contacts != null) { bool mark = false; foreach (TestContact c1 in this.contacts) { if (tc == c1) { mark = true; } } if (!mark) { this.contacts.Add(tc); } } else { this.contacts.Add(tc); } } } if (b.Job != null) { this.job = new TestJob(b.Job); } if (b.Privilege != null) { this.privilege = new TestPrivilege(b.Privilege); } if (b.BirthPlace != null) { this.birthplace = new TestBirthplace(b.BirthPlace); } }
static public TestPatient BuildPatientFromDataBaseData(string guid = null, string idlpu = null, string mis = null, string patientId = null) { if (patientId == null) { patientId = GetPatientId(guid, idlpu, mis); } else { string[] s = GetGUIDandIDLPUandIDMIS(patientId); guid = s[0]; idlpu = s[1]; mis = s[2]; } if (patientId != null) { using (SqlConnection connection = Global.GetSqlConnection()) { string findPatient = "SELECT TOP(1) * FROM Person, PatientAdditionalInfo WHERE Person.IdPerson = '" + patientId + "' AND Person.IdPerson = PatientAdditionalInfo.IdPerson"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader patientFromDataBase = person.ExecuteReader()) { while (patientFromDataBase.Read()) { PatientDto p = new PatientDto(); if (patientFromDataBase["FamilyName"].ToString() != "") { p.FamilyName = Convert.ToString(patientFromDataBase["FamilyName"]); } else { p.FamilyName = null; } if (patientFromDataBase["MiddleName"].ToString() != "") { p.MiddleName = Convert.ToString(patientFromDataBase["MiddleName"]); } else { p.MiddleName = null; } if (patientFromDataBase["GivenName"].ToString() != "") { p.GivenName = Convert.ToString(patientFromDataBase["GivenName"]); } else { p.GivenName = null; } p.BirthDate = Convert.ToDateTime(patientFromDataBase["BirthDate"]); p.Sex = Convert.ToByte(patientFromDataBase["IdSex"]); p.IsVip = Convert.ToBoolean(patientFromDataBase["IsVip"]); if (patientFromDataBase["IdSocialStatus"].ToString() != "") { p.SocialStatus = Convert.ToString(patientFromDataBase["IdSocialStatus"]); } else { p.SocialStatus = null; } if (patientFromDataBase["IdSocialGroup"].ToString() != "") { p.SocialGroup = Convert.ToByte(patientFromDataBase["IdSocialGroup"]); } else { p.SocialGroup = null; } if (patientFromDataBase["IdLivingAreaType"].ToString() != "") { p.IdLivingAreaType = Convert.ToByte(patientFromDataBase["IdLivingAreaType"]); } else { p.IdLivingAreaType = null; } if (patientFromDataBase["IdBloodType"].ToString() != "") { p.IdBloodType = Convert.ToByte(patientFromDataBase["IdBloodType"]); } else { p.IdBloodType = null; } if (patientFromDataBase["DeathTime"].ToString() != "") { p.DeathTime = Convert.ToDateTime(patientFromDataBase["DeathTime"]); } else { p.DeathTime = null; } p.IdPatientMIS = mis; p.IdGlobal = patientId; TestPatient patient = new TestPatient(guid, idlpu, p); patient.documents = TestDocument.BuildDocumentsFromDataBaseData(patientId); patient.addreses = TestAddress.BuildAdressesFromDataBaseData(patientId); patient.contacts = TestContact.BuildContactsFromDataBaseData(patientId); patient.job = TestJob.BuildTestJobFromDataBase(patientId); patient.privilege = TestPrivilege.BuildTestPrivilegeFromDataBase(patientId); patient.birthplace = TestBirthplace.BuildBirthplaceFromDataBaseData(patientId); return(patient); } } } } return(null); }
private void FindMismatch(TestContact b) { if (this.contact.ContactValue != b.contact.ContactValue) Global.errors3.Add("Несовпадение ContactValue TestContact"); if (this.contact.IdContactType != b.contact.IdContactType) Global.errors3.Add("Несовпадение IdContactType TestContact"); }