예제 #1
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);
        }
예제 #2
0
        public static void SaveBasicMeasurment(int tpr_id, bool _IsCallLab)
        {
            if (_IsCallLab == true)
            {
                using (InhCheckupDataContext dbc = new InhCheckupDataContext())
                {
                    trn_patient_regi tpr = dbc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault();
                    if (tpr != null)
                    {
                        trn_basic_measure_hdr hdr = tpr.trn_basic_measure_hdrs.FirstOrDefault();
                        if (hdr == null)
                        {
                            hdr = new trn_basic_measure_hdr();
                            tpr.trn_basic_measure_hdrs.Add(hdr);
                        }

                        List <trn_basic_measure_dtl> dtl = hdr.trn_basic_measure_dtls.ToList();
                        if (dtl.Count() > 0)
                        {
                            dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(dtl);
                        }

                        EmrClass.GetDataFromWSTrakCare tk       = new EmrClass.GetDataFromWSTrakCare();
                        List <trn_basic_measure_dtl>   newBmDtl = tk.getVitalSignByHN(tpr.trn_patient.tpt_hn_no);
                        if (newBmDtl != null && newBmDtl.Count() > 0)
                        {
                            trn_basic_measure_dtl last_basic_dtl = newBmDtl.OrderByDescending(x => x.tbd_date).FirstOrDefault();
                            if (last_basic_dtl != null)
                            {
                                hdr.tbm_glass_or_contact = last_basic_dtl.tbd_vision_with_lens == true ? 'Y' : 'N';
                            }
                            if (newBmDtl != null && newBmDtl.Count > 0)
                            {
                                hdr.trn_basic_measure_dtls.AddRange(newBmDtl);
                            }
                        }
                        dbc.SubmitChanges();
                    }

                    //if (Program.CurrentRegis != null)
                    //{

                    //var objbmhdr = dbc.trn_basic_measure_hdrs.Where(c => c.tpr_id == tpr_id).ToList();

                    //dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(bmDtl);
                    //if (objbmhdr.Count > 0)
                    //{

                    //del data in trn_basic_measurement by tbm_id
                    //var objdeldtl = dbc.trn_basic_measure_dtls.Where(c => c.tbm_id == objbmhdr[0].tbm_id);
                    //dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(objdeldtl);
                    //foreach (var data in objdeldtl)
                    //{
                    //    dbc.trn_basic_measure_dtls.DeleteOnSubmit(data);
                    //}
                    //dbc.SubmitChanges();

                    //    Ws_GetDataByTrak.WS_GetDataBytrakSoapClient ws = new Ws_GetDataByTrak.WS_GetDataBytrakSoapClient();

                    //    var hn = dbc.trn_patients.Where(c => c.tpt_id == Program.CurrentRegis.tpt_id).FirstOrDefault();

                    //    //Search By HN
                    //    DataTable dt = ws.GetVitalSignByHN(hn.tpt_hn_no);

                    //    if (dt.Rows.Count != 0)
                    //    {
                    //        //ค้นหาวันที่ 5 วันล่าสุด จาก ws
                    //        var objseldatetop5 = (from myRow in dt.AsEnumerable()
                    //                              select myRow).GroupBy(c => c.Field<DateTime>("OBS_Date")).Take(5).ToList();

                    //        for (int i = 0; i < objseldatetop5.Count; i++)
                    //        {
                    //            //ค้นหาข้อมูลตามวันที่
                    //            trn_basic_measure_dtl objnew = new trn_basic_measure_dtl();

                    //            var objseldata = (from myRow in dt.AsEnumerable()
                    //                              where myRow.Field<DateTime>("OBS_Date") == objseldatetop5[i].Key
                    //                              select myRow).ToList();

                    //            //save data to trn_basic_measurement_dlt
                    //            foreach (var data in objseldata)
                    //            {
                    //                switch ((int)data["OBS_Item_DR"])
                    //                {
                    //                    case 230:
                    //                        objnew.tbd_weight = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 231:
                    //                        objnew.tbd_height = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 11:
                    //                        objnew.tbd_temp = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 129:
                    //                        objnew.tbd_systolic = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 128:
                    //                        objnew.tbd_diastolic = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 9:
                    //                        objnew.tbd_pulse = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 10:
                    //                        objnew.tbd_rr = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 134:
                    //                        objnew.tbd_bmi = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 176:
                    //                        objnew.tbd_waist = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 173:
                    //                        objnew.tbd_vision_lt = (string)data["OBS_Value"];
                    //                        break;
                    //                    case 174:
                    //                        objnew.tbd_vision_rt = (string)data["OBS_Value"];
                    //                        break;
                    //                }

                    //                string _DateTime = String.Format("{0:yyyy/MM/dd}", data["OBS_Date"]);

                    //                objnew.tbd_date = Convert.ToDateTime(_DateTime + " " + data["OBS_Time"]);
                    //                objnew.tbm_id = objbmhdr[0].tbm_id;
                    //                objnew.tbd_create_by = Program.CurrentUser.mut_username;
                    //                objnew.tbd_create_date = Program.GetServerDateTime();

                    //                objnew.tbd_update_by = Program.CurrentUser.mut_username;
                    //                objnew.tbd_update_date = Program.GetServerDateTime();
                    //            }

                    //            dbc.trn_basic_measure_dtls.InsertOnSubmit(objnew);
                    //        }
                    //    }

                    //    dbc.SubmitChanges();
                    //}

                    //} //if cur regis
                } //using
            }
        }
