Esempio n. 1
0
 static public TestDiagnosisInfo BuildTestMainDiagnosisInfoFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         //опять DiagnosedDateSpecified, что с этим делать?
         //ещё есть какой-то idDiagnosisStatus и idLpu, так же idDiagnosisContainer - это не diagnosisType?
         string        finddiagnosis = "SELECT * FROM public.diagnosis WHERE id_referral = '" + idReferral + "' AND id_diagnosis_container = '" + complication + "')";
         NpgsqlCommand person        = new NpgsqlCommand(finddiagnosis, connection);
         using (NpgsqlDataReader diagnosisReader = person.ExecuteReader())
         {
             while (diagnosisReader.Read())
             {
                 DiagnosisInfo diag = new DiagnosisInfo();
                 if (diagnosisReader["comment"] != DBNull.Value)
                 {
                     diag.Comment = Convert.ToString(diagnosisReader["comment"]);
                 }
                 if (diagnosisReader["diagnosis_date"] != DBNull.Value)
                 {
                     diag.DiagnosedDate = Convert.ToDateTime(diagnosisReader["diagnosis_date"]);
                 }
                 TestDiagnosisInfo tDiag = new TestDiagnosisInfo(diag);
                 if (diagnosisReader["id_mkb_code"] != DBNull.Value)
                 {
                     tDiag.mkbCode = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(diagnosisReader["id_mkb_code"]));
                 }
                 return(tDiag);
             }
         }
     }
     return(null);
 }
Esempio n. 2
0
        static public List <TestContact> BuildContactsFromDataBaseData(string idPerson)
        {
            List <TestContact> contacts = new List <TestContact>();

            using (NpgsqlConnection connection = Global.GetSqlConnection())
            {
                string        findPatient = "SELECT * FROM public.Contact WHERE id_person = '" + idPerson + "'";
                NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
                using (NpgsqlDataReader contactReader = person.ExecuteReader())
                {
                    while (contactReader.Read())
                    {
                        ContactDto cont = new ContactDto();
                        if (contactReader["contact_value"] != DBNull.Value)
                        {
                            cont.ContactValue = Convert.ToString(contactReader["contact_value"]);
                        }
                        TestContact contact = new TestContact(cont);
                        if (contactReader["id_contact_type"] != DBNull.Value)
                        {
                            contact.contactType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(contactReader["id_contact_type"]));
                        }
                        contacts.Add(contact);
                    }
                }
            }
            return((contacts.Count != 0) ? contacts : null);
        }
Esempio n. 3
0
 static public TestReferralSource BuildSourceFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT id_source_lpu_case_mis, id_referral_source_mo_mis, id_source_lpu FROM public.referral WHERE id_referral = '" + idReferral + "' ORDER BY id_referral DESC LIMIT 1";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             ReferralSource p = new ReferralSource();
             while (personFromDataBase.Read())
             {
                 //referral_creation_date должен быть тут в Date!
                 if (personFromDataBase["id_source_lpu_case_mis"] != DBNull.Value)
                 {
                     p.IdCaseMis = Convert.ToString(personFromDataBase["id_source_lpu_case_mis"]);
                 }
                 if (personFromDataBase["id_referral_source_mo_mis"] != DBNull.Value)
                 {
                     p.IdReferralMis = Convert.ToString(personFromDataBase["id_referral_source_mo_mis"]);
                 }
                 TestReferralSource pers = new TestReferralSource(p);
                 if (personFromDataBase["id_source_lpu"] != DBNull.Value)
                 {
                     pers.lpu = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_source_lpu"]));
                 }
                 return(pers);
             }
         }
     }
     return(new TestReferralSource(null));
 }
