Example #1
0
        public void updatePlanForSkipByMvt(ref trn_patient_regi tpr, int mvt_id)
        {
            trn_patient_plan currentPlan = tpr.trn_patient_plans.Where(x => x.mvt_id == mvt_id).FirstOrDefault();

            currentPlan.tpl_skip     = true;
            currentPlan.tpl_skip_seq = currentPlan.tpl_skip_seq == null ? 1 : currentPlan.tpl_skip_seq + 1;
        }
Example #2
0
 public bool skipReqDoctorOutDepartment(ref trn_patient_regi tpr)
 {
     try
     {
         if (tpr.tpr_req_doctor == 'Y' && tpr.tpr_req_inorout_doctor == "UT")
         {
             int?pe_mvt_id = GetEventID("PE");
             List <trn_patient_plan> planPE = tpr.trn_patient_plans.Where(x => x.mvt_id == pe_mvt_id).ToList();
             foreach (trn_patient_plan patient_plan in planPE)
             {
                 trn_patient_plan remove_plan = patient_plan;
                 if (patient_plan.tpl_id != 0)
                 {
                     remove_plan = tpr.trn_patient_plans.Where(x => x.tpl_id == patient_plan.tpl_id).FirstOrDefault();
                 }
                 tpr.trn_patient_plans.Remove(remove_plan);
             }
             return(true);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         Class.globalCls.MessageError("GetDataFromWSTrakCare", "skipReqDoctorOutDepartment", ex.Message);
         return(false);
     }
 }
Example #3
0
        public bool AddPatientPlan(ref trn_patient_regi PatientRegis, string username, DateTime dateNow, List <MapOrderEvent> mapEvent)
        {
            try
            {
                if (mapEvent != null)
                {
                    foreach (var map in mapEvent)
                    {
                        List <trn_patient_plan> listPlan = PatientRegis.trn_patient_plans
                                                           .Where(x => x.tpl_key == map.tk_orderitem_row_id &&
                                                                  x.mop_id == map.mop_id)
                                                           .ToList();
                        switch (map.status)
                        {
                        case "D":
                        {
                            foreach (trn_patient_plan plan in listPlan)
                            {
                                PatientRegis.trn_patient_plans.Remove(plan);
                            }
                        }
                        break;

                        case "V":
                        {
                            if (listPlan.Count() > 0)
                            {
                                foreach (trn_patient_plan PatientPlan in listPlan)
                                {
                                    PatientPlan.mvt_id = map.mvt_id;
                                }
                            }
                            else
                            {
                                trn_patient_plan patientPlan = PatientRegis.trn_patient_plans
                                                               .Where(x => x.mvt_id == map.mvt_id)
                                                               .FirstOrDefault();
                                if (patientPlan == null)
                                {
                                    trn_patient_queue patientQueue = PatientRegis.trn_patient_queues
                                                                     .Where(x => x.mvt_id == map.mvt_id &&
                                                                            x.tps_status == "ED" && x.tps_ns_status == null)
                                                                     .FirstOrDefault();
                                    if (patientQueue == null)
                                    {
                                        PatientRegis.trn_patient_plans.Add(new trn_patient_plan
                                            {
                                                mvt_id          = map.mvt_id,
                                                tpl_status      = 'N',
                                                tpl_by          = 'A',
                                                tpl_new         = false,
                                                tpl_use_pac     = map.use_pac,
                                                tpl_patho       = pathoReplace(map.patho, map.excute_date),
                                                tpl_pac_sheet   = map.pac_sheet,
                                                tpl_create_by   = username,
                                                tpl_create_date = dateNow,
                                                tpl_key         = map.tk_orderitem_row_id,
                                                mop_id          = map.mop_id
                                            });
                                    }
                                    else
                                    {
                                        PatientRegis.trn_patient_plans.Add(new trn_patient_plan
                                            {
                                                mvt_id          = map.mvt_id,
                                                tpl_status      = 'P',
                                                tpl_by          = 'A',
                                                tpl_new         = false,
                                                tpl_use_pac     = map.use_pac,
                                                tpl_patho       = pathoReplace(map.patho, map.excute_date),
                                                tpl_pac_sheet   = map.pac_sheet,
                                                tpl_create_by   = username,
                                                tpl_create_date = dateNow,
                                                tpl_key         = map.tk_orderitem_row_id,
                                                mop_id          = map.mop_id
                                            });
                                    }
                                }
                                else
                                {
                                    PatientRegis.trn_patient_plans.Add(new trn_patient_plan
                                        {
                                            mvt_id          = map.mvt_id,
                                            tpl_status      = patientPlan.tpl_status,
                                            tpl_by          = patientPlan.tpl_by,
                                            tpl_new         = false,
                                            tpl_use_pac     = map.use_pac,
                                            tpl_patho       = pathoReplace(map.patho, map.excute_date),
                                            tpl_pac_sheet   = map.pac_sheet,
                                            tpl_create_by   = username,
                                            tpl_create_date = dateNow,
                                            tpl_key         = map.tk_orderitem_row_id,
                                            tpl_skip        = patientPlan.tpl_skip,
                                            tpl_skip_seq    = patientPlan.tpl_skip_seq,
                                            mop_id          = map.mop_id
                                        });
                                }
                            }
                        }
                        break;

                        case "E":
                        {
                            //if (listPlan.Count() > 0)
                            //{
                            //    foreach (trn_patient_plan PatientPlan in listPlan)
                            //    {
                            //        PatientPlan.mvt_id = map.mvt_id;
                            //        PatientPlan.tpl_status = 'P';
                            //    }
                            //}
                            //else
                            //{
                            //    PatientRegis.trn_patient_plans.Add(new trn_patient_plan
                            //    {
                            //        mvt_id = map.mvt_id,
                            //        tpl_status = 'P',
                            //        tpl_by = 'A',
                            //        tpl_new = false,
                            //        tpl_use_pac = map.use_pac,
                            //        tpl_patho = pathoReplace(map.patho, tmpArriveDate),
                            //        tpl_pac_sheet = map.pac_sheet,
                            //        tpl_create_by = username,
                            //        tpl_create_date = dateNow,
                            //        tpl_key = map.tk_orderitem_row_id,
                            //        mop_id = map.mop_id
                            //    });
                            //}
                        }
                        break;
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Class.globalCls.MessageError("GetPTPackageCls", "AddPatientPlan", ex.Message);
                return(false);
            }
        }
Example #4
0
        public bool AddPatientPlan(ref trn_patient_regi tpr, string username, DateTime dateNow)
        {
            try
            {
                using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                {
                    List <trn_patient_order_item> listPatientItem = tpr.trn_patient_order_items
                                                                    .Where(x => new List <string> {
                        "E", "V", "D"
                    }.Contains(x.toi_trakcare_status))
                                                                    .ToList();
                    var mapMaster = (from oi in listPatientItem
                                     join mp in cdc.mst_order_plans.Where(x => x.mop_status == 'A')
                                     on oi.toi_item_row_id equals mp.mop_item_row_id
                                     select new
                    {
                        mvt_id = mp.mvt_id,
                        status = oi.toi_trakcare_status,
                        tpl_by = 'A',
                        tpl_new = false,
                        tpl_use_pac = oi.toi_use_pac,
                        tpl_pac_sheet = oi.toi_pac_sheet,
                        tpl_create_by = username,
                        tpl_create_date = dateNow,
                        tpl_key = oi.toi_key,
                        mop_id = mp.mop_id
                    }).ToList();

                    var order = mapMaster.GroupBy(x => x.mvt_id)
                                .Select(x => x.OrderBy(y => y.status == "E" ? 0 :
                                                       y.status == "V" ? 1 : 2).FirstOrDefault())
                                .Select(x => new
                    {
                        mvt_id          = x.mvt_id,
                        status          = x.status,
                        tpl_by          = 'A',
                        tpl_new         = false,
                        tpl_use_pac     = x.tpl_use_pac,
                        tpl_pac_sheet   = x.tpl_pac_sheet,
                        tpl_create_by   = username,
                        tpl_create_date = dateNow,
                        tpl_key         = x.tpl_key,
                        mop_id          = x.mop_id
                    }).ToList();

                    foreach (var od in order)
                    {
                        List <trn_patient_plan> plan = tpr.trn_patient_plans.Where(x => x.mvt_id == od.mvt_id).ToList();
                        if (plan.Count() == 0)
                        {
                            if (od.status != "D")
                            {
                                trn_patient_plan newPlan = new trn_patient_plan
                                {
                                    mvt_id          = od.mvt_id,
                                    tpl_status      = od.status == "E" ? 'P' : 'N',
                                    tpl_by          = 'A',
                                    tpl_new         = false,
                                    tpl_use_pac     = od.tpl_use_pac,
                                    tpl_pac_sheet   = od.tpl_pac_sheet,
                                    tpl_create_by   = username,
                                    tpl_create_date = dateNow,
                                    tpl_key         = od.tpl_key,
                                    mop_id          = od.mop_id
                                };
                                tpr.trn_patient_plans.Add(newPlan);
                            }
                        }
                        else
                        {
                            if (od.status == "D")
                            {
                                foreach (trn_patient_plan pl in plan)
                                {
                                    tpr.trn_patient_plans.Remove(pl);
                                }
                            }
                            else
                            {
                                foreach (trn_patient_plan pl in plan)
                                {
                                    if (pl.tpl_status == 'N')
                                    {
                                        pl.tpl_status = od.status == "E" ? 'P' : 'N';
                                    }
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Class.globalCls.MessageError("GetDataFromWSTrakCare", "getPatientPlan", ex.Message);
                return(false);
            }
        }
Example #5
0
        public static void RunSkipEST(int siteid, ref trn_patient_regi tpr)
        {
            try
            {
                using (InhCheckupDataContext dbc = new InhCheckupDataContext())
                {
                    DateTime datenow    = Program.GetServerDateTime();
                    var      gettxtcode = (from t1 in dbc.mst_config_hdrs
                                           join t2 in dbc.mst_config_dtls
                                           on t1.mfh_id equals t2.mfh_id
                                           where t1.mfh_code == "ECHO" &&
                                           t1.mhs_id == siteid &&
                                           t1.mfh_status == 'A' &&
                                           datenow >= t1.mfh_effective_date.Value &&
                                           (t1.mfh_expire_date != null ? (datenow <= t1.mfh_expire_date.Value) : true)
                                           select t2.mfd_text).ToList();
                    if (gettxtcode.Count() != 0)
                    {
                        List <trn_patient_order_set> tpos = tpr.trn_patient_order_sets.Where(x => gettxtcode.Contains(x.tos_od_set_code)).ToList();
                        if (tpos != null)
                        {
                            bool chkEst = tpos.Count > 0;
                            if (chkEst)
                            {
                                int get_mvtEcho = (from t1 in dbc.mst_events
                                                   where t1.mvt_code == "EC" &&
                                                   t1.mvt_status == 'A' &&
                                                   datenow >= t1.mvt_effective_date.Value &&
                                                   (t1.mvt_expire_date != null ? (datenow <= t1.mvt_expire_date.Value) : true)
                                                   select t1.mvt_id).FirstOrDefault();

                                /*var get_mvtid = (from t1 in dbc.mst_events
                                 *               join t2 in dbc.mst_room_events on t1.mvt_id equals t2.mvt_id
                                 *               join t3 in dbc.mst_room_hdrs on t2.mrm_id equals t3.mrm_id
                                 *               where t3.mhs_id == siteid
                                 *               //&& (t3.mrm_code == "ES" || t3.mrm_code == "DC")
                                 *               && t3.mrm_code == "ES"
                                 *               select t1.mvt_id).Distinct().ToList();*/

                                int get_mvtid = (from t1 in dbc.mst_events
                                                 where t1.mvt_code == "ES" &&
                                                 t1.mvt_status == 'A' &&
                                                 datenow >= t1.mvt_effective_date.Value &&
                                                 (t1.mvt_expire_date != null ? (datenow <= t1.mvt_expire_date.Value) : true)
                                                 select t1.mvt_id).FirstOrDefault();

                                List <trn_patient_plan> tpp = tpr.trn_patient_plans.Where(x => x.tpl_status != 'P' && x.mvt_id == get_mvtid).ToList();
                                foreach (trn_patient_plan t in tpp)
                                {
                                    ////tpr.trn_patient_plans.Remove(t);
                                    //t.mvt_id = get_mvtEcho;
                                    //t.tpl_status = 'P';
                                    trn_patient_plan patient_plan = tpr.trn_patient_plans.Where(x => x.tpl_id == t.tpl_id).FirstOrDefault();
                                    patient_plan.mvt_id     = get_mvtEcho;
                                    patient_plan.tpl_status = 'P';
                                }

                                var get_mvtid_dc = (from t1 in dbc.mst_events
                                                    join t2 in dbc.mst_room_events on t1.mvt_id equals t2.mvt_id
                                                    join t3 in dbc.mst_room_hdrs on t2.mrm_id equals t3.mrm_id
                                                    where t3.mhs_id == siteid
                                                    //&& (t3.mrm_code == "ES" || t3.mrm_code == "DC")
                                                    && t3.mrm_code == "DC"
                                                    select t1.mvt_id).Distinct().ToList();
                                List <trn_patient_plan> tpp_1 = tpr.trn_patient_plans.Where(x => x.tpl_status != 'P' && get_mvtid_dc.Contains(x.mvt_id)).ToList();
                                foreach (trn_patient_plan t in tpp_1)
                                {
                                    //tpr.trn_patient_plans.Remove(t);
                                    ////t.tpl_status = 'P';
                                    trn_patient_plan patient_plan = tpr.trn_patient_plans.Where(x => x.tpl_id == t.tpl_id).FirstOrDefault();
                                    tpr.trn_patient_plans.Remove(patient_plan);
                                }

                                //var delobj = (from t in dbc.trn_patient_plans
                                //              where t.tpr_id == tprid
                                //              && t.tpl_status != 'P'
                                //              && get_mvtid.Contains(t.mvt_id)
                                //              select t).ToList();
                                //if (delobj.Count() > 0)
                                //{
                                //    dbc.trn_patient_plans.DeleteAllOnSubmit(delobj);
                                //    dbc.SubmitChanges();
                                //}
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }