コード例 #1
0
        public char?getTprQueueType(tmp_getptarrived tga)
        {
            using (InhCheckupDataContext cdc = new InhCheckupDataContext())
            {
                int site = cdc.mst_hpc_sites.Where(x => x.mhs_code == tga.ctloc_code).Select(x => x.mhs_id).FirstOrDefault();

                tmp_getptappointment tap = cdc.tmp_getptappointments.Where(x => x.papmi_no == tga.papmi_no).FirstOrDefault();
                TimeSpan             tarrivaltime;
                TimeSpan.TryParse(tga.appt_arrivaltime.Replace("PT", "").Replace("H", ":").Replace("M", ":").Replace("S", ""), out tarrivaltime);
                TimeSpan tAppointment;
                TimeSpan.TryParse(tga.paadm_admtime.Replace("PT", "").Replace("H", ":").Replace("M", ""), out tAppointment);
                var litTime = (from t1 in cdc.mst_config_hdrs
                               where t1.mhs_id == site && t1.mfh_code == "WTM"
                               select t1.mst_config_dtls.FirstOrDefault()).FirstOrDefault();
                double litValueTime = 1440;
                if (litTime != null)
                {
                    litValueTime = (double)litTime.mfd_value;
                }

                TimeSpan      ta          = tarrivaltime.Subtract(tAppointment);
                List <string> patientVVIP = cdc.mst_check_vvips.Select(x => x.mvp_hn_no).ToList();
                if (patientVVIP.Contains(tga.papmi_no))
                {
                    return('1'); //VVIP
                }
                else if (!string.IsNullOrEmpty(tga.penstype_code))
                {
                    if (tap == null)
                    {
                        return('3'); //VIP WalkIn
                    }


                    if (ta.TotalMinutes <= litValueTime && tga.ser_rowid != 2808)
                    {
                        return('2'); //VIP Appointment
                    }
                    else
                    {
                        return('3'); //VIP WalkIn
                    }
                }
                else
                {
                    if (tap == null)
                    {
                        return('5'); //WalkIn
                    }
                    if (ta.TotalMinutes <= litValueTime && tga.ser_rowid != 2808)
                    {
                        return('4'); //Appointment
                    }
                    else
                    {
                        return('5'); //WalkIn
                    }
                }
            }
        }
コード例 #2
0
 private tmp_getptarrived get_tgaByRowID(int row_id)
 {
     using (InhCheckupDataContext cdc = new InhCheckupDataContext())
     {
         tmp_getptarrived result = cdc.tmp_getptarriveds.Where(x => x.row_id == row_id).FirstOrDefault();
         return(result);
     }
 }