Esempio n. 4
0
        static public List <TestPrivilege> BuildPrivilegeFromDataBaseData(string idPerson)
        {
            List <TestPrivilege> priveleges = new List <TestPrivilege>();

            using (NpgsqlConnection connection = Global.GetSqlConnection())
            {
                string        findPriviledge = "SELECT * FROM public.priviledge WHERE id_person = '" + idPerson + "'";
                NpgsqlCommand person         = new NpgsqlCommand(findPriviledge, connection);
                using (NpgsqlDataReader contactReader = person.ExecuteReader())
                {
                    while (contactReader.Read())
                    {
                        //что делать с DateSpecified?
                        Privilege priv = new Privilege();
                        if (contactReader["date_start"] != DBNull.Value)
                        {
                            priv.StartDate = Convert.ToDateTime(contactReader["date_start"]);
                        }
                        if (contactReader["date_end"] != DBNull.Value)
                        {
                            priv.EndDate = Convert.ToDateTime(contactReader["date_end"]);
                        }
                        TestPrivilege privilege = new TestPrivilege(priv);
                        if (contactReader["id_priviledge_code"] != DBNull.Value)
                        {
                            privilege.privilegeType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(contactReader["id_priviledge_code"]));
                        }
                        priveleges.Add(privilege);
                    }
                }
            }
            return((priveleges.Count != 0) ? priveleges : null);
        }
