コード例 #1
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);
        }
コード例 #2
0
        public StatusTransaction importPatient(int tpr_id)
        {
            try
            {
                using (InhCheckupDataContext contxt = new InhCheckupDataContext())
                {
                    DateTime dateNow = Program.GetServerDateTime();
                    //List<trn_RefreshLabHistory> his = contxt.trn_RefreshLabHistories.Where(x => x.tpr_id == tpr_id).ToList();
                    //his.ForEach(x => x.status = true);
                    //contxt.SubmitChanges();

                    trn_patient_regi patient_regis = contxt.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault();
                    //using (Service.WS_CheckupCls wsCheckup = new Service.WS_CheckupCls())
                    //{
                    //    wsCheckup.InsertDBEmrCheckupResultXray(patient_regis.trn_patient.tpt_hn_no, patient_regis.tpr_en_no, dateNow.AddYears(-5), dateNow, true);
                    //}
                }

                using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                {
                    try
                    {
                        string   username = Program.CurrentUser == null ? "" : Program.CurrentUser.mut_username;
                        DateTime dateNow  = Program.GetServerDateTime();
                        cdc.Connection.Open();
                        DbTransaction trans = cdc.Connection.BeginTransaction();
                        cdc.Transaction = trans;

                        trn_patient_regi patient_regis = cdc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault();

                        patient_regis.trn_patient_queues.ToList().ForEach(x => { x.tps_status = "ED"; x.tps_ns_status = null; x.tps_update_by = username; x.tps_update_date = dateNow; });

                        int enRowID = Convert.ToInt32(patient_regis.tpr_en_rowid);
                        EmrClass.GetPTPackageCls          PackageCls   = new EmrClass.GetPTPackageCls();
                        EnumerableRowCollection <DataRow> getPTPackage = PackageCls.GetPTPackage(enRowID);
                        PackageCls.AddPatientOrderItem(ref patient_regis, username, dateNow, getPTPackage);
                        PackageCls.AddPatientOrderSet(ref patient_regis, username, dateNow, getPTPackage);
                        List <MapOrderEvent> mapOrder = PackageCls.MapEvent(getPTPackage);
                        PackageCls.AddPatientEvent(ref patient_regis, username, dateNow, mapOrder);
                        PackageCls.AddPatientPlan(ref patient_regis, username, dateNow, mapOrder);
                        PackageCls.skipReqDoctorOutDepartment(ref patient_regis);
                        PackageCls.CompleteEcho(ref patient_regis);
                        PackageCls.skipChangeEstToEcho(ref patient_regis, patient_regis.mhs_id);
                        PackageCls.checkOrderPMR(ref patient_regis, patient_regis.mhs_id);

                        patient_regis.tpr_status    = "WB";
                        patient_regis.tpr_pe_status = "RS";
                        try
                        {
                            cdc.SubmitChanges();
                        }
                        catch (System.Data.Linq.ChangeConflictException)
                        {
                            foreach (System.Data.Linq.ObjectChangeConflict occ in cdc.ChangeConflicts)
                            {
                                cdc.Refresh(System.Data.Linq.RefreshMode.KeepChanges, occ.Object);
                            }
                            cdc.SubmitChanges();
                        }
                        PackageCls.setRelationOrderSet(ref patient_regis);
                        cdc.SubmitChanges();
                        cdc.Transaction.Commit();

                        using (Service.WS_CheckupCls ws = new Service.WS_CheckupCls())
                        {
                            ws.retrieveVitalSign(tpr_id, username);
                            ws.getCheckUpLabResult("", tpr_id);
                        }
                        return(StatusTransaction.True);
                    }
                    catch (Exception ex)
                    {
                        //cdc.Transaction.Rollback();
                        Program.MessageError("ImportPatientToBookCls", "importPatient", ex, false);
                        return(StatusTransaction.Error);
                    }
                    finally
                    {
                        //cdc.Connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Program.MessageError("ImportPatientToBookCls", "importPatient", ex, false);
                return(StatusTransaction.Error);
            }
        }