Esempio n. 1
0
 public TestPatient(string guid, string idlpu, PatientDto p)
 {
     patient = p;
     if ((guid != null) && (idlpu != null) && (p.IdPatientMIS != null))
     {
         patient.IdGlobal = GetPatientId(guid, idlpu, p.IdPatientMIS);
     }
     GUID  = guid.ToLower();
     IDLPU = idlpu;
     if ((p.Documents != null) && (p.Documents.Length != 0))
     {
         List <TestDocument> doc = new List <TestDocument>();
         foreach (DocumentDto d in p.Documents)
         {
             doc.Add(new TestDocument(d));
         }
         documents = doc;
     }
     if ((p.Addresses != null) && (p.Addresses.Length != 0))
     {
         List <TestAddress> add = new List <TestAddress>();
         foreach (AddressDto a in p.Addresses)
         {
             add.Add(new TestAddress(a));
         }
         addreses = add;
     }
     if ((p.Contacts != null) && (p.Contacts.Length != 0))
     {
         List <TestContact> cont = new List <TestContact>();
         foreach (ContactDto c in p.Contacts)
         {
             cont.Add(new TestContact(c));
         }
         contacts = cont;
     }
     if (p.Job != null)
     {
         job = new TestJob(p.Job);
     }
     if (p.Privilege != null)
     {
         privilege = new TestPrivilege(p.Privilege);
     }
     if (p.BirthPlace != null)
     {
         birthplace = new TestBirthplace(p.BirthPlace);
     }
 }
Esempio n. 2
0
 public void FindMismatch(TestPrivilege b)
 {
     if (b.privilege != null)
     {
         if (this.privilege.DateEnd != b.privilege.DateEnd)
         {
             Global.errors3.Add("Несовпадение DateEnd TestPrivilege");
         }
         if (this.privilege.DateStart != b.privilege.DateStart)
         {
             Global.errors3.Add("Несовпадение DateStart TestPrivilege");
         }
         if (this.privilege.IdPrivilegeType != b.privilege.IdPrivilegeType)
         {
             Global.errors3.Add("Несовпадение IdPrivilageType TestPrivilege");
         }
     }
 }
Esempio n. 3
0
 public TestPatient(string guid, string idlpu, PatientDto p)
 {
     patient = p;
     if ((guid != null) && (idlpu != null) && (p.IdPatientMIS != null))
         patient.IdGlobal = GetPatientId(guid, idlpu, p.IdPatientMIS);
     GUID = guid.ToLower();
     IDLPU = idlpu;
     if ((p.Documents != null) && (p.Documents.Length != 0))
     {
         List<TestDocument> doc = new List<TestDocument>();
         foreach (DocumentDto d in p.Documents)
         {
             doc.Add(new TestDocument(d));
         }
         documents = doc;
     }
     if ((p.Addresses != null) && (p.Addresses.Length != 0))
     {
         List<TestAddress> add = new List<TestAddress>();
         foreach (AddressDto a in p.Addresses)
         {
             add.Add(new TestAddress(a));
         }
         addreses = add;
     }
     if ((p.Contacts != null) && (p.Contacts.Length != 0))
     {
         List<TestContact> cont = new List<TestContact>();
         foreach(ContactDto c in p.Contacts)
         {
             cont.Add(new TestContact(c));
         }
         contacts = cont;
     }
     if (p.Job != null)
         job = new TestJob(p.Job);
     if (p.Privilege != null)
         privilege = new TestPrivilege(p.Privilege);
     if (p.BirthPlace != null)
         birthplace = new TestBirthplace(p.BirthPlace);
 }
Esempio n. 4
0
 public static TestPrivilege BuildTestPrivilegeFromDataBase(string idPerson)
 {
     using (SqlConnection connection = Global.GetSqlConnection())
     {
         string findPatient = "SELECT TOP(1) * FROM Privilege WHERE IdPrivilege = (SELECT MAX(IdPrivilege) FROM Privilege  WHERE IdPerson = '" + idPerson + "')";
         SqlCommand person = new SqlCommand(findPatient, connection);
         using (SqlDataReader privilegeReader = person.ExecuteReader())
         {
             while (privilegeReader.Read())
             {
                 PrivilegeDto privilege = new PrivilegeDto();
                 privilege.DateStart = Convert.ToDateTime(privilegeReader["DateStart"]);
                 privilege.DateEnd = Convert.ToDateTime(privilegeReader["DateEnd"]);
                 privilege.IdPrivilegeType = Convert.ToByte(privilegeReader["IdPrivilegeType"]);
                 TestPrivilege p = new TestPrivilege(privilege);
                 return p;
             }
         }
     }
     return null;
 }
Esempio n. 5
0
 static public TestPrivilege BuildTestPrivilegeFromDataBase(string idPerson)
 {
     using (SqlConnection connection = Global.GetSqlConnection())
     {
         string     findPatient = "SELECT TOP(1) * FROM Privilege WHERE IdPrivilege = (SELECT MAX(IdPrivilege) FROM Privilege  WHERE IdPerson = '" + idPerson + "')";
         SqlCommand person      = new SqlCommand(findPatient, connection);
         using (SqlDataReader privilegeReader = person.ExecuteReader())
         {
             while (privilegeReader.Read())
             {
                 PrivilegeDto privilege = new PrivilegeDto();
                 privilege.DateStart       = Convert.ToDateTime(privilegeReader["DateStart"]);
                 privilege.DateEnd         = Convert.ToDateTime(privilegeReader["DateEnd"]);
                 privilege.IdPrivilegeType = Convert.ToByte(privilegeReader["IdPrivilegeType"]);
                 TestPrivilege p = new TestPrivilege(privilege);
                 return(p);
             }
         }
     }
     return(null);
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 public void FindMismatch(TestPrivilege b)
 {
     if (b.privilege != null)
     {
         if (this.privilege.DateEnd != b.privilege.DateEnd)
             Global.errors3.Add("Несовпадение DateEnd TestPrivilege");
         if (this.privilege.DateStart != b.privilege.DateStart)
             Global.errors3.Add("Несовпадение DateStart TestPrivilege");
         if (this.privilege.IdPrivilegeType != b.privilege.IdPrivilegeType)
             Global.errors3.Add("Несовпадение IdPrivilageType TestPrivilege");
     }
 }
Esempio n. 8
0
 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);
     }
 }
Esempio n. 9
0
 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);
 }