Esempio n. 5
0
 static public TestReferralSurvey BuildAdditionalFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT id_survey_organ, survey_comment, id_referral, id_survey_type FROM public.referral WHERE id_referral = '" + idReferral + "' ORDER BY id_referral DESC LIMIT 1";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             Survey p = new Survey();
             while (personFromDataBase.Read())
             {
                 //что делать с DateSpecified и Мисами?
                 if (personFromDataBase["survey_comment"] != DBNull.Value)
                 {
                     p.Comment = Convert.ToString(personFromDataBase["survey_comment"]);
                 }
                 TestReferralSurvey pers = new TestReferralSurvey(p);
                 if (personFromDataBase["id_referral"] != DBNull.Value)
                 {
                     pers.additional = TestAdditional.BuildAdditionalFromDataBaseData(Convert.ToString(personFromDataBase["id_referral"]));
                 }
                 if (personFromDataBase["id_survey_organ"] != DBNull.Value)
                 {
                     pers.surveyOrgan = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_survey_organ"]));
                 }
                 if (personFromDataBase["id_survey_type"] != DBNull.Value)
                 {
                     pers.surveyType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_survey_type"]));
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }
Esempio n. 6
0
 //как искать?
 static public TestCancellation BuildCancellationFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT cancellation_date, cancellation_reason_comment, id_cancellation_code, id_cancellation_reason FROM public.referral WHERE id_referral = '" + idReferral + "' ORDER BY id_referral DESC LIMIT 1";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             CancellationData p = new CancellationData();
             while (personFromDataBase.Read())
             {
                 if (personFromDataBase["cancellation_date"] != DBNull.Value)
                 {
                     p.Date = Convert.ToDateTime(personFromDataBase["cancellation_date"]);
                 }
                 if (personFromDataBase["cancellation_reason_comment"] != DBNull.Value)
                 {
                     p.ReasonComment = Convert.ToString(personFromDataBase["cancellation_reason_comment"]);
                 }
                 TestCancellation pers = new TestCancellation(p);
                 if (personFromDataBase["id_cancellation_code"] != DBNull.Value)
                 {
                     pers.source = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_cancellation_code"]));
                 }
                 if (personFromDataBase["id_cancellation_reason"] != DBNull.Value)
                 {
                     pers.source = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_cancellation_reason"]));
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }
Esempio n. 7
0
        static public List <TestAddress> BuildAdressesFromDataBaseData(string idPerson)
        {
            List <TestAddress> addresses = new List <TestAddress>();

            using (NpgsqlConnection connection = Global.GetSqlConnection())
            {
                string        findIdAdresses = "SELECT * FROM public.address WHERE id_person = '" + idPerson + "'";
                NpgsqlCommand IdAddresses    = new NpgsqlCommand(findIdAdresses, connection);
                using (NpgsqlDataReader addressesReader = IdAddresses.ExecuteReader())
                {
                    while (addressesReader.Read())
                    {
                        AddressDto address = new AddressDto();
                        if (addressesReader["address"] != DBNull.Value)
                        {
                            address.StringAddress = Convert.ToString(addressesReader["address"]);
                        }
                        TestAddress a = new TestAddress(address);
                        if (addressesReader["id_address_type"] != DBNull.Value)
                        {
                            a.addressType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(addressesReader["id_address_type"]));
                        }
                        addresses.Add(a);
                    }
                }
            }
            return((addresses.Count != 0) ? addresses : null);
        }
Esempio n. 8
0
        static public List <TestDoctor> BuildDoctorFromDataBaseData(string idReferral)
        {
            List <TestDoctor> docs = new List <TestDoctor>();

            using (NpgsqlConnection c = Global.GetSqlConnection())
            {
                string        findDoctorsIds = "SELECT * FROM public.referral_doctor WHERE id_referral = '" + idReferral + "'";
                NpgsqlCommand fd             = new NpgsqlCommand(findDoctorsIds, c);
                using (NpgsqlDataReader idr = fd.ExecuteReader())
                {
                    if (idr["id_doctor"] != DBNull.Value)
                    {
                        string idDoctor = idr["id_doctor"].ToString();
                        using (NpgsqlConnection connection = Global.GetSqlConnection())
                        {
                            string        findDoctor = "SELECT * FROM public.doctor WHERE id_doctor = '" + idDoctor + "' ORDER BY id_doctor DESC LIMIT 1";
                            NpgsqlCommand doc        = new NpgsqlCommand(findDoctor, connection);
                            using (NpgsqlDataReader doctorFromDataBase = doc.ExecuteReader())
                            {
                                Doctor p = new Doctor();
                                while (doctorFromDataBase.Read())
                                {
                                    TestDoctor doctor = new TestDoctor(p);
                                    if (doctorFromDataBase["id_doctor_role"] != DBNull.Value)
                                    {
                                        doctor.role = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(doctorFromDataBase["id_doctor_role"]));
                                    }
                                    if (doctorFromDataBase["id_doctor_speciality"] != DBNull.Value)
                                    {
                                        doctor.speciality = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(doctorFromDataBase["id_doctor_speciality"]));
                                    }
                                    if (doctorFromDataBase["id_lpu"] != DBNull.Value)
                                    {
                                        doctor.lpu = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(doctorFromDataBase["id_lpu"]));
                                    }
                                    if (doctorFromDataBase["id_position"] != DBNull.Value)
                                    {
                                        doctor.position = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(doctorFromDataBase["id_position"]));
                                    }
                                    if (doctorFromDataBase["id_person"] != DBNull.Value)
                                    {
                                        doctor.person = TestPerson.BuildPersonFromDataBaseData(Convert.ToString(doctorFromDataBase["id_person"]), Convert.ToString(doctorFromDataBase["id_doctor_mis"]));
                                    }
                                    if (doctorFromDataBase["id_person"] != DBNull.Value)
                                    {
                                        doctor.cnts = TestContact.BuildContactsFromDataBaseData(Convert.ToString(doctorFromDataBase["id_person"]));
                                    }
                                    docs.Add(doctor);
                                }
                            }
                        }
                    }
                }
            }
            return((docs.Count != 0) ? docs : null);
        }
