Beispiel #1
0
        public bool CheckPatientInDataBase()
        {
            TestPatient p = TestPatient.BuildPatientFromDataBaseData(GUID, IDLPU, patient.IdPatientMIS);

            this.Equals(p);
            return(this == p);
        }
Beispiel #2
0
 public TestCaseBase(string guid, CaseBase cb)
 {
     GUID = guid.ToLower();
     if (cb != null)
     {
         caseBase = cb;
         if (caseBase.OpenDate == null)
         {
             caseBase.OpenDate = DateTime.MinValue;
         }
         if (caseBase.CloseDate == null)
         {
             caseBase.CloseDate = DateTime.MinValue;
         }
     }
     if (cb.Author != null)
     {
         autor = new TestParticipant(cb.Author, cb.IdLpu);
         if (autor.doctor.doctor.IdLpu == null)
         {
             autor.doctor.doctor.IdLpu = cb.IdLpu;
         }
     }
     if (cb.Authenticator != null)
     {
         authenticator = new TestParticipant(cb.Authenticator, cb.IdLpu);
         if (authenticator.doctor.doctor.IdLpu == null)
         {
             authenticator.doctor.doctor.IdLpu = cb.IdLpu;
         }
     }
     if (cb.LegalAuthenticator != null)
     {
         legalAuthenticator = new TestParticipant(cb.LegalAuthenticator, cb.IdLpu);
         if (legalAuthenticator.doctor.doctor.IdLpu == null)
         {
             legalAuthenticator.doctor.doctor.IdLpu = cb.IdLpu;
         }
     }
     if (cb.DoctorInCharge != null)
     {
         doctorInCharge = new TestDoctor(cb.DoctorInCharge, cb.IdLpu);
         if (doctorInCharge.doctor.IdLpu == null)
         {
             doctorInCharge.doctor.IdLpu = cb.IdLpu;
         }
     }
     if (cb.Guardian != null)
     {
         guardian = new TestGuardian(cb.Guardian);
     }
     if (cb.IdPatientMis != null)
     {
         patient = TestPatient.BuildPatientFromDataBaseData(guid, cb.IdLpu, cb.IdPatientMis);
     }
 }
Beispiel #3
0
        public void UpdatePatient(string guid, string idlpu, PatientDto patient)
        {
            TestPatient example = TestPatient.BuildPatientFromDataBaseData(guid, idlpu, patient.IdPatientMIS);

            example.ChangePatientField(patient);
            client.UpdatePatient(guid, idlpu, patient);
            if (!example.CheckPatientInDataBase())
            {
                Global.errors1.Add("Не совпадение значений объектов");
            }
        }
Beispiel #4
0
        public void AddPatient(string guid, string idlpu, PatientDto patient)
        {
            TestPatient p = new TestPatient(guid, idlpu, patient);

            try
            {
                p.DeletePatient();
                client.AddPatient(guid, idlpu, patient);
                p = new TestPatient(guid, idlpu, patient);
                TestPatient a = TestPatient.BuildPatientFromDataBaseData(guid, idlpu, patient.IdPatientMIS);
                if (!p.CheckPatientInDataBase())
                {
                    Global.errors1.AddRange(Global.errors2);
                    Global.errors1.Add("Не совпадение значений объектов");
                }
            }
            catch (System.ServiceModel.FaultException <PixServiseTests.PixServise.RequestFault> we)
            {
                if (we.Detail.Message == reinclusionString)
                {
                    TestPatient wwww = TestPatient.BuildPatientFromDataBaseData(guid, idlpu, patient.IdPatientMIS);
                    if (TestPatient.BuildPatientFromDataBaseData(guid, idlpu, patient.IdPatientMIS) == null)
                    {
                        Global.errors1.Add("Ошибочное сообщение о попытке повторного добавления");
                    }
                    else
                    {
                        Global.errors1.Add(we.Detail.Message);
                    }
                }
                else
                {
                    Global.errors1.Add(we.Detail.Message);
                }
            }
        }