コード例 #3
0
        public bool RegisterPatient(tmp_getptarrived arrivedData)
        {
            try
            {
                using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                {
                    DateTime dateNow = Program.GetServerDateTime();

                    EmrClass.GetDataFromWSTrakCare cls = new EmrClass.GetDataFromWSTrakCare();
                    trn_patient tpt            = cdc.trn_patients.Where(x => x.tpt_hn_no == arrivedData.papmi_no).FirstOrDefault();
                    bool        flagNewPatient = true;
                    if (tpt != null)
                    {
                        flagNewPatient = false;
                    }
                    cls.otherClinicSkipToCheckB(arrivedData, ref tpt, Program.CurrentSite.mhs_id);//add Program.CurrentSite.mhs_id suriya 03/04/2015
                    List <trn_patient_regi> listRegis = tpt.trn_patient_regis.Where(x => x.tpr_en_no == arrivedData.paadm_admno).ToList();
                    foreach (trn_patient_regi regis in listRegis)
                    {
                        trn_doctor_hdr docHdr = regis.trn_doctor_hdrs.FirstOrDefault();
                        if (docHdr == null)
                        {
                            docHdr = new trn_doctor_hdr();
                            regis.trn_doctor_hdrs.Add(docHdr);
                            docHdr.trh_create_date = dateNow;
                            docHdr.trh_create_by   = "SysImp";
                            docHdr.trh_update_date = dateNow;
                            docHdr.trh_update_by   = "SysImp";
                        }
                    }
                    if (flagNewPatient)
                    {
                        cdc.trn_patients.InsertOnSubmit(tpt);
                    }
                    cdc.SubmitChanges();
                    trn_patient_regi PatientRegis = tpt.trn_patient_regis.OrderByDescending(x => x.tpr_id).FirstOrDefault();
                    if (PatientRegis != null)
                    {
                        new EmrClass.GetPTPackageCls().setRelationOrderSet(ref PatientRegis);
                        cdc.SubmitChanges();
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Program.MessageError("EmrClass.FunctionDataCls", "RegisterPatient", ex, false);
                return(false);
            }
        }
コード例 #4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string hn = null;

            if (txtSearch.Text != null)
            {
                hn = txtSearch.Text.Trim();
            }
            currentGetArrived = getArrivedByHn(hn);
            //if (currentGetArrived != null)
            //{
            //    hn_no = currentGetArrived.papmi_no;
            //}
            //else
            //{
            //    hn_no = null;
            //}
        }
コード例 #5
0
        public void otherClinicSkipToCheckB(tmp_getptarrived tga, ref trn_patient objpatient, int SiteCode = -999)//add SiteCode suriya 03/04/2015
        {
            if (tga != null)
            {
                DateTime dateNow = DateTime.Now; //Program.GetServerDateTime();
                if (objpatient == null)
                {
                    objpatient = new trn_patient();
                    objpatient.tpt_create_date = dateNow;
                }
                objpatient.tpt_update_date = dateNow;
                objpatient.tpt_hn_no       = tga.papmi_no;
                objpatient.tpt_gender      = Convert.ToChar(tga.ctsex_code);

                objpatient.tpt_pre_name   = tga.ttl_desc;
                objpatient.tpt_first_name = tga.papmi_name;
                objpatient.tpt_last_name  = tga.papmi_name2;
                objpatient.tpt_image      = tga.paper_photo;

                objpatient.tpt_dob         = tga.papmi_dob;
                objpatient.tpt_nation_code = tga.ctnat_code;
                objpatient.tpt_nation_desc = tga.ctnat_desc;
                objpatient.tpt_update_date = dateNow;
                objpatient.tpt_id_card     = tga.paper_id;

                objpatient.tpt_allergy  = tga.allergy_eng;
                objpatient.tpt_en_name1 = tga.paper_name5;
                objpatient.tpt_en_name2 = tga.paper_name6;
                objpatient.tpt_en_name3 = tga.paper_name7;

                objpatient.tpt_dob_text = tga.papmi_dob_text;
                try
                {
                    string tname    = string.IsNullOrEmpty(tga.ttl_desc) ? "" : tga.ttl_desc.Trim();
                    string fname    = string.IsNullOrEmpty(tga.papmi_name) ? "" : " " + tga.papmi_name.Trim();
                    string mname    = string.IsNullOrEmpty(tga.paper_name7) ? "" : " " + tga.paper_name7.Trim();
                    string lname    = string.IsNullOrEmpty(tga.papmi_name2) ? "" : " " + tga.papmi_name2.Trim();
                    string fullname = (tname + fname + mname + lname).Trim();
                    objpatient.tpt_fullname  = fullname;
                    objpatient.tpt_othername = fullname;
                }
                catch (Exception ex)
                {
                    try
                    {
                        string tname    = string.IsNullOrEmpty(tga.ttl_desc) ? "" : tga.ttl_desc.Trim();
                        string fname    = string.IsNullOrEmpty(tga.papmi_name) ? "" : " " + tga.papmi_name.Trim();
                        string lname    = string.IsNullOrEmpty(tga.papmi_name2) ? "" : " " + tga.papmi_name2.Trim();
                        string fullname = (tname + fname + lname).Trim();
                        objpatient.tpt_fullname  = fullname;
                        objpatient.tpt_othername = fullname;
                    }
                    catch
                    {
                    }
                    Program.MessageError("GetDataFromTrakCare", "tpt_fullname", ex, false);
                }

                if (!string.IsNullOrEmpty(tga.ctmar_desc))
                {
                    married mar = mst_married.Where(x => x.desc.Any(y => tga.ctmar_desc.Contains(y))).FirstOrDefault();
                    if (mar != null)
                    {
                        objpatient.tpt_married      = mar.status;
                        objpatient.tpt_married_desc = mar.desc;
                    }
                }
                objpatient.trn_patient_regis.Add(getDefaultPatientRegis(tga, SiteCode));//add SiteCode suriya 03/04/2015
            }
        }
コード例 #6
0
 public char?getNewPatientType(tmp_getptarrived tga)
 {
     return(tga.paadm_type_of_patient_calc == "1" || tga.paadm_type_of_patient_calc == "2" ? 'Y' : 'N');
 }
コード例 #7
0
        public trn_patient_regi getDefaultPatientRegis(tmp_getptarrived tga, int SiteCode = -999)//add SiteCode suriya 03/04/2015
        {
            mst_hpc_site mhs_clinic = getSiteClinic();
            DateTime     dateNow    = DateTime.Now; //Program.GetServerDateTime();

            trn_patient_regi tpr = new trn_patient_regi
            {
                mac_id = null,                                                                        //
                mdc_id = null,                                                                        //
                mhc_id = null,                                                                        //
                //mhs_id = mhs_clinic.mhs_id,//del  suriya 03/04/2015
                mhs_id           = SiteCode == -999 ? mhs_clinic.mhs_id : Program.CurrentSite.mhs_id, //add  suriya 03/04/2015
                mut_id           = null,                                                              //
                tcd_id           = null,                                                              //
                tnc_id           = null,                                                              //
                tpr_appoint_type = 'T',
                //tpr_appointment_date = dateNow,//del  suriya 03/04/2015
                //tpr_arrive_date = dateNow,//del  suriya 03/04/2015
                tpr_appointment_date = SiteCode == -999 ? dateNow : tga.paadm_admdate, //add  suriya 03/04/2015
                tpr_arrive_date      = SiteCode == -999 ? dateNow : tga.paadm_admdate, //add  suriya 03/04/2015
                tpr_arrive_type      = tga.ser_rowid == 2808 ? 'W' : 'A',
                tpr_aviation_type    = null,                                           //
                tpr_check_pending    = 'N',
                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,                                           //
                tpr_create_by        = "CONSULT",
                tpr_create_date      = dateNow,
                tpr_email            = tga.paper_email,
                tpr_employee_no      = null, //
                tpr_en_no            = tga.paadm_admno,
                tpr_en_rowid         = tga.paadm_rowid,
                tpr_foreigner        = tga.ctnat_code == "TH" ? 'N' : 'Y', // 'TH' ? 'N' : 'Y'
                tpr_home_phone       = tga.paper_telh,
                tpr_main_address     = tga.paper_stname,
                tpr_main_amphur      = tga.ctcit_desc,
                tpr_main_id          = null, // reinsert when submit
                tpr_main_province    = tga.prov_desc,
                tpr_main_tumbon      = tga.citarea_desc,
                tpr_main_zip_code    = tga.ctzip_code,
                //tpr_mhc_ename = tpos.Select(x => x.tos_od_set_name).FirstOrDefault(),
                tpr_miss_lower           = false,
                tpr_mobile_phone         = tga.paper_mobphone,
                tpr_new_patient          = getNewPatientType(tga),
                tpr_npo_text             = null, //
                tpr_npo_time             = null, //
                tpr_office_phone         = tga.paper_telo,
                tpr_other_address        = tga.paper_stname,
                tpr_other_amphur         = tga.ctcit_desc,
                tpr_other_province       = tga.prov_desc,
                tpr_other_tumbon         = tga.citarea_desc,
                tpr_other_zip_code       = tga.ctzip_code,
                tpr_patient_type         = '1',
                tpr_pe_doc               = 'N',
                tpr_pe_doc_code          = null, //
                tpr_pe_doc_name          = null, //
                tpr_pe_status            = null, //
                tpr_pe_type              = 'W',
                tpr_pending              = false,
                tpr_pending_cancel_onday = false,
                tpr_pending_ct           = 0,
                tpr_pending_no_station   = null, //
                tpr_prev_pe_code         = null, //
                tpr_prev_pe_name         = null, //
                tpr_print_book           = "N",
                tpr_PRM                = null,
                tpr_PRM_check          = null,
                tpr_PRM_doccode        = null,
                tpr_PRM_docname        = null,
                tpr_PRM_doctor         = null,
                tpr_queue_no           = getQueueOtherClinic(tga.paadm_admno),
                tpr_queue_type         = getTprQueueType(tga),
                tpr_remark             = null, //
                tpr_req_doc_code       = null, //
                tpr_req_doc_gender     = null, //
                tpr_req_doc_name       = null, //
                tpr_req_doctor         = 'N',
                tpr_req_inorout_doctor = null, //
                tpr_req_pe_bef_chkup   = null, //
                tpr_rtn_pe_date        = null, //
                tpr_rtn_pe_name        = null, //
                tpr_send_book          = null, //
                tpr_send_to            = null, //
                tpr_site_use           = null, //
                tpr_status             = null, //
                tpr_type               = null, //
                tpr_update_by          = "CONSULT",
                tpr_update_date        = dateNow,
                tpr_vip_code           = tga.penstype_code,
                tpr_vip_desc           = tga.penstype_desc,
                tpr_arrive_site        = tga.LocWhenOrdOther,
                tpr_arrive_site_desc   = tga.LocWhenOrdOtherDesc
            };

            tpr.trn_basic_measure_hdrs.Add(getBasicHdr(tga.papmi_no, tga.paadm_admno));


            //GetPatientPackage(ref tpr, dateNow);
            //genPatientPlan(ref tpr, Program.CurrentSite.mhs_id, dateNow);
            int             enRowID    = Convert.ToInt32(tpr.tpr_en_rowid);
            GetPTPackageCls PackageCls = new GetPTPackageCls();
            EnumerableRowCollection <DataRow> getPTPackage = PackageCls.GetPTPackage(enRowID);

            PackageCls.AddPatientOrderItem(ref tpr, "System", dateNow, getPTPackage);
            PackageCls.AddPatientOrderSet(ref tpr, "System", dateNow, getPTPackage);
            List <MapOrderEvent> mapOrder = PackageCls.MapEvent(getPTPackage);

            PackageCls.AddPatientEvent(ref tpr, "System", dateNow, mapOrder);
            PackageCls.AddPatientPlan(ref tpr, "System", dateNow, mapOrder);
            PackageCls.skipReqDoctorOutDepartment(ref tpr);
            PackageCls.CompleteEcho(ref tpr);
            PackageCls.skipChangeEstToEcho(ref tpr, tpr.mhs_id);
            PackageCls.checkOrderPMR(ref tpr, tpr.mhs_id);


            trn_patient_queue tpq = getPatientQueue("CB", tpr);

            if (tpq != null)
            {
                tpr.trn_patient_queues.Add(tpq);
            }

            List <trn_out_department> tod = getOutDepartment(tga.papmi_no, tga.ctloc_code, DateTime.Now);

            if (tod != null)
            {
                tpr.trn_out_departments.AddRange(tod);
            }

            trn_patient_cat tpc = getForeignerPatient(tga.ctnat_code);

            if (tpc != null)
            {
                tpr.trn_patient_cats.Add(tpc);
            }

            return(tpr);
        }
コード例 #8
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
            }
        }