Esempio n. 9
0
        static public List <TestDocument> BuildDocumentsFromDataBaseData(string idPerson)
        {
            List <TestDocument> documents = new List <TestDocument>();

            using (NpgsqlConnection connection = Global.GetSqlConnection())
            {
                string        findDocument = "SELECT * FROM public.documents WHERE id_person = '" + idPerson + "'";
                NpgsqlCommand person       = new NpgsqlCommand(findDocument, connection);
                using (NpgsqlDataReader documentReader = person.ExecuteReader())
                {
                    while (documentReader.Read())
                    {
                        //Что делать с DateSpecified?
                        DocumentDto doc = new DocumentDto();
                        if (documentReader["docn"] != DBNull.Value)
                        {
                            doc.DocN = Convert.ToString(documentReader["docn"]);
                        }
                        if (documentReader["docs"] != DBNull.Value)
                        {
                            doc.DocS = Convert.ToString(documentReader["docs"]);
                        }
                        if (documentReader["expired_date"] != DBNull.Value)
                        {
                            doc.ExpiredDate = Convert.ToDateTime(documentReader["expired_date"]);
                        }
                        if (documentReader["issued_date"] != DBNull.Value)
                        {
                            doc.IssuedDate = Convert.ToDateTime(documentReader["issued_date"]);
                        }
                        if (documentReader["provider_name"] != DBNull.Value)
                        {
                            doc.ProviderName = Convert.ToString(documentReader["provider_name"]);
                        }
                        TestDocument document = new TestDocument(doc);
                        if (documentReader["id_document_type"] != DBNull.Value)
                        {
                            document.documentType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(documentReader["id_document_type"]));
                        }
                        if (documentReader["id_provider"] != DBNull.Value)
                        {
                            document.provider = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(documentReader["id_provider"]));
                        }
                        if (documentReader["id_region_code"] != DBNull.Value)
                        {
                            document.regionCode = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(documentReader["id_region_code"]));
                        }
                        documents.Add(document);
                    }
                }
            }
            return((documents.Count != 0) ? documents : null);
        }
Esempio n. 10
0
 static public TestReferralTarget BuildTargetFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT id_target_lpu, is_referral_review_target_mo, referral_review_date_target_mo, reception_appoint_date, reception_appoint_time_comment, reception_appoint_additional_comment, id_target_lpu_case_mis FROM public.referral WHERE id_referral = '" + idReferral + "' ORDER BY record_created DESC LIMIT 1";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             ReferralTarget p = new ReferralTarget();
             while (personFromDataBase.Read())
             {
                 //зачем тут диагнозы и доктора и ReferralReviewDate и IsReferralReviewed?
                 if (personFromDataBase["id_target_lpu_case_mis"] != DBNull.Value)
                 {
                     p.IdCaseMis = Convert.ToString(personFromDataBase["id_target_lpu_case_mis"]);
                 }
                 if (personFromDataBase["is_referral_review_target_mo"] != DBNull.Value)
                 {
                     p.IsReferralReviewed = Convert.ToBoolean(personFromDataBase["is_referral_review_target_mo"]);
                 }
                 if (personFromDataBase["reception_appoint_additional_comment"] != DBNull.Value)
                 {
                     p.ReceptionAppointComment = Convert.ToString(personFromDataBase["reception_appoint_additional_comment"]);
                 }
                 if (personFromDataBase["reception_appoint_time_comment"] != DBNull.Value)
                 {
                     p.ReceptionAppointTime = Convert.ToString(personFromDataBase["reception_appoint_time_comment"]);
                 }
                 if (personFromDataBase["reception_appoint_date"] != DBNull.Value)
                 {
                     p.ReceptionAppointDate = Convert.ToDateTime(personFromDataBase["reception_appoint_date"]);
                 }
                 if (personFromDataBase["referral_review_date_target_mo"] != DBNull.Value)
                 {
                     p.ReferralReviewDate = Convert.ToDateTime(personFromDataBase["referral_review_date_target_mo"]);
                 }
                 TestReferralTarget pers = new TestReferralTarget(p);
                 pers.lpu  = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_target_lpu"]));
                 pers.docs = TestDoctor.BuildDoctorFromDataBaseData(idReferral,
                                                                    Convert.ToString(personFromDataBase["id_target_lpu"]));
                 pers.diag = TestMainDiagnosis.BuildTestMainDiagnosisInfoFromDataBaseData(idReferral,
                                                                                          Convert.ToString(personFromDataBase["id_target_lpu"]));
                 return(pers);
             }
         }
     }
     return(null);
 }
