static public string GetPersonId(string guid, string idlpu, string mis) { string patientId = ""; string findIdPersonString = ""; using (SqlConnection connection = Global.GetSqlConnection()) { string InstId = Global.GetIdInstitution(idlpu); findIdPersonString = "SELECT TOP(1) * FROM ExternalId WHERE IdPersonMIS = '" + mis + "' AND IdLpu = '" + InstId + "' AND SystemGuid = '" + guid.ToLower() + "'"; SqlCommand command = new SqlCommand(findIdPersonString, connection); using (SqlDataReader IdPerson = command.ExecuteReader()) { while (IdPerson.Read()) { patientId = IdPerson["IdPerson"].ToString(); } } } if (patientId != "") { return(patientId); } else { return(null); } }
public byte[] GetResultDocument(string GUID, string idLpu, string idCaseMis, int documentType) { ResultDocument a = client.GetResultDocument(GUID, idLpu, idCaseMis, documentType); byte[] b = {}; using (SqlConnection connection = Global.GetSqlConnection()) { string findPatient = "SELECT TOP(1) Attachment FROM MedDocument, Step, \"Case\" WHERE IdMedDocumentType = '" + documentType + "' AND IdCaseMis = '" + idCaseMis + "' AND IdLpu <= '" + Global.GetIdInstitution(idLpu) + "' AND MedDocument.IdStep = Step.IdStep AND Step.IdCase = \"Case\".IdCase ORDER BY IdMedDocument DESC"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader documentReader = person.ExecuteReader()) { // bool a = documentReader.Read(); while (documentReader.Read()) { b = (byte[])(documentReader["Attachment"]); } } } if (!a.Data.SequenceEqual(b)) { Global.errors1.Add("Несовпадение базового и возвращенного документов"); } return(a.Data); }
static public string GetCaseId(string guid, string idlpu, string mis, string patientId) { if (patientId.ToString() != "") { string caseId = ""; string findIdCaseString = ""; using (SqlConnection connection = Global.GetSqlConnection()) { string InstId = Global.GetIdInstitution(idlpu); if (mis != "") { findIdCaseString = "SELECT TOP(1) * FROM \"Case\" WHERE IdCase = (SELECT MAX(IdCase) FROM \"Case\" WHERE IdCaseMIS = '" + mis + "' AND IdLpu = '" + InstId + "' AND SystemGuid = '" + guid.ToLower() + "' AND IdPerson = '" + patientId + "')"; } else { findIdCaseString = "SELECT TOP(1) * FROM \"Case\" WHERE IdCase = (SELECT MAX(IdCase) FROM \"Case\" WHERE IdCaseType = '" + masterCaseId + "' AND IdLpu = '" + InstId + "' AND SystemGuid = '" + guid.ToLower() + "' AND IdPerson = '" + patientId + "')"; } SqlCommand command = new SqlCommand(findIdCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { caseId = IdCaseReader["IdCase"].ToString(); } } } if (caseId != "") { return(caseId); } else { return(null); } } return(null); }
public void GetCasesByPeriod(string GUID, DateTime datestart, DateTime dateend) { List <TestCaseBase> MyFindedCase = new List <TestCaseBase>(); using (SqlConnection connection = Global.GetSqlConnection()) { string findCaseString = "SELECT * FROM \"Case\" WHERE OpenDate >= '" + datestart + "' AND OpenDate <= '" + dateend + "' AND CloseDate IS NOT NULL AND IsCancelled = 'False'"; SqlCommand command = new SqlCommand(findCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { string guid = IdCaseReader["SystemGuid"].ToString(); string idCaseMis = IdCaseReader["IdCaseMIS"].ToString(); string idLpu = Global.GetIdIdLpu(IdCaseReader["IdLpu"].ToString()); string patientId = IdCaseReader["IdPerson"].ToString(); TestAmbCase ambCase = TestAmbCase.BuildAmbCaseFromDataBaseData(guid, idLpu, idCaseMis, patientId); if ((object)ambCase != null) { MyFindedCase.Add(ambCase); } TestStatCase statCase = TestStatCase.BuildAmbCaseFromDataBaseData(guid, idLpu, idCaseMis, patientId); if ((object)statCase != null) { MyFindedCase.Add(statCase); } string idCase = IdCaseReader["IdCase"].ToString(); } } } CaseBase[] cb = client.GetCasesByPeriod(GUID, datestart, dateend); List <TestCaseBase> FunctionFindedCase = new List <TestCaseBase>(); foreach (CaseBase i in cb) { CaseAmb ca = i as CaseAmb; if ((object)ca != null) { using (SqlConnection connection = Global.GetSqlConnection()) { string findCaseString = "SELECT TOP(1) [SystemGuid] FROM \"ExternalId\" WHERE IdLpu = '" + Global.GetIdInstitution(ca.IdLpu) + "' AND IdPersonMIS = '" + ca.IdPatientMis + "'"; SqlCommand command = new SqlCommand(findCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { GUID = IdCaseReader["SystemGuid"].ToString(); } } } TestAmbCase tac = new TestAmbCase(GUID, (EMKServise.CaseAmb)ConvertCase(ca)); //if (!tac.CheckCaseInDataBase()) // Global.errors1.Add("Что-то пошло не так"); FunctionFindedCase.Add(tac); } CaseStat cs = i as CaseStat; if ((object)cs != null) { using (SqlConnection connection = Global.GetSqlConnection()) { string findCaseString = "SELECT TOP(1) [SystemGuid] FROM \"ExternalId\" WHERE IdLpu = '" + Global.GetIdInstitution(cs.IdLpu) + "' AND IdPersonMIS = '" + cs.IdPatientMis + "'"; SqlCommand command = new SqlCommand(findCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { GUID = IdCaseReader["SystemGuid"].ToString(); } } } TestStatCase tsc = new TestStatCase(GUID, (EMKServise.CaseStat)ConvertCase(cs)); //if (!tsc.CheckCaseInDataBase()) // Global.errors1.Add("Что-то пошло не так"); FunctionFindedCase.Add(tsc); } } if (Global.GetLength(MyFindedCase) > Global.GetLength(FunctionFindedCase)) { Global.errors1.Add("Возвращено меньше, чем в базе"); } if (Global.GetLength(MyFindedCase) < Global.GetLength(FunctionFindedCase)) { Global.errors1.Add("Возвращено больше, чем в базе"); } if (Global.GetLength(MyFindedCase) == Global.GetLength(FunctionFindedCase)) { if (!Global.IsEqual(MyFindedCase.ToArray(), FunctionFindedCase.ToArray())) { Global.errors1.AddRange(Global.errors2); } } }