Beispiel #5
0
 public void UpdateCaseBase(string guid, CaseBase cb)
 {
     if (guid != "")
     {
         GUID = guid.ToLower();
     }
     if (cb != null)
     {
         if (cb.CloseDate != DateTime.MinValue)
         {
             this.caseBase.CloseDate = cb.CloseDate;
         }
         if (cb.Comment != "")
         {
             this.caseBase.Comment = cb.Comment;
         }
         if (cb.Confidentiality != 0)
         {
             this.caseBase.Confidentiality = cb.Confidentiality;
         }
         if (cb.CuratorConfidentiality != 0)
         {
             this.caseBase.CuratorConfidentiality = cb.CuratorConfidentiality;
         }
         if (cb.DoctorConfidentiality != 0)
         {
             this.caseBase.DoctorConfidentiality = cb.DoctorConfidentiality;
         }
         if (cb.HistoryNumber != "")
         {
             this.caseBase.HistoryNumber = cb.HistoryNumber;
         }
         if (cb.IdCaseAidType != 0)
         {
             this.caseBase.IdCaseAidType = cb.IdCaseAidType;
         }
         if (cb.IdCaseMis != "")
         {
             this.caseBase.IdCaseMis = cb.IdCaseMis;
         }
         if (cb.IdCaseResult != 0)
         {
             this.caseBase.IdCaseResult = cb.IdCaseResult;
         }
         if (cb.IdLpu != "")
         {
             this.caseBase.IdLpu = cb.IdLpu;
         }
         if (cb.IdPaymentType != 0)
         {
             this.caseBase.IdPaymentType = cb.IdPaymentType;
         }
         if (cb.OpenDate != DateTime.MinValue)
         {
             this.caseBase.OpenDate = cb.OpenDate;
         }
         if (cb.Author != null)
         {
             autor = new TestParticipant(cb.Author, cb.IdLpu);
             if (autor.doctor.doctor.IdLpu == null)
             {
                 autor.doctor.doctor.IdLpu = cb.IdLpu;
             }
         }
         if (cb.Authenticator != null)
         {
             authenticator = new TestParticipant(cb.Authenticator, cb.IdLpu);
             if (authenticator.doctor.doctor.IdLpu == null)
             {
                 authenticator.doctor.doctor.IdLpu = cb.IdLpu;
             }
         }
         if (cb.LegalAuthenticator != null)
         {
             legalAuthenticator = new TestParticipant(cb.LegalAuthenticator, cb.IdLpu);
             if (legalAuthenticator.doctor.doctor.IdLpu == null)
             {
                 legalAuthenticator.doctor.doctor.IdLpu = cb.IdLpu;
             }
         }
         if (cb.DoctorInCharge != null)
         {
             doctorInCharge = new TestDoctor(cb.DoctorInCharge, cb.IdLpu);
             if (doctorInCharge.doctor.IdLpu == null)
             {
                 doctorInCharge.doctor.IdLpu = cb.IdLpu;
             }
         }
         if (cb.Guardian != null)
         {
             guardian = new TestGuardian(cb.Guardian);
         }
         if (cb.IdPatientMis != null)
         {
             patient = TestPatient.BuildPatientFromDataBaseData(guid, cb.IdLpu, cb.IdPatientMis);
         }
     }
 }
Beispiel #6
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);
        }
Beispiel #7
0
        public ArrayList Find(string guid, string idlpu, TestPatient patient)
        {
            string findPatient = "";

            if (patient.patient.IdPatientMIS != null)
            {
                findPatient = "SELECT * FROM ExternalId WHERE IdPersonMIS = '" + patient.patient.IdPatientMIS + "' AND SystemGuid = '" + guid + "'";
            }
            else
            {
                if (patient.patient.Sex == 0)
                {
                    findPatient = "SELECT * FROM Person WHERE FamilyName = '" + patient.patient.FamilyName + "' AND GivenName ='" + patient.patient.GivenName + "' AND BirthDate ='" + patient.patient.BirthDate + "'";
                }
                else
                {
                    findPatient = "SELECT * FROM Person WHERE FamilyName = '" + patient.patient.FamilyName + "' AND GivenName ='" + patient.patient.GivenName + "' AND BirthDate ='" + patient.patient.BirthDate + "' AND IdSex ='" + patient.patient.Sex + "'";
                }
            }
//            ContactPersonDto p = new ContactPersonDto();
            ArrayList patients  = new ArrayList();
            string    patientId = "";

            using (SqlConnection connection = Global.GetSqlConnection())
            {
                SqlCommand findPatients = new SqlCommand(findPatient, connection);
                using (SqlDataReader patientsReader = findPatients.ExecuteReader())
                {
                    //int i = 0;
                    while (patientsReader.Read())
                    {
                        patientId = Convert.ToString(patientsReader["IdPerson"]);
                        if (patient.documents != null)
                        {
                            string findDoc = "";
                            if (patient.documents[0].document.DocS != null)
                            {
                                findDoc = "SELECT * FROM Document WHERE IdPerson = '" + patientId + "' AND DocS ='" + patient.documents[0].document.DocS + "' AND DocN ='" + patient.documents[0].document.DocN + "'";
                            }
                            else
                            {
                                findDoc = "SELECT * FROM Document WHERE IdPerson = '" + patientId + "' AND DocN ='" + patient.documents[0].document.DocN + "'";
                            }
                            using (SqlConnection connection2 = Global.GetSqlConnection())
                            {
                                SqlCommand findPatients2 = new SqlCommand(findDoc, connection2);
                                using (SqlDataReader patientsReader2 = findPatients2.ExecuteReader())
                                {
                                    string addedId = "";
                                    while (patientsReader2.Read())
                                    {
                                        if (addedId != patientId)
                                        {
                                            TestPatient patientFromDb = TestPatient.BuildPatientFromDataBaseData(patientId: patientId);
                                            addedId             = patientId;
                                            patientFromDb.GUID  = guid;
                                            patientFromDb.IDLPU = idlpu;
                                            patients.Add(patientFromDb);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            TestPatient patientFromDb2 = TestPatient.BuildPatientFromDataBaseData(patientId: patientId);
                            patients.Add(patientFromDb2);
                        }
                    }
                }
            }
            return(patients);
        }