Esempio n. 11
0
 static public TestReferralTarget BuildTargetFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT id_target_lpu_case_mis, is_referral_review_target_mo, reception_appoint_additional_comment, reception_appoint_time_comment, referral_review_date_target_mo, id_target_lpu, reception_appoint_date FROM public.referral WHERE id_referral = '" + idReferral + "' ORDER BY id_referral DESC LIMIT 1";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             ReferralTarget p = new ReferralTarget();
             while (personFromDataBase.Read())
             {
                 //что делать с DateSpecified и Мисами?
                 if (personFromDataBase["id_target_lpu_case_mis"] != DBNull.Value)
                 {
                     p.IdCaseMis = Convert.ToString(personFromDataBase["id_source_lpu_case_mis"]);
                 }
                 if (personFromDataBase["is_referral_review_target_mo"] != DBNull.Value)
                 {
                     p.IsReferralReviewed = Convert.ToBoolean(personFromDataBase["is_referral_review_target_mo"]);
                 }
                 if (personFromDataBase["reception_appoint_additional_comment"] != DBNull.Value)
                 {
                     p.ReceptionAppointComment = Convert.ToString(personFromDataBase["reception_appoint_additional_comment"]);
                 }
                 if (personFromDataBase["reception_appoint_time_comment"] != DBNull.Value)
                 {
                     p.ReceptionAppointTime = Convert.ToString(personFromDataBase["reception_appoint_time_comment"]);
                 }
                 if (personFromDataBase["reception_appoint_date"] != DBNull.Value)
                 {
                     p.ReceptionAppointDate = Convert.ToDateTime(personFromDataBase["reception_appoint_date"]);
                 }
                 if (personFromDataBase["referral_review_date_target_mo"] != DBNull.Value)
                 {
                     p.ReferralReviewDate = Convert.ToDateTime(personFromDataBase["referral_review_date_target_mo"]);
                 }
                 TestReferralTarget pers = new TestReferralTarget(p);
                 if (personFromDataBase["id_target_lpu"] != DBNull.Value)
                 {
                     pers.lpu = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_target_lpu"]));
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }
Esempio n. 12
0
 static public TestPerson BuildPersonFromDataBaseData(string idPerson, string MIS)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT * FROM public.person WHERE id_person = '" + idPerson + "'";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             Person p = new Person();
             while (personFromDataBase.Read())
             {
                 //что делать с DateSpecified и Мисами?
                 if (personFromDataBase["birthday"] != DBNull.Value)
                 {
                     p.BirthDate = Convert.ToDateTime(personFromDataBase["birthday"]);
                 }
                 if (MIS == "")
                 {
                     p.IdPatientMis = null;
                 }
                 if ((personFromDataBase["family_name"] != DBNull.Value) || (personFromDataBase["given_name"] != DBNull.Value) || (personFromDataBase["middle_name"] != DBNull.Value))
                 {
                     p.HumanName = new HumanName();
                     if (personFromDataBase["family_name"] != DBNull.Value)
                     {
                         p.HumanName.FamilyName = Convert.ToString(personFromDataBase["family_name"]);
                     }
                     if (personFromDataBase["given_name"] != DBNull.Value)
                     {
                         p.HumanName.GivenName = Convert.ToString(personFromDataBase["given_name"]);
                     }
                     if (personFromDataBase["middle_name"] != DBNull.Value)
                     {
                         p.HumanName.MiddleName = Convert.ToString(personFromDataBase["middle_name"]);
                     }
                 }
                 TestPerson pers = new TestPerson(p);
                 if (personFromDataBase["id_sex"] != DBNull.Value)
                 {
                     pers.sex = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_sex"]));
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }
Esempio n. 13
0
 static public TestProfileMedService BuildProfileMedServiceFromDataBaseData(string idLPU)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findProfileMedService = "SELECT * FROM public.lpu_profile WHERE id_lpu = '" + idLPU + "'";
         NpgsqlCommand person = new NpgsqlCommand(findProfileMedService, connection);
         using (NpgsqlDataReader ProfileMedServiceReader = person.ExecuteReader())
         {
             while (ProfileMedServiceReader.Read())
             {
                 ProfileMedService profileMedService = new ProfileMedService();
                 if (ProfileMedServiceReader["address"] != DBNull.Value)
                 {
                     profileMedService.Address = Convert.ToString(ProfileMedServiceReader["address"]);
                 }
                 if (ProfileMedServiceReader["comment"] != DBNull.Value)
                 {
                     profileMedService.Comment = Convert.ToString(ProfileMedServiceReader["comment"]);
                 }
                 if (ProfileMedServiceReader["contact_value"] != DBNull.Value)
                 {
                     profileMedService.ContactValue = Convert.ToString(ProfileMedServiceReader["contact_value"]);
                 }
                 if (ProfileMedServiceReader["date_end"] != DBNull.Value)
                 {
                     profileMedService.EndDate = Convert.ToDateTime(ProfileMedServiceReader["date_end"]);
                 }
                 if (ProfileMedServiceReader["site"] != DBNull.Value)
                 {
                     profileMedService.Site = Convert.ToString(ProfileMedServiceReader["site"]);
                 }
                 if (ProfileMedServiceReader["date_begin"] != DBNull.Value)
                 {
                     profileMedService.StartDate = Convert.ToDateTime(ProfileMedServiceReader["date_begin"]);
                 }
                 TestProfileMedService tProfileMedService = new TestProfileMedService(profileMedService);
                 if (ProfileMedServiceReader["id_profile_med_service"] != DBNull.Value)
                 {
                     tProfileMedService.idProfileMedService = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(ProfileMedServiceReader["id_profile_med_service"]));
                 }
                 return(tProfileMedService);
             }
         }
     }
     return(null);
 }
