public static List<TestDocument> BuildDocumentsFromDataBaseData(string idPerson) { List<TestDocument> documents = new List<TestDocument>(); using (SqlConnection connection = Global.GetSqlConnection()) { foreach (int i in Enum.GetValues(typeof(docs))) { string findPatient = "SELECT TOP(1) * FROM Document WHERE IdDocument = (SELECT MAX(IdDocument) FROM Document WHERE IdPerson = '" + idPerson + "' AND IdDocumentType = '" + i + "')"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader documentReader = person.ExecuteReader()) { while (documentReader.Read()) { DocumentDto doc = new DocumentDto(); if (documentReader["DocN"].ToString() != "") doc.DocN = Convert.ToString(documentReader["DocN"]); if (documentReader["ProviderName"].ToString() != "") doc.ProviderName = Convert.ToString(documentReader["ProviderName"]); if (documentReader["IdDocumentType"].ToString() != "") doc.IdDocumentType = Convert.ToByte(documentReader["IdDocumentType"]); if (documentReader["DocS"].ToString() != "") doc.DocS = Convert.ToString(documentReader["DocS"]); if (documentReader["IdProvider"].ToString() != "") doc.IdProvider = Convert.ToString(documentReader["IdProvider"]); if (documentReader["IssuedDate"].ToString() != "") doc.IssuedDate = Convert.ToDateTime(documentReader["IssuedDate"]); if (documentReader["ExpiredDate"].ToString() != "") doc.ExpiredDate = Convert.ToDateTime(documentReader["ExpiredDate"]); if (documentReader["RegionCode"].ToString() != "") doc.RegionCode = Convert.ToString(documentReader["RegionCode"]); TestDocument document = new TestDocument(doc); documents.Add(document); } } } } if (documents.Count != 0) return documents; else return null; }
static public List <TestDocument> BuildDocumentsFromDataBaseData(string idPerson) { List <TestDocument> documents = new List <TestDocument>(); using (SqlConnection connection = Global.GetSqlConnection()) { foreach (int i in Enum.GetValues(typeof(docs))) { string findPatient = "SELECT TOP(1) * FROM Document WHERE IdDocument = (SELECT MAX(IdDocument) FROM Document WHERE IdPerson = '" + idPerson + "' AND IdDocumentType = '" + i + "')"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader documentReader = person.ExecuteReader()) { while (documentReader.Read()) { DocumentDto doc = new DocumentDto(); if (documentReader["DocN"].ToString() != "") { doc.DocN = Convert.ToString(documentReader["DocN"]); } if (documentReader["ProviderName"].ToString() != "") { doc.ProviderName = Convert.ToString(documentReader["ProviderName"]); } if (documentReader["IdDocumentType"].ToString() != "") { doc.IdDocumentType = Convert.ToByte(documentReader["IdDocumentType"]); } if (documentReader["DocS"].ToString() != "") { doc.DocS = Convert.ToString(documentReader["DocS"]); } if (documentReader["IdProvider"].ToString() != "") { doc.IdProvider = Convert.ToString(documentReader["IdProvider"]); } if (documentReader["IssuedDate"].ToString() != "") { doc.IssuedDate = Convert.ToDateTime(documentReader["IssuedDate"]); } if (documentReader["ExpiredDate"].ToString() != "") { doc.ExpiredDate = Convert.ToDateTime(documentReader["ExpiredDate"]); } if (documentReader["RegionCode"].ToString() != "") { doc.RegionCode = Convert.ToString(documentReader["RegionCode"]); } TestDocument document = new TestDocument(doc); documents.Add(document); } } } } if (documents.Count != 0) { return(documents); } else { return(null); } }
private void FindMismatch(TestDocument b) { if (this.document.DocN != b.document.DocN) Global.errors3.Add("Несовпадение DocN TestDocument"); if (this.document.DocS != b.document.DocS) Global.errors3.Add("Несовпадение DocS TestDocument"); if (this.document.ExpiredDate != b.document.ExpiredDate) Global.errors3.Add("Несовпадение ExpiredDate TestDocument"); if (this.document.IdDocumentType != b.document.IdDocumentType) Global.errors3.Add("Несовпадение IdDocumentType TestDocument"); if (this.document.IdProvider != b.document.IdProvider) Global.errors3.Add("Несовпадение IdProvider TestDocument"); if (this.document.IssuedDate != b.document.IssuedDate) Global.errors3.Add("Несовпадение IssuedDate TestDocument"); if (this.document.ProviderName != b.document.ProviderName) Global.errors3.Add("Несовпадение ProviderName TestDocument"); if (this.document.RegionCode != b.document.RegionCode) Global.errors3.Add("Несовпадение RegionCode TestDocument"); }
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); }