Exemple #1
0
        static public TestCaseBase BuildBaseCaseFromDataBaseData(string guid, string idlpu, string mis, string idPerson)
        {
            //idPerson = TestPerson.GetPersonId(guid, idlpu, idPerson);
            string caseId = GetCaseId(guid, idlpu, mis, idPerson);

            if (caseId != null)
            {
                using (SqlConnection connection = Global.GetSqlConnection())
                {
                    string     IdDoctor    = "";
                    string     IdGuardian  = "";
                    int        idCaseT     = 0;
                    bool       isCanceld   = false;
                    CaseBase   p           = new CaseBase();
                    string     findCase    = "SELECT TOP(1) * FROM \"Case\" WHERE IdCase = '" + caseId + "'";
                    SqlCommand caseCommand = new SqlCommand(findCase, connection);
                    using (SqlDataReader caseReader = caseCommand.ExecuteReader())
                    {
                        while (caseReader.Read())
                        {
                            if (caseReader["CloseDate"].ToString() != "")
                            {
                                p.CloseDate = Convert.ToDateTime(caseReader["CloseDate"]);
                            }
                            else
                            {
                                p.CloseDate = DateTime.MinValue;
                            }
                            if (caseReader["Comment"].ToString() != "")
                            {
                                p.Comment = Convert.ToString(caseReader["Comment"]);
                            }
                            else
                            {
                                p.Comment = null;
                            }
                            if (caseReader["HistoryNumber"].ToString() != "")
                            {
                                p.HistoryNumber = Convert.ToString(caseReader["HistoryNumber"]);
                            }
                            else
                            {
                                p.HistoryNumber = null;
                            }
                            if (caseReader["IdCaseAidType"].ToString() != "")
                            {
                                p.IdCaseAidType = Convert.ToByte(caseReader["IdCaseAidType"]);
                            }
                            else
                            {
                                p.IdCaseAidType = 0;
                            }
                            if (caseReader["IdCaseMis"].ToString() != "")
                            {
                                p.IdCaseMis = Convert.ToString(caseReader["IdCaseMis"]);
                            }
                            else
                            {
                                p.IdCaseMis = null;
                            }
                            if (caseReader["IdCaseResult"].ToString() != "")
                            {
                                p.IdCaseResult = Convert.ToByte(caseReader["IdCaseResult"]);
                            }
                            else
                            {
                                p.IdCaseResult = 0;
                            }
                            if (caseReader["IdCasePaymentType"].ToString() != "")
                            {
                                p.IdPaymentType = Convert.ToByte(caseReader["IdCasePaymentType"]);
                            }
                            else
                            {
                                p.IdPaymentType = 0;
                            }
                            if (caseReader["OpenDate"].ToString() != "")
                            {
                                p.OpenDate = Convert.ToDateTime(caseReader["OpenDate"]);
                            }
                            else
                            {
                                p.OpenDate = DateTime.MinValue;
                            }
                            if (caseReader["IDDoctor"].ToString() != "")
                            {
                                IdDoctor = Convert.ToString(caseReader["IDDoctor"]);
                            }
                            if (caseReader["IdGuardian"].ToString() != "")
                            {
                                IdGuardian = Convert.ToString(caseReader["IDGuardian"]);
                            }
                            if (caseReader["IdCaseType"].ToString() != "")
                            {
                                idCaseT = Convert.ToInt32(caseReader["IdCaseType"]);
                            }
                            isCanceld = Convert.ToBoolean(caseReader["IsCancelled"]);
                        }
                    }
                    findCase    = "SELECT * FROM mm_AccessRole2Case WHERE IdCase = '" + caseId + "'";
                    caseCommand = new SqlCommand(findCase, connection);
                    using (SqlDataReader caseReader = caseCommand.ExecuteReader())
                    {
                        while (caseReader.Read())
                        {
                            switch (caseReader["IdAccessRole"].ToString())
                            {
                            case "1":
                                p.Confidentiality = Convert.ToByte(caseReader["IdPrivacyLevel"]);
                                break;

                            case "2":
                                p.DoctorConfidentiality = Convert.ToByte(caseReader["IdPrivacyLevel"]);
                                break;

                            case "3":
                                p.CuratorConfidentiality = Convert.ToByte(caseReader["IdPrivacyLevel"]);
                                break;
                            }
                        }
                    }
                    p.IdCaseMis = mis;
                    p.IdLpu     = idlpu;
                    TestCaseBase cb = new TestCaseBase(guid, p);
                    cb.idCaseType = idCaseT;
                    cb.isCanceld  = isCanceld;
                    if (IdDoctor != "")
                    {
                        cb.doctorInCharge = TestDoctor.BuildTestDoctorFromDataBase(IdDoctor);
                    }
                    else
                    {
                        cb.doctorInCharge = null;
                    }
                    if (IdGuardian != "")
                    {
                        cb.guardian = TestGuardian.BuildTestGuardianFromDataBase(IdGuardian, idPerson);
                    }
                    else
                    {
                        cb.guardian = null;
                    }
                    if (idPerson != "")
                    {
                        cb.patient = TestPatient.BuildPatientFromDataBaseData(patientId: idPerson);
                    }
                    else
                    {
                        cb.patient = null;
                    }
                    findCase    = "SELECT * FROM mm_Author2Case WHERE IdCase = '" + caseId + "'";
                    caseCommand = new SqlCommand(findCase, connection);
                    using (SqlDataReader caseReader = caseCommand.ExecuteReader())
                    {
                        while (caseReader.Read())
                        {
                            switch (caseReader["IdAuthorshipType"].ToString())
                            {
                            case "1":
                                cb.autor = TestParticipant.BuildTestParticipantFromDataBase(caseId, Convert.ToString(caseReader["IdDoctor"]), 1);
                                break;

                            case "3":
                                cb.authenticator = TestParticipant.BuildTestParticipantFromDataBase(caseId, Convert.ToString(caseReader["IdDoctor"]), 3);
                                break;

                            case "4":
                                cb.legalAuthenticator = TestParticipant.BuildTestParticipantFromDataBase(caseId, Convert.ToString(caseReader["IdDoctor"]), 4);
                                break;
                            }
                        }
                    }
                    return(cb);
                }
            }
            return(null);
        }
