Exemplo n.º 1
0
        //end suriya 18/03/2015

        public int serviceGetPTArrivedCheckupFilter(string SiteCode, string en, DateTime dateNow)
        {
            try
            {
                SiteCode = returnMainSite(SiteCode);//add suriya 15/08/2016
                using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                {
                    if (cdc.tmp_getptarriveds.Any(t => t.paadm_admno == en && t.ctloc_code == SiteCode))//add suriya 24/03/2015
                    {
                        return(-1);
                    }

                    Service.WS_TrakcareCls ws_trak = new Service.WS_TrakcareCls();
                    var result = ws_trak.GetPTArrivedCheckUpFilter(SiteCode, en, dateNow.ToString("yyyy-MM-dd")).AsEnumerable();


                    tmp_getptarrived patient_arrive = result.Select(x => new tmp_getptarrived
                    {
                        paadm_type_of_patient_calc = x.Field <string>("PAADM_Type_of_Patient_Calc"),
                        paadm_rowid      = x.Field <int>("PAADM_RowID").ToString(),
                        appt_rowid       = x.Field <string>("APPT_RowId"),
                        appt_arrivaltime = x.Field <TimeSpan>("APPT_ArrivalTime").ToString(),
                        paadm_admdate    = x.Field <DateTime?>("PAADM_AdmDate"),
                        allergy_eng      = GetAllergyByHN(x.Field <string>("PAPMI_No")),//call webserice
                        paadm_admno      = x.Field <string>("PAADM_ADMNo"),
                        papmi_no         = x.Field <string>("PAPMI_No"),
                        ttl_desc         = x.Field <string>("TTL_Desc"),
                        papmi_name       = x.Field <string>("PAPMI_Name"),
                        papmi_name2      = x.Field <string>("PAPMI_Name2"),
                        appt_transdate   = x.Field <DateTime?>("APPT_TransDate"),
                        appt_datesearch  = x.Field <DateTime?>("APPT_DateSearch"),
                        paadm_admtime    = x.Field <TimeSpan>("PAADM_admTime").ToString(),
                        ctloc_code       = returnMainSite(x.Field <string>("CTLOC_Code")),
                        ctloc_desc       = x.Field <string>("CTLOC_Desc"),
                        penstype_code    = x.Field <string>("PENSTYPE_Code"),
                        penstype_desc    = x.Field <string>("PENSTYPE_Desc"),
                        ser_rowid        = x.Field <int>("SER_RowId"),
                        ser_desc         = x.Field <string>("SER_Desc"),
                        ctnat_code       = x.Field <string>("CTNAT_Code"),
                        ctnat_desc       = x.Field <string>("CTNAT_Desc"),
                        ctsex_code       = x.Field <string>("CTSEX_Code"),
                        ctsex_desc       = x.Field <string>("CTSEX_Desc"),
                        papmi_dob        = x.Field <DateTime?>("PAPMI_DOB"),
                        //paper_photo = getImagePatient(x.Field<string>("PAPER_Photo")),
                        paper_photo = new GetPatientImage().getByWebService(x.Field <string>("PAPMI_No")),
                        //paper_photo_path = x.Field<string>("PAPER_Photo"),
                        paper_ageyr    = x.Field <string>("PAPER_AgeYr"),
                        paper_agemth   = x.Field <string>("PAPER_AgeMth"),
                        paper_ageday   = x.Field <string>("PAPER_AgeDay"),
                        paper_stname   = x.Field <string>("PAPER_StName"),
                        citarea_desc   = x.Field <string>("CITAREA_Desc"),
                        prov_desc      = x.Field <string>("PROV_Desc"),
                        ctcit_desc     = x.Field <string>("CTCIT_Desc"),
                        ctzip_code     = x.Field <string>("CTZIP_Code"),
                        paper_id       = x.Field <string>("PAPER_ID"),
                        paper_telo     = x.Field <string>("PAPER_TelO"),
                        paper_telh     = x.Field <string>("PAPER_TelH"),
                        paper_mobphone = x.Field <string>("PAPER_MobPhone"),
                        paper_email    = x.Field <string>("PAPER_Email"),

                        ctmar_desc  = x.Field <string>("CTMAR_Desc"),
                        paper_name5 = x.Field <string>("PAPER_Name5"),
                        paper_name6 = x.Field <string>("PAPER_Name6"),
                        paper_name7 = x.Field <string>("PAPER_Name7"),

                        papmi_dob_text = x.Field <string>("papmi_dob_text")
                    }).FirstOrDefault();
                    if (patient_arrive != null)
                    {
                        if (!cdc.tmp_getptarriveds.Any(t => t.paadm_admno == en && t.ctloc_code == SiteCode))
                        {
                            cdc.tmp_getptarriveds.InsertOnSubmit(patient_arrive);
                            cdc.SubmitChanges();
                        }
                    }
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw ex; //add  suriya 24/03/2015
            }
        }
Exemplo n.º 2
0
        public int?RegisPatient(string location, string en, DateTime arrived, string user)
        {
            using (Service.WS_TrakcareCls ws = new Service.WS_TrakcareCls())
            {
                var result = ws.GetPTArrivedCheckUpFilter(location, en, arrived.ToString("yyyy-MM-dd")).AsEnumerable().FirstOrDefault();
                if (result != null)
                {
                    using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                    {
                        DateTime dateNow = globalCls.GetServerDateTime();
                        var      patient = cdc.trn_patients.Where(x => x.tpt_hn_no == result.Field <string>("PAPMI_No")).FirstOrDefault();
                        if (patient == null)
                        {
                            patient = new trn_patient
                            {
                                tpt_hn_no       = result.Field <string>("PAPMI_No"),
                                tpt_create_date = dateNow
                            };
                            cdc.trn_patients.InsertOnSubmit(patient);
                        }
                        patient.tpt_pre_name   = result.Field <string>("TTL_Desc") == null ? "" : result.Field <string>("TTL_Desc").Trim();
                        patient.tpt_first_name = result.Field <string>("PAPMI_Name") == null ? "" : result.Field <string>("PAPMI_Name").Trim();
                        patient.tpt_last_name  = result.Field <string>("PAPMI_Name2") == null ? "" : result.Field <string>("PAPMI_Name2").Trim();
                        patient.tpt_en_name1   = result.Field <string>("PAPER_Name5") == null ? "" : result.Field <string>("PAPER_Name5").Trim();
                        patient.tpt_en_name2   = result.Field <string>("PAPER_Name6") == null ? "" : result.Field <string>("PAPER_Name6").Trim();
                        patient.tpt_en_name3   = result.Field <string>("PAPMI_Name7") == null ? "" : result.Field <string>("PAPMI_Name7").Trim();
                        List <string> name = new List <string>();
                        if (patient.tpt_pre_name != "")
                        {
                            name.Add(patient.tpt_pre_name);
                        }
                        if (patient.tpt_first_name != "")
                        {
                            name.Add(patient.tpt_first_name);
                        }
                        if (patient.tpt_en_name3 != "")
                        {
                            name.Add(patient.tpt_en_name3);
                        }
                        if (patient.tpt_last_name != "")
                        {
                            name.Add(patient.tpt_last_name);
                        }
                        patient.tpt_fullname  = string.Join(" ", name);
                        patient.tpt_othername = string.Join(" ", name);
                        patient.tpt_id_card   = result.Field <string>("PAPER_ID") == null ? "" : result.Field <string>("PAPER_ID").Trim();
                        patient.tpt_dob       = result.Field <DateTime?>("PAPMI_DOB");
                        patient.tpt_dob_text  = result.Field <string>("papmi_dob_text") == null ? "" : result.Field <string>("papmi_dob_text").Trim();
                        patient.tpt_gender    = result.Field <string>("CTSEX_Code") == null || result.Field <string>("CTSEX_Code").Trim().Length == 0 ? (char?)null : result.Field <string>("CTSEX_Code").Trim()[0];
                        Marrie mar = new Marrie(result.Field <string>("CTMAR_Desc"));
                        patient.tpt_married      = mar.code;
                        patient.tpt_married_desc = mar.desc;
                        patient.tpt_nation_code  = result.Field <string>("CTNAT_Code") == null ? "" : result.Field <string>("CTNAT_Code").Trim();
                        patient.tpt_nation_desc  = result.Field <string>("CTNAT_Desc") == null ? "" : result.Field <string>("CTNAT_Desc").Trim();
                        patient.tpt_allergy      = new APITrakcare.GetAllergyCls().ByGetAllergyByHN(result.Field <string>("PAPMI_No"));
                        patient.tpt_image        = GetImage(result.Field <string>("PAPMI_No"));
                        patient.tpt_vip_hpc      = location == "01HPC3" ? true : false;
                        patient.tpt_update_date  = dateNow;

                        int mhs_id = cdc.mst_hpc_sites.Where(x => x.mhs_code == location).Select(x => x.mhs_id).FirstOrDefault();
                        var regis  = patient.trn_patient_regis.Where(x => x.tpr_en_no == result.Field <string>("PAADM_ADMNo") && x.mhs_id == mhs_id).FirstOrDefault();
                        if (regis == null)
                        {
                            DateTime?PAADM_AdmDate    = result.Field <DateTime?>("PAADM_AdmDate");
                            TimeSpan?PAADM_AdmTime    = result.Field <TimeSpan?>("PAADM_AdmTime");
                            TimeSpan?APPT_ArrivalTime = result.Field <TimeSpan?>("APPT_ArrivalTime");
                            DateTime?app = null;
                            DateTime?arr = null;
                            if (PAADM_AdmDate != null)
                            {
                                app     = PAADM_AdmDate.Value;
                                arrived = PAADM_AdmDate.Value;
                                if (APPT_ArrivalTime != null)
                                {
                                    app = app.Value.Add(APPT_ArrivalTime.Value);
                                }
                                if (PAADM_AdmTime != null)
                                {
                                    arr = arr.Value.Add(PAADM_AdmTime.Value);
                                }
                            }
                            var pattype   = '1';
                            var apptype   = GetAppointType(GetLimitAppoint(mhs_id), app, arr);
                            var arrtype   = app == null ? 'W' : 'A';
                            var queueType = GetQueueType(result.Field <int>("SER_RowId"), !string.IsNullOrEmpty(result.Field <string>("PENSTYPE_Code")), apptype);
                            regis = new trn_patient_regi
                            {
                                mhs_id = mhs_id,

                                tpr_en_no         = result.Field <string>("PAADM_ADMNo"),
                                tpr_vip_code      = result.Field <string>("PENSTYPE_Code") == null ? null : result.Field <string>("PENSTYPE_Code").Trim(),
                                tpr_vip_desc      = result.Field <string>("PENSTYPE_Desc") == null ? null : result.Field <string>("PENSTYPE_Desc").Trim(),
                                tpr_email         = result.Field <string>("PAPER_Email") == null ? null : result.Field <string>("PAPER_Email").Trim(),
                                tpr_en_rowid      = result.Field <int?>("PAADM_RowID") == null ? null : result.Field <int?>("PAADM_RowID").ToString(),
                                tpr_foreigner     = result.Field <string>("CTNAT_Code") == null ? (char?)null : (result.Field <string>("CTNAT_Code") == "TH" ? 'N' : 'Y'),
                                tpr_home_phone    = result.Field <string>("PAPER_TelH") == null ? null : result.Field <string>("PAPER_TelH").Trim(),
                                tpr_main_address  = result.Field <string>("PAPER_StName") == null ? null : result.Field <string>("PAPER_StName").Trim(),
                                tpr_main_amphur   = result.Field <string>("CTCIT_Desc") == null ? null : result.Field <string>("CTCIT_Desc").Trim(),
                                tpr_main_province = result.Field <string>("PROV_Desc") == null ? null : result.Field <string>("PROV_Desc").Trim(),
                                tpr_main_tumbon   = result.Field <string>("CITAREA_Desc") == null ? null : result.Field <string>("CITAREA_Desc").Trim(),
                                tpr_main_zip_code = result.Field <string>("CTZIP_Code") == null ? null : result.Field <string>("CTZIP_Code").Trim(),
                                tpr_office_phone  = result.Field <string>("PAPER_TelO") == null ? null : result.Field <string>("PAPER_TelO"),
                                tpr_mobile_phone  = result.Field <string>("PAPER_MobPhone") == null ? null : result.Field <string>("PAPER_MobPhone").Trim(),
                                tpr_new_patient   = result.Field <string>("PAADM_Type_of_Patient_Calc") == null ? (char?)null : (new List <string> {
                                    "1", "2"
                                }.Contains(result.Field <string>("PAADM_Type_of_Patient_Calc")) ? 'Y' : 'N'),

                                tpr_appoint_type     = apptype,
                                tpr_appointment_date = app,
                                tpr_arrive_date      = arr,
                                tpr_arrive_type      = arrtype,

                                tpr_patient_type = pattype,

                                tpr_req_doc_code       = null,
                                tpr_req_doc_gender     = null,
                                tpr_req_doc_name       = null,
                                tpr_req_doctor         = null,
                                tpr_req_inorout_doctor = null,
                                tpr_req_pe_bef_chkup   = null,
                                tpr_req_same_doc       = null,
                                tpr_pe_doc             = null, // queue
                                tpr_pe_doc_code        = null, // queue
                                tpr_pe_doc_name        = null, // queue
                                tpr_pe_site2           = 'P',  // site 2
                                tpr_pe_type            = 'W',  // site 1
                                tpr_pending_no_station = null,
                                tpr_check_pending      = 'N',  //pending
                                tpr_type             = 'D',
                                tpr_return_screening = null,

                                tpr_miss_lower      = null,      //ultrasound
                                tpr_miss_lower_date = null,      //ultrasound
                                tpr_call_lower_date = null,      //ultrasound
                                tpr_call_lower_time = null,      //ultrasound

                                tpr_pd_pe_site2          = null, // queue
                                tpr_pending              = null,
                                tpr_pending_cancel_onday = null,
                                tpr_pending_ct           = 0,
                                tpr_site_use             = null, // stamp on checkpoint B

                                tpr_status    = "WB",            // status = Wait Book, for CK Report
                                tpr_pe_status = "RS",            // status = Result, for CK Report

                                tpr_mhc_ename = null,            //package

                                tpr_other_address  = null,       // trn_patient_regis last espisode
                                tpr_other_amphur   = null,       // trn_patient_regis last espisode
                                tpr_other_province = null,       // trn_patient_regis last espisode
                                tpr_other_tumbon   = null,       // trn_patient_regis last espisode
                                tpr_other_zip_code = null,       // trn_patient_regis last espisode
                                tpr_other_name     = null,

                                tpr_PRM         = null, // package PMR
                                tpr_PRM_check   = null, // package PMR
                                tpr_PRM_doccode = null, // package PMR
                                tpr_PRM_docname = null, // package PMR
                                tpr_PRM_doctor  = null, // package PMR

                                tpr_queue_no   = GetQueueNo(result.Field <string>("PAADM_ADMNo"), queueType, CheckOtherSite(mhs_id)),
                                tpr_queue_type = CheckVIP(patient.tpt_hn_no) ? '1' : queueType,

                                tpr_remark    = null,
                                tpr_send_book = null,
                                tpr_send_to   = null,      // trn_patient_regis last espisode

                                tnc_document_no    = null, // company
                                tnc_emp_id         = null, // company
                                tnc_id             = null, // company
                                tnc_position       = null, // company
                                tpr_employee_no    = null,
                                tcd_id             = null,
                                tpr_comp_dep       = null,
                                tpr_comp_dep_edesc = null,
                                tpr_comp_dep_tdesc = null,
                                tpr_comp_edesc     = null,
                                tpr_comp_tdesc     = null,
                                tpr_company_code   = null,
                                tpr_company_id     = null,
                                tnc_department     = null,

                                tpr_create_by   = user,
                                tpr_create_date = dateNow,
                                tpr_update_by   = user,
                                tpr_update_date = dateNow,

                                tpr_sys_assign_doctor = null, // not use
                                mut_id               = null,  // not use
                                mac_id               = null,  // not use
                                mdc_id               = null,  // not use
                                mhc_id               = null,  // not use
                                tpr_arrive_site      = "",    // not use
                                tpr_arrive_site_desc = "",    // not use
                                tpr_close_other_site = null,  // not use
                                tpr_npo_text         = null,  // tmp_patient_regis
                                tpr_npo_time         = null,  // tmp_patient_regis
                                tpr_aviation_type    = null,  //select on register
                                tpr_nurse_code       = null,
                                tpr_nurse_name       = null,
                                tpr_prev_pe_code     = null,
                                tpr_prev_pe_name     = null,
                                tpr_rtn_pe_date      = null,
                                tpr_print_book       = "N",
                                tpr_rtn_pe_name      = null
                            };
                            patient.trn_patient_regis.Add(regis);
                        }
                        cdc.SubmitChanges();
                        return(regis.tpr_id);
                    }
                }
            }
            return(null);
        }