コード例 #9
0
        private tmp_getptarrived getArrivedByHn(string hn)
        {
            lbAlert.Text        = "Searching...";
            btnCancel.Enabled   = false;
            btnContinue.Enabled = false;
            btnSearch.Enabled   = false;
            Application.DoEvents();

            string tmpHN = hn.Replace("-", "");

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            //using (InhCheckupDataContext cdc = new InhCheckupDataContext())
            //{
            //    DateTime dateNow = Program.GetServerDateTime();
            //    List<vw_tmp_arrive> result = cdc.vw_tmp_arrives
            //                                    .Where(x => (x.papmi_no == tmpHN || x.papmi_no.Replace("-", "") == tmpHN) &&
            //                                                x.paadm_admdate.Value.Date == dateNow.Date).ToList();
            //    if (result.Count > 0)
            //    {
            //        result = result.Where(x => x.flag_success == 'N' || x.flag_success == null).ToList();
            //        if (result.Count > 0)
            //        {
            //            int row_id = result.Select(x => x.row_id).FirstOrDefault();
            //            return get_tgaByRowID(row_id);
            //        }
            //        else
            //        {
            //            lbAlert.Text = "This HN No. is processing on EMR-checkup.";
            //        }
            //    }
            //    else
            //    {
            //        lbAlert.Text = "This HN No. is not found.";
            //    }
            //    return null;
            //}
            try
            {
                string currentSite     = null;
                string currentSiteName = null;
                if (Program.CurrentSite != null)
                {
                    currentSite = Program.CurrentSite.mhs_code;
                    mst_hpc_site mhs = Program.getMstHpcSiteByMshCode(currentSite);
                    currentSiteName = mhs != null ? mhs.mhs_ename : null;
                }
                if (currentSite != null)
                {
                    DateTime dateTime = Program.GetServerDateTime();
                    string   hn_pos1  = tmpHN.Length >= 2 ? tmpHN.Substring(0, 2) : "";
                    string   hn_pos2  = tmpHN.Length >= 4 ? tmpHN.Substring(2, 2) : "";
                    string   hn_pos3  = tmpHN.Length >= 5 ? tmpHN.Substring(4) : "";

                    string realHN = hn_pos1 + "-" + hn_pos2 + "-" + hn_pos3;

                    using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                    {
                        List <tmp_getptarrived> tmpArrived = cdc.tmp_getptarriveds.Where(x => x.papmi_no == realHN && x.paadm_admdate.Value.Date == dateTime.Date)
                                                             .ToList();
                        if (tmpArrived.Count > 0)
                        {
                            if (tmpArrived.Where(x => x.flag_success == 'Y').Count() != 0)
                            {
                                lbAlert.Text = "This HN No. is processing on EMR-checkup.";
                                return(null);
                            }
                        }
                        EmrClass.GetDataFromWSTrakCare cls = new EmrClass.GetDataFromWSTrakCare();
                        using (Service.WS_TrakcareCls ws = new Service.WS_TrakcareCls())
                        {
                            string           dateNow = Program.GetServerDateString();
                            string           timeNow = string.Format(DateTime.Now.ToString("{0}HH{1}mm{2}ss{3}"), "PT", "H", "M", "S");
                            tmp_getptarrived tga     = ws.GetPTOrderByLocDateHn(currentSite, dateNow, realHN).AsEnumerable()
                                                       .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 = timeNow,
                                paadm_admdate    = x.Field <DateTime?>("PAADM_AdmDate"),
                                allergy_eng      = new APITrakcare.GetAllergyCls().GetByHN(x.Field <string>("PAPMI_No")),
                                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       = cls.returnMainSite(currentSite),
                                ctloc_desc       = currentSiteName,
                                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      = new EmrClass.GetPatientImage().getByPath(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"),
                                flag_success = 'Y',

                                LocWhenOrdOther = cls.returnMainSite(x.Field <string>("LocWhenOrdOther")),
                                //LocWhenOrdCheckup = x.Field<string>("LocWhenOrdCheckup"),
                                //LocWhenOrdConsult = cls.returnMainSite(x.Field<string>("LocWhenOrdConsult")),
                                LocWhenOrdOtherDesc = x.Field <string>("LocWhenOrdOtherDesc"),
                            }).FirstOrDefault();

                            //btnCancel.Enabled = true;
                            //btnContinue.Enabled = true;
                            //btnSearch.Enabled = true;
                            if (tga == null)
                            {
                                lbAlert.Text = "This HN No. is not found.";
                                return(null);
                            }
                            else
                            {
                                //if (tga.paper_photo == null)
                                //{
                                //    MemoryStream ms = new MemoryStream();
                                //    BKvs2010.Properties.Resources.no_image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                                //    tga.paper_photo = ms.ToArray();
                                //}
                                //tmpArrived.ForEach(x => x.flag_success = 'Y');
                                //cdc.SubmitChanges();
                                lbAlert.Text = "";
                                return(tga);
                            }
                        }
                    }
                }
            }
            catch
            {
                lbAlert.Text = "This process is Error.";
            }
            finally
            {
                btnCancel.Enabled   = true;
                btnContinue.Enabled = true;
                btnSearch.Enabled   = true;
            }
            return(null);
        }