Exemple #2
0
        static public List <TestService> BuildServiseFromDataBaseData(string IdStep)
        {
            List <TestService> serviseList = new List <TestService>();

            using (SqlConnection connection = Global.GetSqlConnection())
            {
                string     findService    = "SELECT * FROM Service, Step, nsi.ServiceType WHERE Service.IdStep = '" + IdStep + "' AND Service.IdStep = Step.IdStep AND Service.idServiceType = nsi.ServiceType.IdServiceType";
                SqlCommand serviceCommand = new SqlCommand(findService, connection);
                using (SqlDataReader serviceReader = serviceCommand.ExecuteReader())
                {
                    while (serviceReader.Read())
                    {
                        Service s = new Service();
                        s.PaymentInfo = new PaymentInfo();
                        if (serviceReader["DateEnd"].ToString() != "")
                        {
                            s.DateEnd = Convert.ToDateTime(serviceReader["DateEnd"]);
                        }
                        else
                        {
                            s.DateEnd = DateTime.MinValue;
                        }
                        if (serviceReader["DateStart"].ToString() != "")
                        {
                            s.DateStart = Convert.ToDateTime(serviceReader["DateStart"]);
                        }
                        else
                        {
                            s.DateStart = DateTime.MinValue;
                        }
                        if (serviceReader["IdFedNsi"].ToString() != "")
                        {
                            s.IdServiceType = Convert.ToString(serviceReader["IdFedNsi"]);
                        }
                        if (serviceReader["ServiceName"].ToString() != "")
                        {
                            s.ServiceName = Convert.ToString(serviceReader["ServiceName"]);
                        }
                        if (serviceReader["IdRHealthCareUnit"].ToString() != "")
                        {
                            s.PaymentInfo.HealthCareUnit = Convert.ToByte(serviceReader["IdRHealthCareUnit"]);
                        }
                        if (serviceReader["IdRVisitPaymentType"].ToString() != "")
                        {
                            s.PaymentInfo.IdPaymentType = Convert.ToByte(serviceReader["IdRVisitPaymentType"]);
                        }
                        if (serviceReader["IdRPaymentStatus"].ToString() != "")
                        {
                            s.PaymentInfo.PaymentState = Convert.ToByte(serviceReader["IdRPaymentStatus"]);
                        }
                        if (serviceReader["Quantity"].ToString() != "")
                        {
                            s.PaymentInfo.Quantity = Convert.ToInt32(serviceReader["Quantity"]);
                        }
                        if (serviceReader["Tariff"].ToString() != "")
                        {
                            s.PaymentInfo.Tariff = Convert.ToDecimal(serviceReader["Tariff"]);
                        }
                        TestService ts = new TestService(s);
                        if ((serviceReader["IdPersonRole"].ToString() != "") && (serviceReader["IdCase"].ToString() != ""))
                        {
                            ts.doctor = TestParticipant.BuildTestParticipantFromDataBase(serviceReader["IdCase"].ToString(), serviceReader["IdDoctor"].ToString(), Convert.ToByte(serviceReader["IdPersonRole"]));
                        }
                        serviseList.Add(ts);
                    }
                }
            }
            if (serviseList.Count != 0)
            {
                return(serviseList);
            }
            else
            {
                return(null);
            }
        }