Beispiel #1
0
        static private string[] GetGUIDandIDLPUandIDMIS(string idPerson)
        {
            string guid  = "";
            string idlpu = "";
            string mis   = "";

            using (SqlConnection connection = Global.GetSqlConnection())
            {
                string     findPatient = "SELECT TOP(1) * FROM ExternalId WHERE IdPerson = '" + idPerson + "'";
                SqlCommand person      = new SqlCommand(findPatient, connection);
                using (SqlDataReader patientFromDataBase = person.ExecuteReader())
                {
                    while (patientFromDataBase.Read())
                    {
                        guid = Convert.ToString(patientFromDataBase["SystemGuid"]);
                        mis  = Convert.ToString(patientFromDataBase["IdPersonMIS"]);
                        if (Data.type == Type.guid)
                        {
                            idlpu = Convert.ToString(patientFromDataBase["IdLpu"]);
                        }
                        else
                        {
                            idlpu = Global.GetIdIdLpu(Convert.ToString(patientFromDataBase["IdLpu"]));
                            //string findIdInstitutionalString =
                            //    "SELECT TOP(1) IdFedNsi FROM Institution WHERE IdInstitution = '" + lpu + "'";
                            //using (SqlConnection connection2 = Global.GetSqlConnection())
                            //{
                            //    SqlCommand IdInstitution = new SqlCommand(findIdInstitutionalString, connection2);
                            //    using (SqlDataReader IdInstitutional = IdInstitution.ExecuteReader())
                            //    {
                            //        while (IdInstitutional.Read())
                            //        {
                            //            idlpu = Convert.ToString(IdInstitutional["IdFedNsi"]);
                            //        }
                            //    }
                            //}
                        }
                    }
                }
            }
            string[] s = new string[] { guid, idlpu, mis };
            return(s);
        }
Beispiel #2
0
        //public TestReferral(ReferralDto r)
        //{
        //    referral = new Referral
        //    {
        //        ReferralInfo = new ReferralInfo
        //        {
        //            IdReferralType = Convert.ToByte(r.IdReferralType),
        //            IdReferralMis = r.IdReferralMis,
        //            IssuedDateTime = r.IssuedDateTime,
        //            //r.IdUrgencyType;
        //            MkbCode = r.MkbCode,
        //            Reason = r.Reason
        //        },
        //        IdSourceLpu = r.IdSourceLpu,
        //        IdTargetLpu = r.IdTargetLpu,
        //        //r.IdLPU;
        //    };
        //    attachment = new TestAttachment(new MedDocument.DocumentAttachment());
        //    doctor = TestDoctor.BuildTestDoctorFromDataBase(r.IdDoctorRef);
        //    departmentHead = TestDoctor.BuildTestDoctorFromDataBase(r.IdRefDepartmentHead);
        //}
        static public List <TestReferral> BuildReferralFromDataBaseData(string idStep)
        {
            List <TestReferral> trl = new List <TestReferral>();

            if (idStep != "")
            {
                List <TestAttachment> lta = TestAttachment.BuildTestAttacmentFromDataBase(idStep, idReferral);
                if (lta != null)
                {
                    foreach (TestAttachment i in lta)
                    {
                        using (SqlConnection connection = Global.GetSqlConnection())
                        {
                            string     findR    = "SELECT * FROM Referral WHERE IdMedDocument = '" + i.idMedDocument + "'";
                            SqlCommand Rcommand = new SqlCommand(findR, connection);
                            using (SqlDataReader RReader = Rcommand.ExecuteReader())
                            {
                                while (RReader.Read())
                                {
                                    Referral r = new Referral();
                                    r.ReferralInfo = new ReferralInfo();
                                    if (RReader["MkbCode"].ToString() != "")
                                    {
                                        r.ReferralInfo.MkbCode = Convert.ToString(RReader["MkbCode"]);
                                    }
                                    if (RReader["IdSourceLpu"].ToString() != "")
                                    {
                                        r.IdSourceLpu = Global.GetIdIdLpu(Convert.ToString(RReader["IdSourceLpu"]));
                                    }
                                    if (RReader["IdTargetLpu"].ToString() != "")
                                    {
                                        r.IdTargetLpu = Global.GetIdIdLpu(Convert.ToString(RReader["IdTargetLpu"]));
                                    }
                                    if (RReader["Reason"].ToString() != "")
                                    {
                                        r.ReferralInfo.Reason = Convert.ToString(RReader["Reason"]);
                                    }
                                    if (RReader["IdReferralMIS"].ToString() != "")
                                    {
                                        r.ReferralInfo.IdReferralMis = Convert.ToString(RReader["IdReferralMIS"]);
                                    }
                                    if (RReader["IdReferralType"].ToString() != "")
                                    {
                                        r.ReferralInfo.IdReferralType = Convert.ToByte(RReader["IdReferralType"]);
                                    }
                                    if (RReader["IssuedDateTime"].ToString() != "")
                                    {
                                        r.ReferralInfo.IssuedDateTime = Convert.ToDateTime(RReader["IssuedDateTime"]);
                                    }
                                    if (RReader["IdHospitalizationOrder"].ToString() != "")
                                    {
                                        r.ReferralInfo.HospitalizationOrder = Convert.ToByte(RReader["IdHospitalizationOrder"]);
                                    }
                                    if (RReader["ReferralId"].ToString() != "")
                                    {
                                        r.ReferralID = Convert.ToString(RReader["ReferralId"]);
                                    }
                                    if (RReader["RelatedId"].ToString() != "")
                                    {
                                        r.RelatedID = Convert.ToString(RReader["RelatedId"]);
                                    }
                                    r.CreationDate = i.CreationDate;
                                    r.Header       = i.DocHead;
                                    //Тут нет ReferalId и referedId
                                    TestReferral tr = new TestReferral(r);
                                    tr.attachment = i;
                                    if (RReader["IdRefDepartmentHead"].ToString() != "")
                                    {
                                        tr.departmentHead = TestDoctor.BuildTestDoctorFromDataBase((RReader["IdRefDepartmentHead"]).ToString());
                                    }
                                    tr.doctor = TestDoctor.BuildTestDoctorFromDataBase(i.IdDoctor);
                                    trl.Add(tr);
                                }
                            }
                        }
                    }
                }
            }
            if (trl.Count != 0)
            {
                return(trl);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        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);
                }
            }
        }