Esempio n. 14
0
 static public TestEventTarget BuildTargetFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string        findPatient = "SELECT id_case_aid_form, id_case_aid_place, id_case_aid_type, case_close_date, case_open_date, reception_appoint_date FROM public.referral WHERE id_referral = '" + idReferral + "' ORDER BY id_referral DESC LIMIT 1";
         NpgsqlCommand person      = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             EventTarget p = new EventTarget();
             while (personFromDataBase.Read())
             {
                 //что делать с IsReferralReviwedSpecified, Lpu, ReceptionAppointComment, ReceptionAppointTime, ReferralReviewDate и RefferalCreatedDate?
                 if (personFromDataBase["case_close_date"] != DBNull.Value)
                 {
                     p.CaseCloseDate = Convert.ToDateTime(personFromDataBase["case_close_date"]);
                 }
                 if (personFromDataBase["case_open_date"] != DBNull.Value)
                 {
                     p.CaseOpenDate = Convert.ToDateTime(personFromDataBase["case_open_date"]);
                 }
                 if (personFromDataBase["reception_appoint_date"] != DBNull.Value)
                 {
                     p.ReceptionAppointDate = Convert.ToDateTime(personFromDataBase["reception_appoint_date"]);
                 }
                 TestEventTarget pers = new TestEventTarget(p);
                 if (personFromDataBase["id_case_aid_form"] != DBNull.Value)
                 {
                     pers.caseAidForm = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_case_aid_form"]));
                 }
                 if (personFromDataBase["id_case_aid_place"] != DBNull.Value)
                 {
                     pers.caseAidPlace = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_case_aid_place"]));
                 }
                 if (personFromDataBase["id_case_aid_type"] != DBNull.Value)
                 {
                     pers.caseAidType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_case_aid_type"]));
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }
Esempio n. 15
0
 static public TestDiagnosisInfo BuildTestMainDiagnosisInfoFromDataBaseData(string idReferral, string idLpu)
 {
     if (idLpu != "")
     {
         using (NpgsqlConnection connection = Global.GetSqlConnection())
         {
             string finddiagnosis = "SELECT * FROM public.diagnosis WHERE id_referral = '" + idReferral +
                                    "' AND id_diagnosis_container = '" + complication + "' AND id_lpu = '" +
                                    idLpu + "'";
             NpgsqlCommand person = new NpgsqlCommand(finddiagnosis, connection);
             using (NpgsqlDataReader diagnosisReader = person.ExecuteReader())
             {
                 while (diagnosisReader.Read())
                 {
                     DiagnosisInfo diag = new DiagnosisInfo();
                     if (diagnosisReader["comment"] != DBNull.Value)
                     {
                         diag.Comment = Convert.ToString(diagnosisReader["comment"]);
                     }
                     if (diagnosisReader["diagnosis_date"] != DBNull.Value)
                     {
                         diag.DiagnosedDate = Convert.ToDateTime(diagnosisReader["diagnosis_date"]);
                     }
                     TestDiagnosisInfo tDiag = new TestDiagnosisInfo(diag);
                     if (diagnosisReader["id_diagnosis_status"] != DBNull.Value)
                     {
                         tDiag.diagnosisType =
                             TestCoding.BuildCodingFromDataBaseData(
                                 diagnosisReader["id_diagnosis_status"].ToString());
                     }
                     if (diagnosisReader["id_mkb_code"] != DBNull.Value)
                     {
                         tDiag.mkbCode =
                             TestCoding.BuildCodingFromDataBaseData(
                                 Convert.ToString(diagnosisReader["id_mkb_code"]));
                     }
                     return(tDiag);
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 16
0
 static public TestReferralInfo BuildPersonFromDataBaseData(string idReferral)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string findPatient =
             "SELECT comment, priority_comment, referral_paper_date, id_referral_type, id_profile_med_service, referral_reason FROM public.referral WHERE id_referral = '" +
             idReferral +
             "' ORDER BY public.referral.id_referral DESC LIMIT 1";
         NpgsqlCommand person = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             ReferralInfo p = new ReferralInfo();
             while (personFromDataBase.Read())
             {
                 p.IdMq = idReferral;
                 //что делать с mqReferralStatus?
                 if (personFromDataBase["comment"] != DBNull.Value)
                 {
                     p.Comment = Convert.ToString(personFromDataBase["comment"]);
                 }
                 if (personFromDataBase["referral_paper_date"] != DBNull.Value)
                 {
                     p.Date = Convert.ToDateTime(personFromDataBase["referral_paper_date"]);
                 }
                 if (personFromDataBase["priority_comment"] != DBNull.Value)
                 {
                     p.Priority = Convert.ToString(personFromDataBase["priority_comment"]);
                 }
                 if (personFromDataBase["referral_reason"] != DBNull.Value)
                 {
                     p.Reason = Convert.ToString(personFromDataBase["referral_reason"]);
                 }
                 TestReferralInfo pers = new TestReferralInfo(p);
                 pers.cancellation = TestCancellation.BuildCancellationFromDataBaseData(idReferral);
                 if (personFromDataBase["id_referral_type"] != DBNull.Value)
                 {
                     pers.referralType =
                         TestCoding.BuildCodingFromDataBaseData(
                             Convert.ToString(personFromDataBase["id_referral_type"]));
                 }
                 if (personFromDataBase["id_profile_med_service"] != DBNull.Value)
                 {
                     pers.profileMedService =
                         TestCoding.BuildCodingFromDataBaseData(
                             Convert.ToString(personFromDataBase["id_profile_med_service"]));
                 }
                 using (NpgsqlConnection connection2 = Global.GetSqlConnection())
                 {
                     string findIdMq =
                         "SELECT id_mq_referral_status FROM public.referral, public.referral_status WHERE public.referral.id_referral = '" + idReferral + "' AND public.referral.id_referral = public.referral_status.id_referral ORDER BY public.referral_status.id_referral_status DESC LIMIT 1";
                     NpgsqlCommand com = new NpgsqlCommand(findIdMq, connection2);
                     using (NpgsqlDataReader reader = com.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             if (reader["id_mq_referral_status"] != DBNull.Value)
                             {
                                 pers.mqReferralStatus =
                                     TestCoding.BuildCodingFromDataBaseData(
                                         Convert.ToString(reader["id_mq_referral_status"]));
                             }
                         }
                     }
                 }
                 return(pers);
             }
         }
     }
     return(null);
 }