예제 #3
0
        private void btnContinue_Click(object sender, EventArgs e)
        {
            try
            {
                btnContinue.Enabled = false;
                btnSearch.Enabled   = false;
                btnCancel.Enabled   = false;
                lbAlert.Text        = "Processing...";
                Application.DoEvents();

                //tmp_getptarrived result = getArrivedByHn(hn_no);
                if (currentGetArrived != null)
                {
                    using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                    {
                        //tmp_getptarrived tga = cdc.tmp_getptarriveds.Where(x => x.row_id == result.row_id).FirstOrDefault();
                        //tga.flag_success = 'Y';
                        DateTime dateNow = Program.GetServerDateTime();

                        List <tmp_getptarrived> tmpArrived = cdc.tmp_getptarriveds.Where(x => x.papmi_no == currentGetArrived.papmi_no).ToList(); // && x.paadm_admdate.Value.Date == dateNow.Date
                        if (tmpArrived.Where(x => x.flag_success == 'Y').Count() == 0)
                        {
                            tmpArrived.ForEach(x => x.flag_success = 'Y');
                            cdc.tmp_getptarriveds.InsertOnSubmit(currentGetArrived);
                            EmrClass.GetDataFromWSTrakCare cls = new EmrClass.GetDataFromWSTrakCare();
                            trn_patient tpt            = cdc.trn_patients.Where(x => x.tpt_hn_no == currentGetArrived.papmi_no).FirstOrDefault();
                            bool        flagNewPatient = true;
                            if (tpt != null)
                            {
                                flagNewPatient = false;
                            }
                            cls.otherClinicSkipToCheckB(currentGetArrived, ref tpt);
                            if (flagNewPatient == true)
                            {
                                cdc.trn_patients.InsertOnSubmit(tpt);
                            }
                            cdc.SubmitChanges();
                            trn_patient_regi      tpr        = tpt.trn_patient_regis.OrderByDescending(x => x.tpr_create_date).FirstOrDefault();
                            trn_RefreshLabHistory refreshHis = new trn_RefreshLabHistory()
                            {
                                tpr_id     = tpr.tpr_id,
                                CreateDate = dateNow,
                                HN_no      = tpt.tpt_hn_no,
                                status     = false
                            };
                            cdc.trn_RefreshLabHistories.InsertOnSubmit(refreshHis);
                            cdc.SubmitChanges();
                            new EmrClass.GetPTPackageCls().setRelationOrderSet(ref tpr);
                            cdc.SubmitChanges();
                            btnContinue.Enabled = true;
                            btnSearch.Enabled   = true;
                            btnCancel.Enabled   = true;
                            returnHN            = currentGetArrived.papmi_no;
                            this.Close();
                        }
                        else
                        {
                        }
                    }
                }
            }
            catch
            {
            }
        }