Exemple #1
0
        public ListModelBase <GmsExcludedCustomerViewModel, OutboundCallQueueFilter> GetExcludedCustomers(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var outboundCallQueueFilter = filter as OutboundCallQueueFilter ?? new OutboundCallQueueFilter();
            var organization            = _organizationRepository.GetOrganizationbyId(outboundCallQueueFilter.HealthPlanId);

            CallQueue callQueue = null;

            var criteria = _healthPlanCallQueueCriteriaRepository.GetById(outboundCallQueueFilter.CriteriaId);

            callQueue = _callQueueRepository.GetById(outboundCallQueueFilter.CallQueueId > 0 ? outboundCallQueueFilter.CallQueueId : criteria.CallQueueId);
            outboundCallQueueFilter.CallQueueId = callQueue.Id;

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(outboundCallQueueFilter);

            var excludedCustomers = _gmsExcludedCustomerRepository.GetExcludedCallQueueCustomers(pageNumber, pageSize, outboundCallQueueFilter, callQueue, outboundCallQueueFilter.SuppressionType, out totalRecords);

            var model = new ExcludedCustomerListModel {
                Filter = outboundCallQueueFilter
            };
            var customerIds = excludedCustomers.Where(x => x.CustomerId.HasValue).Select(x => x.CustomerId.Value).ToArray();

            if (!customerIds.IsNullOrEmpty())
            {
                var customers  = _customerRepository.GetCustomers(customerIds);
                var customTags = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds);
                model.Collection = Create(excludedCustomers, customers, customTags, organization);

                return(model);
            }
            model.Collection = Create(excludedCustomers, null, null, organization);

            return(model);
        }
Exemple #2
0
        public OpenGLRenderer(CreateFlags flags, GL gl)
        {
            _flags = flags;
            Gl     = gl;

            _vertexCollection = new VertexCollection();
            _callQueue        = new CallQueue();
            TextureManager    = new TextureManager(this);
        }
Exemple #3
0
        public void Single()
        {
            var result    = 0;
            var callQueue = new CallQueue();

            using (callQueue.BlockUntil(() => true)) {
                result = 1;
            }
            Assert.AreEqual(1, result);
        }
Exemple #4
0
        // public void LoadData( CheckupDataContext dbc)
        // {

        //     if (Program.CurrentRoom != null)
        //     {
        //         try
        //         {
        //             DateTime dtnow = Program.GetServerDateTime();
        //             DateTime ResetDate = new DateTime(dtnow.Year, dtnow.Month, dtnow.Day, 0, 0, 0);
        //             TimeSpan timenow = dtnow.TimeOfDay;
        //             //bool? doc_call = dbc.func_get_doctor_call(Program.CurrentUser.mut_username);

        //             ////Added.Akkaradech on 2014-01-08
        //             //var GetpatientInPatientCate = (from mut in dbc.mst_user_types
        //             //                               join muc in dbc.mst_user_cats
        //             //                               on mut.mut_id equals muc.mut_id
        //             //                               join tpc1 in dbc.trn_patient_cats
        //             //                               on muc.mdc_id equals tpc1.mdc_id
        //             //                               join tpq in dbc.trn_patient_queues
        //             //                               on tpc1.tpr_id equals tpq.tpr_id
        //             //                               where
        //             //                               tpq.mrm_id == Program.CurrentRoom.mrm_id
        //             //                               && tpq.tps_status == "NS"
        //             //                               && tpq.tps_ns_status == "QL"
        //             //                               && tpq.trn_patient_regi.tpr_arrive_date.Value.Date == dtnow.Date
        //             //                               select tpc1.tpr_id).Distinct().ToList();

        //             //int GetpatientInPatientCate = (from mut in dbc.mst_user_types
        //             //                               join muc in dbc.mst_user_cats
        //             //                               on mut.mut_id equals muc.mut_id
        //             //                               join tpc1 in dbc.trn_patient_cats
        //             //                               on muc.mdc_id equals tpc1.mdc_id
        //             //                               join tpq in dbc.trn_patient_queues
        //             //                               on tpc1.tpr_id equals tpq.tpr_id
        //             //                               where
        //             //                               tpq.mrm_id == Program.CurrentRoom.mrm_id
        //             //                               && tpq.tps_status == "NS"
        //             //                               && tpq.tps_ns_status == "QL"
        //             //                               && tpq.trn_patient_regi.tpr_arrive_date.Value.Date == dtnow.Date
        //             //                               select tpc1.tpr_id).Distinct().FirstOrDefault();
        //             ////EndAdded.Akkaradech on 2014-01-08

        //             var objwaitlist = (from t1 in dbc.trn_patient_queues
        //                                where t1.mrm_id == Program.CurrentRoom.mrm_id
        //                                && t1.trn_patient_regi.tpr_arrive_date.Value.Date == dtnow.Date

        //                                && t1.tps_status == "NS"
        //                                && t1.tps_ns_status == "QL"
        //                               // && GetpatientInPatientCate.Contains(t1.trn_patient_regi.tpr_id)
        //                                orderby t1.tps_bm_seq,t1.tps_create_date,t1.tps_hold_date
        //                                select new
        //                                 {
        //                                     mdc_id=t1.trn_patient_regi.mdc_id,
        //                                     mvtID=t1.mvt_id,
        //                                     ReqDoc=t1.trn_patient_regi.tpr_req_doctor,
        //                                     ReqGender = (t1.trn_patient_regi.tpr_req_doc_gender == null) ? 'X' : t1.trn_patient_regi.tpr_req_doc_gender,
        //                                     DocCode=t1.trn_patient_regi.tpr_req_doc_code,
        //                                     //PEDoc = string.IsNullOrEmpty(Convert.ToString((t1.trn_patient_regi.tpr_pe_doc == null) ? ' ' : t1.trn_patient_regi.tpr_pe_doc)) ? 'N' : t1.trn_patient_regi.tpr_pe_doc,
        //                                     PEDoc = (t1.trn_patient_regi.tpr_pe_doc == null) ? 'N' : t1.trn_patient_regi.tpr_pe_doc,
        //                                     //PEDoc = t1.trn_patient_regi.tpr_pe_doc,
        //                                     PEDocCode=t1.trn_patient_regi.tpr_pe_doc_code,
        //                                     NurseCode=t1.trn_patient_regi.tpr_nurse_code,
        //                                     RTN_Nurse=t1.trn_patient_regi.tpr_return_screening,

        //                                     OutDocCode = (t1.trn_patient_regi.tpr_req_inorout_doctor == null || t1.trn_patient_regi.tpr_req_inorout_doctor == "") ? false
        //                                                  : t1.trn_patient_regi.tpr_req_inorout_doctor == "UT" ? true : false,

        //                                     bmSeq=(t1.tps_bm_seq!=null)?t1.tps_bm_seq:99,
        //                                     ordDate=(t1.tps_call_status=="HD")?t1.tps_hold_date:t1.tps_create_date,
        //                                     hold_flag = (t1.tps_call_status == "HD" && (timenow.Subtract(t1.tps_hold_date.Value.TimeOfDay)).TotalMinutes >= 0) ? "Y" : "N",
        //                                     Callstatus=t1.tps_call_status,
        //                                     QueueNo = t1.trn_patient_regi.tpr_queue_no,
        //                                     IsPirot = t1.trn_patient_regi.tpr_patient_type,
        //                                     HN = t1.trn_patient_regi.trn_patient.tpt_hn_no,
        //                                     FullName = t1.trn_patient_regi.trn_patient.tpt_pre_name + t1.trn_patient_regi.trn_patient.tpt_first_name + " " + t1.trn_patient_regi.trn_patient.tpt_last_name,
        //                                     tprid = t1.trn_patient_regi.tpr_id,
        //                                     countmdc = (from t in dbc.trn_patient_cats where t.tpr_id == t1.trn_patient_regi.tpr_id select t.mdc_id).Count(),

        //                                     countInsu = (from t in dbc.trn_patient_cats
        //                                                  join s in dbc.mst_doc_categories on t.mdc_id equals s.mdc_id
        //                                                  where t.tpr_id == t1.trn_patient_regi.tpr_id
        //                                                  && s.mdc_pre_insure == true
        //                                                  select t.mdc_id).Count(),

        //                                     DocCat = (from t in dbc.trn_patient_cats join s in dbc.mst_doc_categories on t.mdc_id equals s.mdc_id where t.tpr_id == t1.trn_patient_regi.tpr_id && s.mdc_code == "MD014" select s.mdc_id).Distinct().Count(),
        //                                     //mdc_flag = (Convert1.ToInt32(GetpatientInPatientCate) == t1.trn_patient_regi.tpr_id) ? 1 : 0
        //                                     mdc_flag = (from mut in dbc.mst_user_types
        //                                                 join muc in dbc.mst_user_cats on mut.mut_id equals muc.mut_id
        //                                                 join tpc1 in dbc.trn_patient_cats on muc.mdc_id equals tpc1.mdc_id
        //                                                 join tpq in dbc.trn_patient_queues on tpc1.tpr_id equals tpq.tpr_id
        //                                                 where tpq.mrm_id == Program.CurrentRoom.mrm_id
        //                                                 && tpq.tpr_id == t1.trn_patient_regi.tpr_id
        //                                                 && tpq.tps_status == "NS"
        //                                                 && tpq.tps_ns_status == "QL"
        //                                                 && tpq.trn_patient_regi.tpr_arrive_date.Value.Date == dtnow.Date
        //                                                 && mut.mut_id == Program.CurrentUser.mut_id
        //                                                 && mut.mut_gender == ((tpq.trn_patient_regi.tpr_req_doc_gender == null) ? mut.mut_gender : tpq.trn_patient_regi.tpr_req_doc_gender)
        //                                                 select tpc1.tpr_id).Count(),
        //                                     vip_hpc = (t1.trn_patient_regi.trn_patient.tpt_vip_hpc == true) ? "Y" : "N",
        //                                     type_PE = ((from t in dbc.mst_events where t.mvt_id == t1.mvt_id select t.mvt_code).FirstOrDefault() == "PE") ? "Y" : "N",
        //                                     type_Lower = t1.trn_patient_regi.tpr_miss_lower,
        //                                     hilight = t1.tps_reserve == null ? false : (bool)t1.tps_reserve
        //                                 }).ToList();

        //                 objwaitlist = (from t1 in objwaitlist
        //                                //where t1.tprid == Convert1.ToInt32(GetpatientInPatientCate.Contains(t1.tprid))
        //                                orderby t1.hold_flag descending, t1.bmSeq, t1.ordDate
        //                                select t1).ToList();

        //             //*********** เช็คว่าเป็น Pirot **
        //             //var v_Avia = objwaitlist.Select(x => x.IsPirot).ToList();
        //             //var v_tprid = objwaitlist.Select(x => x.tprid).ToList();
        //             //var countmdc = (from t in dbc.trn_patient_cats where t.tpr_id == Convert1.ToInt32(v_tprid) select t.mdc_id).Count();
        //             var CurrentmrmCode = (from t1 in dbc.mst_room_hdrs where t1.mrm_id == Program.CurrentRoom.mrm_id select t1).FirstOrDefault();
        //             if (CurrentmrmCode != null)
        //             {
        //                 if (Program.CurrentSite.mhs_code == "01HPC3")
        //                 {
        //                     //objwaitlist = objwaitlist.OrderBy(x => x.bmSeq).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.ordDate).ToList();
        //                     objwaitlist = objwaitlist.OrderByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList();
        //                 }
        //                 else if (Program.CurrentSite.mhs_code == "01HPC2")
        //                 {
        //                     //objselect = objselect.OrderBy(x => x.tps_bm_seq).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.st_date).ToList();
        //                     objwaitlist = objwaitlist.OrderByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList();
        //                 }

        //                 if (CurrentmrmCode.mrm_code == "SC")
        //                 {
        //                     if (Program.CurrentRoom.mrd_avation == true && Program.CurrentRoom.mrd_pre_insure == true)
        //                     {
        //                         //objwaitlist = objwaitlist.Where(x => (x.IsPirot == '2' || x.IsPirot == '4') && x.countmdc > 0).ToList();

        //                         //objwaitlist = objwaitlist.Where(x => (x.IsPirot == '2' || x.IsPirot == '4') && x.countInsu > 0).ToList();
        //                     }
        //                     else if (Program.CurrentRoom.mrd_avation == true && Program.CurrentRoom.mrd_pre_insure == false)
        //                     {
        //                         //objwaitlist = objwaitlist.Where(x => x.IsPirot == '2' || x.IsPirot == '4').ToList();
        //                         objwaitlist = objwaitlist.Where(x => (x.IsPirot == '2' || x.IsPirot == '4') && x.countInsu == 0).ToList();
        //                     }
        //                     else if (Program.CurrentRoom.mrd_avation == false && Program.CurrentRoom.mrd_pre_insure == true)
        //                     {
        //                         //objwaitlist = objwaitlist.Where(x => x.countmdc > 0 || ((x.IsPirot != '2' && x.IsPirot != '4') && (x.countmdc == 0 || (x.countmdc > 0 && x.DocCat == 1)))).ToList();
        //                         //objselect = objselect.Where(x => countmdc > 0).ToList();

        //                         objwaitlist = objwaitlist.Where(x => (x.IsPirot != '2' && x.IsPirot != '4') || x.countInsu > 0).ToList();
        //                     }
        //                     else
        //                     {
        //                         //objwaitlist = objwaitlist.Where(x => (x.IsPirot != '2' && x.IsPirot != '4') && (x.countmdc == 0 || (x.countmdc > 0 && x.DocCat == 1))).ToList();

        //                         objwaitlist = objwaitlist.Where(x => (x.IsPirot != '2' && x.IsPirot != '4') && x.countInsu == 0).ToList();
        //                     }

        //                     /*if (Program.CurrentSite.mhs_code == "01HPC2")
        //                     {
        //                         objwaitlist = objwaitlist.Where(x => (x.NurseCode == null || (x.NurseCode != null && x.NurseCode == Program.CurrentUser.mut_username))).ToList();
        //                     }*/

        //                     // เพิ่มเงื่อนไขในการเข้าห้องเดิมของ HPC Site 2
        //                     if (Program.CurrentSite.mhs_code == "01HPC2")
        //                     {
        //                         objwaitlist = objwaitlist.Where(x => (x.NurseCode == null || (x.NurseCode != null && x.NurseCode == Program.CurrentUser.mut_username))).ToList();

        //                         objwaitlist = objwaitlist.OrderByDescending(x => x.vip_hpc).ThenByDescending(x => x.RTN_Nurse).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList();
        //                     }
        //                     else if (Program.CurrentSite.mhs_code == "01HPC3")
        //                     {
        //                         objwaitlist = objwaitlist.Where(x => (x.NurseCode == null || (x.NurseCode != null && x.NurseCode == Program.CurrentUser.mut_username))).ToList();

        //                         objwaitlist = objwaitlist.OrderByDescending(x => x.vip_hpc).ThenByDescending(x => x.RTN_Nurse).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList();
        //                     }

        //                     //if (Program.CurrentRoom.mrd_avation == true)
        //                     //{
        //                     //    objwaitlist = objwaitlist.Where(x => x.IsPirot == '2' || x.IsPirot=='4').ToList();
        //                     //}
        //                     //else
        //                     //{
        //                     //    if (countmdc == 0)
        //                     //    {
        //                     //        objwaitlist = objwaitlist.Where(x => x.IsPirot != '2' && x.IsPirot != '4').ToList();
        //                     //    }
        //                     //}
        //                     //if (Program.CurrentRoom.mrd_pre_insure == true)
        //                     //{
        //                     //   // objwaitlist = objwaitlist.Where(x => x.mdc_id != null || x.mdc_id == null).ToList();
        //                     //   // objwaitlist = objwaitlist.Where(x => countmdc > 0).ToList();
        //                     //}
        //                     //else
        //                     //{
        //                     //    if (Convert.ToChar(v_Avia) == '2' || Convert.ToChar(v_Avia) == '4')
        //                     //    {
        //                     //        // objselect = objselect.Where(x => x.mdc_id == null).ToList();
        //                     //    }
        //                     //    else
        //                     //    {
        //                     //        // objwaitlist = objwaitlist.Where(x => x.mdc_id == null).ToList();
        //                     //        objwaitlist = objwaitlist.Where(x => countmdc == 0).ToList();
        //                     //    }
        //                     //}
        //                 }
        //                 else if (CurrentmrmCode.mrm_code == "DC")
        //                 {
        //                     char datagender = (Program.CurrentUser.mut_gender == null) ? 'Z' : Convert.ToChar(Program.CurrentUser.mut_gender);
        //                     //{//ถ้า Require Doctor
        //                     //objwaitlist = objwaitlist.Where(x => ((x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                     //                                     (x.PEDoc == null) || (x.PEDoc == 'N'))
        //                     //                                     && (x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                     //                                     (x.ReqDoc == 'Y' && x.ReqGender == datagender) ||
        //                     //                                     (x.ReqDoc == 'N')
        //                     //                                 ).ToList();

        //                     //objwaitlist = objwaitlist.Where(x => ((x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                     //                                   (x.PEDoc == null && ((x.countmdc > 0 && x.tprid == Convert1.ToInt32(GetpatientInPatientCate.Contains(x.tprid))) || (x.countmdc == 0)) ||
        //                     //                                   (x.PEDoc == 'N' && ((x.countmdc > 0 && x.tprid == Convert1.ToInt32(GetpatientInPatientCate.Contains(x.tprid))) || (x.countmdc == 0))))
        //                     //                                   && (x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                     //                                   (x.ReqDoc == 'Y' && x.ReqGender == datagender) ||
        //                     //                                   (x.ReqDoc == 'N' && ((x.countmdc > 0 && x.tprid == Convert1.ToInt32(GetpatientInPatientCate.Contains(x.tprid))) || (x.countmdc == 0)))
        //                     //                               )).ToList();

        //                     if (Program.CurrentSite.mhs_code == "01CHK")
        //                     {
        //                         /*if (doc_call == true)
        //                         {
        //                             //objwaitlist = objwaitlist.Where(x => 1 == 1).ToList();

        //                             objwaitlist = objwaitlist.Where(x => ((x.OutDocCode == false && x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                                 (x.OutDocCode == false && x.PEDoc == null && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0)) ||
        //                                                                 (x.OutDocCode == false && x.PEDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))))
        //                                                                 && ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                                 ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender) ||
        //                                                                 ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))) ||
        //                                                                 (x.OutDocCode == true && x.type_PE == "Y") ||
        //                                                                (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                                (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender)
        //                                                             )).ToList();
        //                         }
        //                         else
        //                         {
        //                             //objwaitlist = objwaitlist.Where(x => 1 == 2).ToList();
        //                             objwaitlist = objwaitlist.Where(x => (
        //                                                         (x.PEDocCode != null && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                         (x.DocCode != null && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                         (x.countmdc > 0 && x.mdc_flag > 0)
        //                                                         )).ToList();
        //                         }*/

        //                         objwaitlist = objwaitlist.Where(x => ((x.OutDocCode == false && x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                              ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                              ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender) ||
        //                                                              (x.OutDocCode == true && x.type_PE == "Y") ||
        //                                                              (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                              (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender)
        //                                                             )).ToList();
        //                     }
        //                     else if (Program.CurrentSite.mhs_code == "01HPC2")
        //                     {
        //                         /*objwaitlist = objwaitlist.Where(x => ((x.OutDocCode == false && x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                             (x.OutDocCode == false && x.PEDoc == null && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0)) ||
        //                                                             (x.OutDocCode == false && x.PEDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))))
        //                                                             && ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                             ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender) ||
        //                                                             ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))) ||
        //                                                             (x.OutDocCode == true && x.type_PE == "Y") ||
        //                                                             (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                             (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender)
        //                                                         )).ToList();*/

        //                         objwaitlist = objwaitlist.Where(x => ((x.OutDocCode == false && x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                               (x.OutDocCode == false && x.PEDoc == 'N' && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                               (x.OutDocCode == false && x.PEDoc == 'N' && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender) ||
        //                                                               (x.OutDocCode == false && x.PEDoc == 'N' && x.DocCode == null && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))) ||
        //                                                               (x.OutDocCode == true && x.type_PE == "Y") ||
        //                                                               (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                               (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender)
        //                                                         )).ToList();

        //                         objwaitlist = objwaitlist.OrderBy(x => x.bmSeq).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.type_PE).ThenBy(x => x.ordDate).ToList();
        //                     }
        //                     else
        //                     {
        //                         /*objwaitlist = objwaitlist.Where(x => ((x.OutDocCode == false && x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                        (x.OutDocCode == false && x.PEDoc == null && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0)) ||
        //                                                        (x.OutDocCode == false && x.PEDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))))
        //                                                        && ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                        ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender) ||
        //                                                        ((x.PEDoc == 'N' || x.PEDoc == null) && x.OutDocCode == false && x.ReqDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))) ||
        //                                                        (x.OutDocCode == true && x.type_PE == "Y") ||
        //                                                         (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                         (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender)
        //                                                    )).ToList();*/

        //                         objwaitlist = objwaitlist.Where(x => ((x.OutDocCode == false && x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                               (x.OutDocCode == false && x.PEDoc == 'N' && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                               (x.OutDocCode == false && x.PEDoc == 'N' && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender) ||
        //                                                               (x.OutDocCode == false && x.PEDoc == 'N' && x.DocCode == null && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))) ||
        //                                                               (x.OutDocCode == true && x.type_PE == "Y") ||
        //                                                               (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                               (x.OutDocCode == true && x.type_PE == "N" && x.ReqDoc == 'Y' && x.DocCode == null && x.ReqGender == datagender)
        //                                                         )).ToList();

        //                         objwaitlist = objwaitlist.OrderBy(x => x.bmSeq).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.type_PE).ThenBy(x => x.ordDate).ToList();
        //                     }

        //                     /*objwaitlist = objwaitlist.Where(x => ((x.PEDoc == 'Y' && x.PEDocCode == Program.CurrentUser.mut_username) ||
        //                                                        (x.PEDoc == null && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0)) ||
        //                                                        (x.PEDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0))))
        //                                                        && (x.ReqDoc == 'Y' && x.DocCode == Program.CurrentUser.mut_username) ||
        //                                                        (x.ReqDoc == 'Y' && x.ReqGender == datagender) ||
        //                                                        (x.ReqDoc == 'N' && ((x.countmdc > 0 && x.mdc_flag > 0) || (x.countmdc == 0)))
        //                                                    )).ToList();*/
        //                 }
        //                 else if (CurrentmrmCode.mrm_code == "EM")
        //                 {//ถ้า เป็น Eye ให้แยกตาม Type mvt_id
        //                     string strCode = "";
        //                     if (Program.CurrentRoom.mrd_type == 'D')
        //                     {
        //                         strCode = "EM";
        //                     }
        //                     else if (Program.CurrentRoom.mrd_type == 'N')
        //                     {
        //                         strCode = "EN";
        //                     }
        //                     var currentEvent = (from t1 in dbc.mst_events
        //                                         where t1.mvt_code == strCode
        //                                         select t1).FirstOrDefault();
        //                     if (currentEvent != null)
        //                     {
        //                         objwaitlist = objwaitlist.Where(x => x.mvtID == currentEvent.mvt_id).ToList();
        //                     }
        //                 }
        //                 else if (CurrentmrmCode.mrm_code == "TE")
        //                 {//ถ้า เป็น Teeth ให้แยกตาม Type mvt_id
        //                     string strCode = "";
        //                     if (Program.CurrentRoom.mrd_type == 'T')
        //                     {
        //                         strCode = "TX";
        //                     }
        //                     else if (Program.CurrentRoom.mrd_type == 'D')
        //                     {
        //                         strCode = "TE";
        //                     }
        //                     var currentEvent = (from t1 in dbc.mst_events
        //                                         where t1.mvt_code == strCode
        //                                         select t1).FirstOrDefault();
        //                     if (currentEvent != null)
        //                     {
        //                         objwaitlist = objwaitlist.Where(x => x.mvtID == currentEvent.mvt_id).ToList();
        //                     }
        //                 }
        //                 else if (CurrentmrmCode.mrm_code == "UU")
        //                 {
        //                     //objwaitlist = objwaitlist.OrderBy(x => x.bmSeq).ThenByDescending(x => x.type_Lower).ThenByDescending(x => x.hold_flag).ThenBy(x => x.ordDate).ToList();

        //                     if (Program.CurrentSite.mhs_code == "01CHK")
        //                     {
        //                         objwaitlist = objwaitlist.OrderBy(x => x.bmSeq).ThenByDescending(x => x.type_Lower).ThenByDescending(x => x.hold_flag).ThenBy(x => x.ordDate).ToList();
        //                     }
        //                     else
        //                     {
        //                         objwaitlist = objwaitlist.OrderBy(x => x.bmSeq).ThenByDescending(x => x.type_Lower).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.ordDate).ToList();
        //                     }
        //                 }
        //             }

        //             //****************************
        //             GridWaitingList.DataSource = new SortableBindingList<waitinglist>(objwaitlist.Select((item, index) => new waitinglist
        //             {
        //                 NO = index + 1,
        //                 Callstatus=item.Callstatus,
        //                 QueueNo = item.QueueNo,
        //                 HN = item.HN,
        //                 FullName = item.FullName,
        //                 tpr_id = item.tprid,
        //                 hilight = item.hilight
        //             }).ToList());
        //             lbTitle.Text = string.Format("Waiting List (Total {0} คน)", objwaitlist.Count());
        //             timer1.Start();// Stat Timer
        //         }
        //         catch (Exception ex)
        //         {
        //             Program.MessageError("UIWaitList", "LoadData", ex, false);
        //             timer1.Start();
        //         }
        //     }
        //}
        public void IsStatusED()
        {
            timer1.Stop();
            if (Program.IsViewHistory == false)
            {
                if (CallQueue.IsStatusED())
                {
                    OnRefreshStatusED();
                    //MessageBox.Show("Now Status Completed.");
                    Program.CurrentPatient_queue = null;
                }
            }
            timer1.Start();
        }
Exemple #5
0
        public CallQueue Save(CallQueue callQueue)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var entity = Mapper.Map <CallQueue, CallQueueEntity>(callQueue);

                if (!adapter.SaveEntity(entity, true))
                {
                    throw new PersistenceFailureException();
                }

                return(Mapper.Map <CallQueueEntity, CallQueue>(entity));
            }
        }
Exemple #6
0
        public void MultipleThreads()
        {
            int state     = 0;
            var callQueue = new CallQueue();
            var result    = new List <int>();
            var start     = false;
            Action <int, Func <bool> > concurrentAction = (int x, Func <bool> pred) => {
                using (callQueue.BlockUntil(pred)) {
                    Thread.Sleep(x);
                    result.Add(x);
                }
            };
            var threads = new Thread[100];

            for (var i = 0; i < 100; i++)
            {
                if (i == 0)
                {
                    var i1 = i;
                    threads[i] = new Thread(() => concurrentAction(i1 + 1, () => Volatile.Read(ref start)));
                }
                else
                {
                    var i1 = i;
                    threads[i] = new Thread(() => concurrentAction(i1 + 1, () => true));
                }
            }

            foreach (var thread in threads)
            {
                thread.Start();
                Thread.Sleep(1);
            }

            Thread.Sleep(100);
            Assert.AreEqual(Enumerable.Empty <int>(), result);


            Volatile.Write(ref start, true);
            callQueue.Pulse();
            while (result.Count < 100)
            {
                Thread.Sleep(100);
            }
            Tools.NUnitTool.Print(result);
            Assert.AreEqual(Enumerable.Range(1, 100), result);
        }
Exemple #7
0
        public void PulseInMiddle()
        {
            var callQueue = new CallQueue();
            var result    = new List <int>();
            var start     = false;
            Action <int, Func <bool> > concurrentAction = (int x, Func <bool> pred) => {
                using (callQueue.BlockUntil(pred)) {
                    Thread.Sleep(x * 10);
                    result.Add(x);
                    if (x == 2)
                    {
                        Volatile.Write(ref start, false);
                    }
                }
            };
            var thread1 = new Thread(() => concurrentAction(1, () => Volatile.Read(ref start)));
            var thread2 = new Thread(() => concurrentAction(2, () => true));
            var thread3 = new Thread(() => concurrentAction(3, () => Volatile.Read(ref start)));
            var thread4 = new Thread(() => concurrentAction(4, () => true));

            thread1.Start();
            Thread.Sleep(1);
            thread2.Start();
            Thread.Sleep(1);
            thread3.Start();
            Thread.Sleep(1);
            thread4.Start();
            Thread.Sleep(1);

            // Everything should be blocked
            Thread.Sleep(100);
            Assert.AreEqual(Enumerable.Empty <int>(), result);

            // Allow first two threads in
            Volatile.Write(ref start, true);
            callQueue.Pulse();
            Thread.Sleep(100);
            Assert.AreEqual(new[] { 1, 2 }, result.ToArray());

            // Allow last two threads in
            Volatile.Write(ref start, true);
            callQueue.Pulse();
            Thread.Sleep(100);
            Assert.AreEqual(new[] { 1, 2, 3, 4 }, result.ToArray());
        }
Exemple #8
0
 private StatusTransaction callLab(int tpr_id)
 {
     try
     {
         using (InhCheckupDataContext cdc = new InhCheckupDataContext())
         {
             trn_patient_regi tpr = cdc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault();
             int tpt_id           = tpr.tpt_id;
             CallQueue.CallLab(tpt_id, tpr_id);
             return(StatusTransaction.True);
         }
     }
     catch (Exception ex)
     {
         Program.MessageError("SendQueue", "callLab", ex, false);
         return(StatusTransaction.Error);
     }
 }
Exemple #9
0
        private void btnCallQueue_Click(object sender, EventArgs e)
        {
            DisableBtnAll();
            this.AutoScrollPosition = new Point(0, 0);

            frmBGScreen frmbg = new frmBGScreen();

            frmbg.Show();
            try
            {
                //noina
                StatusTransaction callQ = CallQueue.P_CallQueueWaitReady();
                //end noina

                if (callQ == StatusTransaction.Error)
                {
                    lbAlertMsg.Text      = "กรุณากด Call Queue อีกครั้ง";
                    btnCallQueue.Enabled = true;
                }
                else
                {
                    if (Program.CurrentRegis != null)
                    {
                        this.tpr_id = Program.CurrentRegis.tpr_id;
                        clsCountDown.startCountDown(0, clsCountDown.GetTimeCountDown());
                        StatusNSWR();
                    }
                    else
                    {
                        lbAlertMsg.Text = "No patient on queue!";
                        StatusEmptyRoom();
                    }
                }
            }
            catch (Exception ex)
            {
                Program.MessageError(this.Name, "btnCallQueue_Click", ex, false);
            }
            finally
            {
                frmbg.Close();
            }
        }
        public VulkanRenderer(CreateFlags flags, VulkanRendererParams @params, Vk vk)
        {
            _flags = flags;
            Vk     = vk;
            Params = @params;

            _vertexCollection = new VertexCollection();
            _callQueue        = new CallQueue();

            _frames = new Frame[Params.FrameCount];

            CurrentFrameIndex             = 0;
            CurrentCommandBuffer          = Params.InitialCommandBuffer;
            _requireredDescriptorSetCount = 0;

            VulkanRenderExtensionMethodContainer.VulkanRenderer = this;

            TextureManager = new TextureManager(this);
        }
Exemple #11
0
        public ExcludedCustomerListModel SetHeaderData(OutboundCallQueueFilter filter, ExcludedCustomerListModel model)
        {
            var       organization = _organizationRepository.GetOrganizationbyId(filter.HealthPlanId);
            CallQueue callQueue    = null;
            var       criteria     = _healthPlanCallQueueCriteriaRepository.GetById(filter.CriteriaId);

            callQueue = _callQueueRepository.GetById(filter.CallQueueId > 0 ? filter.CallQueueId : criteria.CallQueueId);
            var criteriaName = string.Empty;

            if (filter.CampaignId.HasValue && filter.CampaignId.Value > 0)
            {
                var campagin = _campaignRepository.GetById(filter.CampaignId.Value);
                criteriaName = campagin.Name;
            }

            model.CallQueueType   = callQueue.Name;
            model.HealthPlanName  = organization.Name;
            model.SuppressionType = filter.SuppressionType.GetDescription();
            model.CriteriaName    = string.IsNullOrEmpty(criteria.CriteriaName) ? criteriaName : criteria.CriteriaName;

            return(model);
        }
Exemple #12
0
        public void ChangeAssignmentOfExistingQueue(CallQueue queue, IEnumerable <CallQueueAssignment> callQueueAssignments)
        {
            var callQueueCustomerIds = _callQueueCustomerRepository.GetCallQueueCustomerIdsByCallQueueIdAndStatus(queue.Id, CallQueueStatus.Initial);

            if (callQueueCustomerIds != null && callQueueCustomerIds.Any())
            {
                var totalRecords = callQueueCustomerIds.Count();

                var callDivisions = (from ca in callQueueAssignments
                                     let count = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalRecords * ca.Percentage) / 100))
                                                 select new
                {
                    AssignedTo = ca.AssignedOrgRoleUserId,
                    callCount = count > 0 ? count : 1
                }).ToList();

                int endCount = 0;
                foreach (var callDivision in callDivisions)
                {
                    var       queuecustomerIds = callQueueCustomerIds.Skip(endCount).Take(callDivision.callCount).ToArray();
                    const int pageSize         = 50;
                    int       pageNumber       = 1;
                    while (true)
                    {
                        var assignedCallQueueCustomerIds = queuecustomerIds.Skip((pageNumber - 1) * pageSize).Take(pageSize);
                        _callQueueCustomerRepository.UpdateAssignment(assignedCallQueueCustomerIds, callDivision.AssignedTo);

                        if ((pageNumber * pageSize) >= callDivision.callCount)
                        {
                            break;
                        }

                        pageNumber++;
                    }
                    endCount = endCount + callDivision.callCount;
                }
            }
        }
Exemple #13
0
        private void addDataGridStation()
        {
            var objview = (from t1 in dbc.vw_patient_rooms
                           where t1.mhs_id == Program.CurrentSite.mhs_id &&
                           t1.tpr_id == Program.CurrentRegis.tpr_id
                           //&& t1.site_rm == Program.CurrentSite.mhs_id
                           //&& t1.mvt_type_cate == 'M'
                           && t1.mvt_type_cate ==
                           (CallQueue.GetUltrasound_Type(Program.CurrentRegis.tpr_id, Program.CurrentSite.mhs_id) == true ||
                            (t1.mvt_code != "UL" && t1.mvt_code != "UB" && t1.mvt_code != "UW") ? 'M' : t1.mvt_type_cate)
                           select new
            {
                t1.mvt_id,
                t1.mrm_id,
                t1.mhs_ename,
                t1.mze_ename,
                t1.mrm_ename,
                t1.waiting_person,
                t1.waiting_time
            }).ToList();

            gridStation.DataSource = objview;
        }
Exemple #14
0
        public void TwoThreads()
        {
            int state     = 0;
            var callQueue = new CallQueue();
            var result    = new List <int>();
            var start     = false;
            Action <int, Func <bool> > concurrentAction = (int x, Func <bool> pred) => {
                using (callQueue.BlockUntil(pred)) {
                    result.Add(x);
                }
            };
            var thread1 = new Thread(() => concurrentAction(1, () => Volatile.Read(ref start)));
            var thread2 = new Thread(() => concurrentAction(2, () => true));

            thread1.Start();
            Thread.Sleep(1);
            thread2.Start();
            Thread.Sleep(100);

            Volatile.Write(ref start, true);
            callQueue.Pulse();
            Thread.Sleep(200);
            Assert.AreEqual(new int[] { 1, 2 }, result.ToArray());
        }
Exemple #15
0
        public OutboundCallQueueListModel GetOutboundCallQueueUpsellAndConfirmation(OutboundCallQueueFilter filter, CallQueue callQueue, int pageSize, long criteriaId, out int totalRecords)
        {
            var callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomerForUpsellAndConfirmation(filter, filter.PageNumber, pageSize, callQueue, criteriaId, out totalRecords);

            if (callQueueCustomers.IsNullOrEmpty())
            {
                return(null);
            }

            var eventIds    = callQueueCustomers.Where(x => x.EventId.HasValue).Select(x => x.EventId.Value).Distinct();
            var customerIds = callQueueCustomers.Where(cqc => cqc.CustomerId.HasValue && cqc.CustomerId.Value > 0).Select(cqc => cqc.CustomerId.Value).Distinct().ToArray();

            var eventCustomers = _eventCustomerRepository.GetByEventIds(eventIds);

            eventCustomers = eventCustomers.Where(ec => customerIds.Contains(ec.CustomerId));

            var orgRoleUserIds = eventCustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList();

            var registeredbyAgent = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);

            var roles = _roleRepository.GetAll();

            // var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray();

            var appointment = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value));

            var events = _eventRepository.GetEventswithPodbyIds(eventIds).ToList();
            var hosts  = _hostRepository.GetEventHosts(eventIds).ToList();
            var pods   = _podRepository.GetPodsForEvents(eventIds);

            IEnumerable <Customer> customers = _customerRepository.GetCustomers(customerIds);

            var callQueueCustomerCalls = _callCenterCallRepository.GetCallForCallQueueCustomerList(customerIds, null);
            IEnumerable <CallCenterNotes> callCenterNotes = null;

            if (callQueueCustomerCalls != null && callQueueCustomerCalls.Any())
            {
                callCenterNotes = _callCenterNotesRepository.GetByCallIds(callQueueCustomerCalls.Select(s => s.CallId));
            }

            return(_outboundCallQueueListModelFactory.CallQueueCustomersForUpsellAndConfimration(callQueueCustomers, customers, callQueueCustomerCalls, callCenterNotes, events, hosts, pods, appointment, eventCustomers, registeredbyAgent, roles));
        }
Exemple #16
0
        public OutboundCallQueueListModel GetOutboundCallQueueListModel(OutboundCallQueueFilter filter, CallQueue callQueue, int pageSize, long criteriaId, out int totalRecords)
        {
            IEnumerable <CallQueueCustomer> callQueueCustomers;

            if (callQueue.Category == CallQueueCategory.FillEvents)
            {
                callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomerForFillEvents(filter, filter.PageNumber, pageSize, criteriaId, out totalRecords);
            }
            else
            {
                callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomerForZipCode(filter, filter.PageNumber, pageSize, out totalRecords);
            }


            if (callQueueCustomers.IsNullOrEmpty())
            {
                return(null);
            }

            var customerIds = callQueueCustomers.Where(cqc => cqc.CustomerId.HasValue && cqc.CustomerId.Value > 0).Select(cqc => cqc.CustomerId.Value).ToArray();
            IEnumerable <Customer> customers = null;

            if (customerIds.Any())
            {
                customerIds = customerIds.Distinct().ToArray();
                customers   = _customerRepository.GetCustomers(customerIds);
            }

            var prospectCustomerIds = callQueueCustomers.Where(cqc => cqc.ProspectCustomerId.HasValue && cqc.ProspectCustomerId.Value > 0).Select(cqc => cqc.ProspectCustomerId.Value).Distinct().ToArray();//&& !cqc.CustomerId.HasValue

            var prospectCustomers = _prospectCustomerRepository.GetProspectCustomers(prospectCustomerIds);

            var callQueueCustomerCalls = _callCenterCallRepository.GetCallForCallQueueCustomerList(customerIds, prospectCustomerIds);
            IEnumerable <CallCenterNotes> callCenterNotes = null;

            if (callQueueCustomerCalls != null && callQueueCustomerCalls.Any())
            {
                callCenterNotes = _callCenterNotesRepository.GetByCallIds(callQueueCustomerCalls.Select(s => s.CallId));
            }

            return(_outboundCallQueueListModelFactory.SystemGeneratedCallQueueCustomers(callQueueCustomers, customers, prospectCustomers, callQueueCustomerCalls, callCenterNotes, null, null, null));
        }
Exemple #17
0
        private void btnSendAuto_Click(object sender, EventArgs e)
        {
            DisableBtnAll();
            DateTime startDate = DateTime.Now;

            this.AutoScrollPosition = new Point(0, 0);
            List <int> mvt_id = new List <int>();

            if (uu.enable && uu.visible && uu.check && uu.autoCheck)
            {
                mvt_id.Add(uu.mvt_id);
            }
            if (ul.enable && ul.visible && ul.check && ul.autoCheck)
            {
                mvt_id.Add(ul.mvt_id);
            }
            if (ub.enable && ub.visible && ub.check && ub.autoCheck)
            {
                mvt_id.Add(ub.mvt_id);
            }
            if (uw.enable && uw.visible && uw.check && uw.autoCheck)
            {
                mvt_id.Add(uw.mvt_id);
            }
            if (mvt_id.Count() == 0)
            {
                lbAlertMsg.Text = "กรุณาเลือก Order ที่ต้องการตรวจเพิ่มอย่างน้อย 1 รายการ";
                StatusWK();
            }
            else
            {
                if (CheckMinLower())
                {
                    if (SkipLower())
                    {
                        Class.FunctionDataCls     func = new Class.FunctionDataCls();
                        EmrClass.GetDataMasterCls mst  = new EmrClass.GetDataMasterCls();
                        frmBGScreen frmbg = new frmBGScreen();
                        frmbg.Show();
                        Application.DoEvents();
                        try
                        {
                            if (new Class.FunctionDataCls().ChkSendAutoNewModule(Program.CurrentRegis))
                            {
                                string msgAlert = "";
                                bool   isPopup  = false;
                                QueueClass.SendAutoCls.ResultSendQueue result = new QueueClass.SendAutoCls().SendAuto((int)tps_id, mvt_id, user, ref msgAlert, ref isPopup);
                                if (result == QueueClass.SendAutoCls.ResultSendQueue.Error)
                                {
                                    lbAlertMsg.Text = msgAlert;
                                    StatusWK();
                                }
                                else if (result == QueueClass.SendAutoCls.ResultSendQueue.OldRoom)
                                {
                                    lbAlertMsg.Text = msgAlert;
                                    StatusWK();
                                }
                                else
                                {
                                    lbAlertMsg.Visible = true;
                                    if (result == QueueClass.SendAutoCls.ResultSendQueue.SendComplete)
                                    {
                                        new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendAuto,
                                                                    (int)tpr_id,
                                                                    (int)tps_id,
                                                                    Program.CurrentSite.mhs_id,
                                                                    Program.CurrentRoom.mrd_ename,
                                                                    Program.CurrentUser.mut_username,
                                                                    startDate);

                                        new ClsTCPClient().sendClearUnitDisplay();
                                        new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                                        StatusEmptyRoom();
                                        this.tpr_id = null;
                                        if (isPopup)
                                        {
                                            MessageBox.Show(msgAlert, "EMR Checkup.");
                                        }
                                        else
                                        {
                                            lbAlertMsg.Text = msgAlert;
                                        }
                                    }
                                    else
                                    {
                                        if (isPopup)
                                        {
                                            MessageBox.Show(msgAlert, "EMR Checkup.");
                                        }
                                        else
                                        {
                                            lbAlertMsg.Text = msgAlert;
                                        }
                                    }
                                }
                                //using (Service.WS_Checkup ws = new Service.WS_Checkup())
                                //{
                                //    WS_PathWay.SendAutoResult result = ws.SendAuto((int)tps_id, mvt_id.ToArray(), user.mut_username, Program.CurrentSite.mhs_id);
                                //    if (result.SendResult == WS_PathWay.Result.Error)
                                //    {
                                //        lbAlertMsg.Text = result.AlertMsg;
                                //        StatusWK();
                                //    }
                                //    else
                                //    {
                                //        if (result.SendResult == WS_PathWay.Result.Complete)
                                //        {
                                //            new ClsTCPClient().sendClearUnitDisplay();
                                //            new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                                //            StatusEmptyRoom();
                                //            this.tpr_id = null;
                                //            lbAlertMsg.Text = result.AlertMsg;
                                //        }
                                //        else
                                //        {
                                //            lbAlertMsg.Text = result.AlertMsg;
                                //            StatusWK();
                                //        }
                                //    }
                                //}
                            }
                            else
                            {
                                StatusTransaction result = CallQueue.SendAutoOnStation(mvt_id);
                                if (result == StatusTransaction.True || result == StatusTransaction.SendCheckB)
                                {
                                    new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendAuto,
                                                                (int)tpr_id,
                                                                (int)tps_id,
                                                                Program.CurrentSite.mhs_id,
                                                                Program.CurrentRoom.mrd_ename,
                                                                Program.CurrentUser.mut_username,
                                                                startDate);

                                    new ClsTCPClient().sendClearUnitDisplay();
                                    lbAlertMsg.Visible = true;
                                    new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                                    lbAlertMsg.Text = new Class.FunctionDataCls().getStringGotoNextRoom((int)tpr_id);
                                    StatusEmptyRoom();
                                    this.tpr_id = null;
                                }
                                else if (result == StatusTransaction.Error)
                                {
                                    lbAlertMsg.Text = "โปรดกด Send Auto อีกครั้ง";
                                    StatusWK();
                                }
                                else if (result == StatusTransaction.False)
                                {
                                    lbAlertMsg.Text = "Save Data Complete.";
                                    StatusWK();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            lbAlertMsg.Text = ex.Message;
                            StatusWK();
                        }
                        finally
                        {
                            frmbg.Close();
                        }
                    }
                    else
                    {
                        StatusWK();
                    }
                }
                else
                {
                    StatusWK();
                }
            }
        }
        public ListModelBase <MailRoundCustomersReportViewModel, OutboundCallQueueFilter> GetCustomersForMatrixReport(int pageNumber, int pageSize, OutboundCallQueueFilter filter, CallQueue callQueue, out int totalRecords)
        {
            totalRecords = 0;
            MailRoundCustomersListModel model       = null;
            IEnumerable <long>          customerIds = null;

            if (callQueue.Category == HealthPlanCallQueueCategory.MailRound)
            {
                customerIds = _callQueueCustomerRepository.GetMailRoundCustomerIdsForMatrixReport(filter, callQueue, pageNumber, pageSize, out totalRecords);
            }
            else if (callQueue.Category == HealthPlanCallQueueCategory.FillEventsHealthPlan)
            {
                customerIds = _callQueueCustomerRepository.GetFillEventCustomerIDsForMatrixReport(filter, callQueue, pageNumber, pageSize, out totalRecords);
            }
            else if (callQueue.Category == HealthPlanCallQueueCategory.LanguageBarrier)
            {
                customerIds = _callQueueCustomerRepository.GetLanguageBarrierCustomerIDsForMatrixReport(filter, callQueue, pageNumber, pageSize, out totalRecords);
            }

            if (!customerIds.IsNullOrEmpty())
            {
                var startOfYear = new DateTime(DateTime.Now.Year, 1, 1);
                var customers   = _customerRepository.GetCustomers(customerIds.ToArray());
                var directMails = _directMailRepository.GetByCustomerIds(customerIds, startOfYear);
                var callDetails = _callCenterCallRepository.GetCallsByCustomerIds(customerIds, fromDate: startOfYear, isOutbound: true);
                var customTags  = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds, startOfYear);

                model = _mailRoundCustomersReportFactory.Create(customers, callDetails, directMails, customTags);
            }

            model        = model ?? new MailRoundCustomersListModel();
            model.Filter = filter;

            return(model);
        }
        public PreAssessmentCustomerContactViewModel GetByCustomerId(long customerId, long callId, long orgRoleUserId)
        {
            if (customerId <= 0)
            {
                return(null);
            }
            var       call          = _callCenterCallRepository.GetById(callId);
            var       eventCustomer = _eventCustomerRepository.Get(call.EventId, customerId);
            CallQueue callQueue     = null;

            if (call != null)
            {
                callQueue = _callQueueRepository.GetById((long)call.CallQueueId);
            }
            var customer = _customerRepository.GetCustomer(customerId);

            var memberIdLabel = string.Empty;
            CorporateAccount    corporateAccount    = null;
            CustomerEligibility customerEligibility = null;

            if (customer != null)
            {
                customerEligibility = _customerEligibilityRepository.GetByCustomerIdAndYear(customer.CustomerId, DateTime.Today.Year);
                if (!string.IsNullOrEmpty(customer.Tag))
                {
                    corporateAccount = _corporateAccountRepository.GetByTag(customer.Tag);
                    memberIdLabel    = corporateAccount != null ? corporateAccount.MemberIdLabel : string.Empty;
                }
            }

            var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId);
            CallQueuePatientInfomationViewModel patientInfo = null;

            if (customer != null)
            {
                Falcon.App.Core.Medical.Domain.ActivityType activityType = null;
                if (customer.ActivityId.HasValue)
                {
                    activityType = _activityTypeRepository.GetById(customer.ActivityId.Value);
                }

                patientInfo = _preAssessmentCallQueuePatientInfomationFactory.SetCustomerInfo(customer, customerEligibility, activityType);
            }
            else
            {
                patientInfo = _preAssessmentCallQueuePatientInfomationFactory.SetProspectCustomerInfo(prospectCustomer);
            }


            if (patientInfo.HealthPlanPhoneNumber == null)
            {
                patientInfo.HealthPlanPhoneNumber = corporateAccount != null ? corporateAccount.CheckoutPhoneNumber : null;
            }
            var additionalFileds = new List <OrderedPair <string, string> >();

            if (corporateAccount != null)
            {
                var accountAdditionalFields = _accountAdditionalFieldRepository.GetByAccountId(corporateAccount.Id);
                if (accountAdditionalFields.Any())
                {
                    additionalFileds.AddRange(accountAdditionalFields.Select(additionalField => new OrderedPair <string, string>(additionalField.DisplayName,
                                                                                                                                 GetCustomerAdditionalField(customer, additionalField.AdditionalFieldId))));
                }
                if (corporateAccount.ShowCallCenterScript && corporateAccount.CallCenterScriptFileId > 0)
                {
                    var callCenterScriptPdf = _fileRepository.GetById(corporateAccount.CallCenterScriptFileId);
                    var mediaLocation       = _mediaRepository.GetCallCenterScriptPdfFolderLocation();
                    patientInfo.CallCenterScriptUrl = mediaLocation.Url + callCenterScriptPdf.Path;
                }
                if (callQueue != null && callQueue.Category == HealthPlanCallQueueCategory.PreAssessmentCallQueue)
                {
                    if (corporateAccount.ShowCallCenterScript && corporateAccount.ConfirmationScriptFileId > 0)
                    {
                        var confirmationScriptPdf = _fileRepository.GetById(corporateAccount.ConfirmationScriptFileId);
                        var mediaLocation         = _mediaRepository.GetCallCenterScriptPdfFolderLocation();
                        patientInfo.CallCenterScriptUrl = mediaLocation.Url + confirmationScriptPdf.Path;
                    }
                }
            }
            var hasMammo = customer != null && _preApprovedTestRepository.CheckPreApprovedTestForCustomer(customer.CustomerId, TestGroup.BreastCancer);

            patientInfo.HasMammo = hasMammo;

            patientInfo.MammoTestAsPreApproved = hasMammo;

            patientInfo.CustomerId         = customerId;
            patientInfo.ProspectCustomerId = prospectCustomer != null ? prospectCustomer.Id : 0;

            patientInfo = _preAssessmentCallQueuePatientInfomationFactory.SetCustomerTagInfo(prospectCustomer, patientInfo);

            if (patientInfo != null && callQueue != null && callQueue.IsHealthPlan)
            {
                patientInfo.PrimaryCarePhysician = _primaryCarePhysicianHelper.GetPrimaryCarePhysicianViewModel(customerId);
            }

            if (customer != null)
            {
                var customerCustomTags = _corporateCustomerCustomTagRepository.GetByCustomerId(customer.CustomerId);
                if (!customerCustomTags.IsNullOrEmpty())
                {
                    var customTags = customerCustomTags.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Select(x => x.Tag).ToArray();
                    patientInfo.CustomCorporateTags = customTags.IsNullOrEmpty() ? string.Empty : string.Join(",", customTags);
                }
            }

            IEnumerable <string> preApprovedTests = null;
            var preApprovedTestsList = _preApprovedTestRepository.GetPreApprovedTests(customerId);

            if (preApprovedTestsList.Count() > 0)
            {
                preApprovedTests = preApprovedTestsList;
            }

            IEnumerable <Package> preApprovedPackages = null;
            var preApprovedPackageList = _preApprovedPackageRepository.GetByCustomerId(customerId);
            var packageIds             = preApprovedPackageList != null?preApprovedPackageList.Select(x => x.PackageId) : null;

            if (packageIds != null)
            {
                preApprovedPackages = _packageRepository.GetByIds(packageIds.ToList());
            }

            if (customer != null && customer.Address != null && customer.Address.StateId > 0 && corporateAccount != null)
            {
                patientInfo.HealthPlanPhoneNumber = _customerAccountGlocomNumberService.GetGlocomNumber(corporateAccount.Id, customer.Address.StateId, customer.CustomerId, callId);
            }

            if (patientInfo.HealthPlanPhoneNumber == null)
            {
                patientInfo.HealthPlanPhoneNumber = corporateAccount != null ? corporateAccount.CheckoutPhoneNumber : null;
            }

            if (patientInfo.HealthPlanPhoneNumber != null)
            {
                string dialerUrl;
                var    callCenterRepProfile = _callCenterRepProfileRepository.Get(orgRoleUserId);
                if (callCenterRepProfile != null && !string.IsNullOrEmpty(callCenterRepProfile.DialerUrl))
                {
                    dialerUrl = callCenterRepProfile.DialerUrl.ToLower().Replace(CallCenterAgentUrlKeywords.CallerId.ToLower(), (patientInfo.HealthPlanPhoneNumber.AreaCode + patientInfo.HealthPlanPhoneNumber.Number))
                                .Replace(CallCenterAgentUrlKeywords.PatientId.ToLower(), patientInfo.CustomerId.ToString());
                }
                else
                {
                    dialerUrl = "Glocom://*65*" + patientInfo.HealthPlanPhoneNumber.AreaCode + patientInfo.HealthPlanPhoneNumber.Number + "*1" + CallCenterAgentUrlKeywords.PatientContact.ToLower();
                }

                if (patientInfo.CallBackPhoneNumber != null)
                {
                    patientInfo.CallBackPhoneNumberUrl = dialerUrl.Replace(CallCenterAgentUrlKeywords.PatientContact.ToLower(), (patientInfo.CallBackPhoneNumber.AreaCode + patientInfo.CallBackPhoneNumber.Number));
                }

                if (patientInfo.OfficePhoneNumber != null)
                {
                    patientInfo.OfficePhoneNumberUrl = dialerUrl.Replace(CallCenterAgentUrlKeywords.PatientContact.ToLower(), (patientInfo.OfficePhoneNumber.AreaCode + patientInfo.OfficePhoneNumber.Number));
                }

                if (patientInfo.MobilePhoneNumber != null && !string.IsNullOrEmpty(patientInfo.MobilePhoneNumber.Number))
                {
                    patientInfo.MobilePhoneNumberUrl = dialerUrl.Replace(CallCenterAgentUrlKeywords.PatientContact.ToLower(), (patientInfo.MobilePhoneNumber.AreaCode + patientInfo.MobilePhoneNumber.Number));
                }
            }

            var preAssessmentCustomerCallQueueCallAttempt = _preAssessmentCustomerCallQueueCallAttemptRepository.GetByCallId(callId);

            RegisteredEventViewModel registeredEventModel = null;
            var isCancelled = false;

            if (callQueue != null && callQueue.Category == HealthPlanCallQueueCategory.PreAssessmentCallQueue && call.EventId > 0)
            {
                var         isEawvPurchased = _testResultService.IsTestPurchasedByCustomer(eventCustomer.Id, (long)TestType.eAWV);
                Appointment appointment     = null;
                if (eventCustomer.AppointmentId.HasValue)
                {
                    appointment = _appointmentRepository.GetById(eventCustomer.AppointmentId.Value);
                }
                else
                {
                    isCancelled = true;
                }

                var theEvent = _eventService.GetById(eventCustomer.EventId);

                var hostAddress = new AddressViewModel
                {
                    StreetAddressLine1 = theEvent.StreetAddressLine1,
                    StreetAddressLine2 = theEvent.StreetAddressLine2,
                    City    = theEvent.City,
                    State   = theEvent.State,
                    ZipCode = theEvent.Zip
                };

                QuestionnaireType questionnaireType = QuestionnaireType.None;
                if (corporateAccount != null && corporateAccount.IsHealthPlan && theEvent != null)
                {
                    questionnaireType = _accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(corporateAccount.Id, theEvent.EventDate);
                }

                registeredEventModel = new RegisteredEventViewModel
                {
                    EventId             = theEvent.EventId,
                    EventDate           = theEvent.EventDate,
                    AppointmentTime     = appointment != null ? appointment.StartTime : (DateTime?)null,
                    HostName            = theEvent.OrganizationName,
                    HostAddress         = hostAddress.ToString(),
                    EventNotes          = "",
                    EventCustomerId     = eventCustomer.Id,
                    TimeZone            = theEvent.EventTimeZone,
                    IsCanceled          = isCancelled,
                    HraQuestionerAppUrl = _settings.HraQuestionerAppUrl,
                    OrganizationNameForHraQuestioner = _settings.OrganizationNameForHraQuestioner,
                    CorporateAccountTag = corporateAccount.Tag,
                    MedicareVisitId     = eventCustomer.AwvVisitId.HasValue ? eventCustomer.AwvVisitId.Value : 0,
                    Pods = theEvent.Pods.IsNullOrEmpty() ? "" : theEvent.PodNames(),
                    ShowHraQuestionnaire = questionnaireType == QuestionnaireType.HraQuestionnaire ? true : false,
                    IsEawvPurchased      = isEawvPurchased,

                    ShowChatQuestionnaire = questionnaireType == QuestionnaireType.ChatQuestionnaire ? true : false,
                    ChatQuestionerAppUrl  = _settings.ChatQuestionerAppUrl,
                    AllowNonMammoPatients = theEvent.AllowNonMammoPatients,
                    CaptureHaf            = corporateAccount != null && corporateAccount.CaptureHaf,
                };

                preAssessmentCustomerCallQueueCallAttempt.IsNotesReadAndUnderstood = true;
            }
            if (corporateAccount != null)
            {
                var organization = _organizationRepository.GetOrganizationbyId(corporateAccount.Id);
                patientInfo.HealthPlan = organization.Name;
            }

            var warmTransfer = false;

            if (customer != null && corporateAccount != null && corporateAccount.WarmTransfer)
            {
                var customerWarmTransfer = _customerWarmTransferRepository.GetByCustomerIdAndYear(customer.CustomerId, DateTime.Today.Year);
                warmTransfer = customerWarmTransfer != null && customerWarmTransfer.IsWarmTransfer.HasValue && customerWarmTransfer.IsWarmTransfer.Value;
            }

            var model = new PreAssessmentCustomerContactViewModel
            {
                PatientInfomation = patientInfo,
                // CallHistory = callHistoryModel,
                PreApprovedTests = preApprovedTests,
                //    ReadAndUnderstood = currentCall != null && currentCall.ReadAndUnderstood.HasValue && currentCall.ReadAndUnderstood.Value,
                AdditionalFields = additionalFileds,
                MemberIdLabel    = memberIdLabel,
                //  IsCallEnded = currentCall != null && currentCall.Status == (long)CallStatus.CallSkipped && currentCall.EndTime.HasValue,
                PreApprovedPackages = !preApprovedPackages.IsNullOrEmpty() ? preApprovedPackages.Select(x => x.Name).ToList() : null,
                CallId                   = callId,
                HealthPlanId             = corporateAccount != null ? corporateAccount.Id : 0,
                CallQueueCustomerAttempt = preAssessmentCustomerCallQueueCallAttempt ?? new PreAssessmentCustomerCallQueueCallAttempt {
                    IsNotesReadAndUnderstood = true
                },
                EventInformation = registeredEventModel,
                WarmTransfer     = warmTransfer,
                // RequiredTests = requiredTests,
            };
            var isHealthPlanCallQueue = call != null;
            var patientInfoEditModel  = _preAssessmentCallQueuePatientInfomationFactory.GetCallQueueCustomerEditModel(model, isHealthPlanCallQueue);

            model.PatientInfoEditModel     = patientInfoEditModel;
            model.PatientInfoEditViewModel = patientInfoEditModel;
            return(model);
        }
        private long SaveCallQueueCustomerDetailAndGetCallId(Customer customer, CallQueue callQueue, long orgRoleUserId, long callId, long dialerType, long eventId = 0)
        {
            var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customer.CustomerId);

            var _event       = _eventRepository.GetById(eventId);
            var HealthPlanId = _eventRepository.GetById(eventId) != null?_eventRepository.GetById(eventId).AccountId : null;

            long?prospectCustomerId_ = null;

            if (prospectCustomer != null)
            {
                prospectCustomerId_ = prospectCustomer.Id;
            }

            using (var scope = new TransactionScope())
            {
                //lock customer in call queue so that other agent not be able to call them;
                var domain = new PreAssessmentCallQueueCustomerLock
                {
                    CustomerId         = customer.CustomerId,
                    ProspectCustomerId = prospectCustomerId_,
                    CreatedBy          = orgRoleUserId,
                    CreatedOn          = DateTime.Now
                };
                _preAssessmentCallQueueCustomerLockRepository.SavePreAssessmentCallQueueCustomerLock(domain);
                var customerId = customer != null ? customer.CustomerId : 0;

                var prospectCustomerId     = prospectCustomerId_ != null ? (long)prospectCustomerId_ : 0;
                var organizationRoleUserId = orgRoleUserId;
                var callStatus             = customerId > 0 ? CallType.Existing_Customer.ToString().Replace("_", " ") : CallType.Register_New_Customer.ToString().Replace("_", " ");

                PhoneNumber glocomNumber = null;

                if (customer != null && customer.Address != null && HealthPlanId > 0)
                {
                    glocomNumber = _customerAccountGlocomNumberService.GetGlocomNumber((long)HealthPlanId, customer.Address.StateId, customerId);

                    if (glocomNumber == null)
                    {
                        var corporateAccount = _corporateAccountRepository.GetByTag(customer.Tag);
                        glocomNumber = corporateAccount != null ? corporateAccount.CheckoutPhoneNumber : null;
                    }
                }

                var incomingPhoneLine = glocomNumber != null ? glocomNumber.AreaCode + glocomNumber.Number : "";

                callId = _outboundCallQueueService.SetCallDetail(organizationRoleUserId, customerId, incomingPhoneLine, "", callStatus, null,
                                                                 HealthPlanId, "", callQueue.Id, callId, true, dialerType: dialerType, callQueueCategory: callQueue.Category, eventId: eventId, ProductTypeId: customer.ProductTypeId);

                if (customerId == 0 && prospectCustomerId > 0)
                {
                    UpdateContactedInfo(prospectCustomerId, callId, orgRoleUserId);
                }
                else if (customerId > 0)
                {
                    if (!(callQueue.Category == CallQueueCategory.Upsell || callQueue.Category == CallQueueCategory.PreAssessmentCallQueue))
                    {
                        if (prospectCustomer == null && customer != null)
                        {
                            prospectCustomer = _prospectCustomerFactory.CreateProspectCustomerFromCustomer(customer, false);
                            prospectCustomer = ((IUniqueItemRepository <ProspectCustomer>)_prospectCustomerRepository).Save(prospectCustomer);
                        }
                        if (prospectCustomer != null)
                        {
                            UpdateContactedInfo(prospectCustomer.Id, callId, orgRoleUserId);
                        }
                    }
                }
                var customerCallQueueCallAttempt = new PreAssessmentCustomerCallQueueCallAttempt
                {
                    DateCreated              = DateTime.Now,
                    IsCallSkipped            = false,
                    IsNotesReadAndUnderstood = true,
                    CreatedBy             = orgRoleUserId,
                    CustomerId            = customerId,
                    CallId                = callId,
                    NotInterestedReasonId = null
                };

                _preAssessmentCustomerCallQueueCallAttemptRepository.Save(customerCallQueueCallAttempt, false);

                if (glocomNumber != null)
                {
                    var customerAccountGlocomNumber = new CustomerAccountGlocomNumber
                    {
                        CallId       = callId,
                        CustomerId   = customerId,
                        GlocomNumber = glocomNumber.AreaCode + glocomNumber.Number,
                        CreatedDate  = DateTime.Now,
                        IsActive     = true
                    };
                    _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber);
                }

                scope.Complete();
                return(callId);
            }
        }
Exemple #21
0
        public IEnumerable <GmsExcludedCustomerViewModel> GetGmsExcludedCustomers(OutboundCallQueueFilter filter, CallQueue callQueue)
        {
            var suppressionTypes = SuppressionFilterType.MaxAttempt.GetNameValuePairs();

            var organization = _organizationRepository.GetOrganizationbyId(filter.HealthPlanId);

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
            var collection = new List <GmsExcludedCustomerViewModel>();

            foreach (var suppressionType in suppressionTypes)
            {
                int totalRecords             = 0;
                var suppressionTypeCustomers = new List <GmsExcludedCustomerViewModel>();
                var pageNumber = 1;

                while (true)
                {
                    var excludedCustomers = _gmsExcludedCustomerRepository.GetGmsExcludedCallQueueCustomers(pageNumber, PageSize, filter, callQueue,
                                                                                                            (SuppressionFilterType)suppressionType.FirstValue, out totalRecords);

                    if (excludedCustomers.IsNullOrEmpty())
                    {
                        break;
                    }

                    var customerIds = excludedCustomers.Where(x => x.CustomerId.HasValue).Select(x => x.CustomerId.Value).ToArray();

                    var customers  = _customerRepository.GetCustomers(customerIds);
                    var customTags = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds);

                    suppressionTypeCustomers.AddRange(Create(excludedCustomers, customers, customTags, organization));

                    if ((pageNumber * PageSize) >= totalRecords)
                    {
                        break;
                    }

                    pageNumber++;
                }

                var distinctCustomers = suppressionTypeCustomers.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId));
                collection.AddRange(distinctCustomers);
            }

            return(collection);
        }
        public JsonResult MassAssignment(MassAgentAssignmentEditModel data)
        {
            var model             = new MassAgentAssignmentViewModel();
            var healthPlanId      = data.HealthPlanId;
            var callQueueCategory = data.CallQueueCategory;
            var criteriaId        = data.CriteriaId;
            var callQueue         = new CallQueue();

            if (healthPlanId == null || (healthPlanId.HasValue && healthPlanId.Value == 0))
            {
                return(Json(model.ErrorMessage = "Select healthplan first", JsonRequestBehavior.AllowGet));
            }
            if (!(callQueueCategory == HealthPlanCallQueueCategory.FillEventsHealthPlan ||
                  callQueueCategory == HealthPlanCallQueueCategory.MailRound ||
                  callQueueCategory == HealthPlanCallQueueCategory.LanguageBarrier ||
                  callQueueCategory == HealthPlanCallQueueCategory.AppointmentConfirmation))
            {
                return(Json(model.ErrorMessage = "Select call queue first", JsonRequestBehavior.AllowGet));
            }

            if (Request != null && Request.Files != null && Request.Files.Count > 0 && data.MassAssignmentFile != null)
            {
                HttpPostedFileBase file   = Request.Files[0];
                var uploadDateTime        = DateTime.Now;
                var fileUploadName        = @"MassAgentAssignment_" + uploadDateTime.ToString("yyyyMMddHHmmss") + "_" + _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId + ".csv";
                var tempMediaFileLocation = _mediaRepository.GetTempMediaFileLocation();
                var tempPhysicalPath      = tempMediaFileLocation.PhysicalPath;
                var tempFullpath          = tempPhysicalPath + fileUploadName;

                var logFileName = "Failure_" + fileUploadName;
                var logFilePath = tempPhysicalPath + logFileName;

                var fileExtension = file.FileName.Split('.');
                if ((fileExtension.Length >= 2 && fileExtension[fileExtension.Length - 1].ToLower() != "csv") || fileExtension.Length < 2)
                {
                    return(Json(model.ErrorMessage = "File format is not CSV", JsonRequestBehavior.AllowGet));
                }

                try
                {
                    file.SaveAs(tempFullpath);          //save in Temp
                    model.UploadedCsvFileName = fileUploadName;
                }
                catch (Exception)
                {
                    return(Json(model.ErrorMessage = "Internal error occurred", JsonRequestBehavior.AllowGet));
                }

                var massAssignmentTable = _csvReader.ReadWithTextQualifier(tempFullpath);

                if (massAssignmentTable.Rows.Count == 0)
                {
                    return(Json(model.ErrorMessage = "File contains no data", JsonRequestBehavior.AllowGet));
                }

                var columns            = massAssignmentTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray();
                var missingColumnNames = CheckAllColumnExist(columns);
                if (!string.IsNullOrEmpty(missingColumnNames))
                {
                    var customString = missingColumnNames
                                       .Replace(MassAgentAssignmentColumns.AgentName, "Agent name")
                                       .Replace(MassAgentAssignmentColumns.EmailId, "Email id")
                                       .Replace(MassAgentAssignmentColumns.StartDate, "Start date")
                                       .Replace(MassAgentAssignmentColumns.EndDate, "End date");

                    return(Json(model.ErrorMessage = "Missing Column Name(s):" + customString, JsonRequestBehavior.AllowGet));
                }

                //parsing HealthPlanId and CallQueueCategory
                if (healthPlanId == null || string.IsNullOrEmpty(callQueueCategory))
                {
                    return(Json(model.ErrorMessage = "Please select healthplan/call queue first", JsonRequestBehavior.AllowGet));
                }

                callQueue = _callQueueRepository.GetCallQueueByCategory(data.CallQueueCategory);

                if (callQueue == null)
                {
                    return(Json(model.ErrorMessage = "Invalid call queue selected", JsonRequestBehavior.AllowGet));
                }

                var       agentDataCollection = new List <CallQueueAssignmentEditModel>();
                DataTable table = _csvReader.CsvToDataTable(tempMediaFileLocation.PhysicalPath + fileUploadName, true);
                if (table.Rows.Count <= 0)
                {
                    return(Json(model.ErrorMessage = "File contains no data", JsonRequestBehavior.AllowGet));
                }

                var failedToParseRecords = new StringBuilder();
                failedToParseRecords.Append(MassAgentAssignmentColumns.AgentName + "," +
                                            MassAgentAssignmentColumns.EmailId + "," +
                                            MassAgentAssignmentColumns.StartDate + "," +
                                            MassAgentAssignmentColumns.EndDate + "," +
                                            "Error Message" + Environment.NewLine);

                foreach (DataRow row in table.Rows)
                {
                    var agentData = new CallQueueAssignmentEditModel();
                    var rowData   = GetMassAssignmentCsvRow(row);
                    var errorRow  = rowData.AgentName + "," +
                                    rowData.EmailId + "," +
                                    rowData.StartDate + "," +
                                    rowData.EndDate;

                    //Email Id
                    if (string.IsNullOrEmpty(rowData.EmailId))
                    {
                        failedToParseRecords.Append(errorRow + "," + "No Email Provided" + Environment.NewLine);
                        continue;
                    }
                    //StartDate empty
                    if (string.IsNullOrEmpty(rowData.StartDate))
                    {
                        failedToParseRecords.Append(errorRow + "," + "Start date not provided" + Environment.NewLine);
                        continue;
                    }
                    //Start Date Convert
                    try
                    {
                        var startDate = Convert.ToDateTime(rowData.StartDate);

                        if (!(startDate >= DateTime.Today))
                        {
                            failedToParseRecords.Append(errorRow + "," + "Start date must be greater than or equal to current date" + Environment.NewLine);
                            continue;
                        }

                        agentData.StartDate = startDate;
                    }
                    catch (Exception)
                    {
                        failedToParseRecords.Append(errorRow + "," + "Start date invalid format" + Environment.NewLine);
                        continue;
                    }
                    //EndDate
                    if (!string.IsNullOrEmpty(rowData.EndDate))
                    {
                        try
                        {
                            var endDate = Convert.ToDateTime(rowData.EndDate);

                            if (!(endDate >= agentData.StartDate))
                            {
                                failedToParseRecords.Append(errorRow + "," + "End date should be greater than or equal to start date." + Environment.NewLine);
                                continue;
                            }
                            agentData.EndDate = endDate;
                        }
                        catch (Exception)
                        {
                            failedToParseRecords.Append(errorRow + "," + "End date invalid format" + Environment.NewLine);
                            continue;
                        }
                    }
                    else
                    {
                        agentData.EndDate = null;
                    }

                    var oruId = _userRepository.SearchUserByEmailAndRole(rowData.EmailId);
                    if (oruId == null)
                    {
                        failedToParseRecords.Append(errorRow + "," + "Agent not found in our records" + Environment.NewLine);
                        continue;
                    }

                    if (!data.AssignmentsfromUi.IsNullOrEmpty())
                    {
                        if (data.AssignmentsfromUi.Any(x => x.AssignedOrgRoleUserId == oruId))
                        {
                            failedToParseRecords.Append(errorRow + "," + "Agent already added manually" + Environment.NewLine);
                            continue;
                        }
                    }

                    if (agentDataCollection.Any(x => x.AssignedOrgRoleUserId == oruId))
                    {
                        failedToParseRecords.Append(errorRow + "," + "Failed, as record is already present in CSV" + Environment.NewLine);
                        continue;
                    }

                    agentData.AssignedOrgRoleUserId = oruId.Value;
                    agentData.Name = rowData.AgentName;

                    if (criteriaId == null)
                    {
                        criteriaId = 0;
                    }

                    if (callQueueCategory == HealthPlanCallQueueCategory.FillEventsHealthPlan)
                    {
                        agentData.IsExistInOtherCriteria = _healthPlanCallQueueCriteriaRepository.CheckHealthPlanAssignment(healthPlanId.Value,
                                                                                                                            callQueueCategory, criteriaId.Value, agentData.AssignedOrgRoleUserId, agentData.StartDate.Value, agentData.EndDate);

                        if (agentData.IsExistInOtherCriteria)
                        {
                            failedToParseRecords.Append(errorRow + "," + "Start date is overlapping with already assigned date for same health plan and same call queue." + Environment.NewLine);
                            continue;
                        }
                    }
                    else
                    {
                        agentData.IsExistInOtherCriteria = false;
                    }
                    agentData.IsEdited = true;
                    agentDataCollection.Add(agentData);
                }

                if (agentDataCollection.Count < table.Rows.Count) //Some records have failed
                {
                    System.IO.File.AppendAllText(logFilePath, failedToParseRecords.ToString());
                    model.IsRecordsFailed = true;
                    model.LogFileName     = logFileName;
                }
                else
                {
                    model.LogFileName = null;
                }

                model.SuccessAssignments = agentDataCollection;
                model.ErrorMessage       = "";
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(model.ErrorMessage = "No file has been uploaded. Please upload a csv file.", JsonRequestBehavior.AllowGet));
            }
        }
Exemple #23
0
        private void cls_successCountDown(object sender, successTypeArgs e)
        {
            DisableBtnAll();

            StatusTransaction ready = CallQueue.P_CallQueueReady();

            if (ready == StatusTransaction.True)
            {
                StatusTransaction showUnit = new ClsTCPClient().sendCallUnitDisplay();
                if (showUnit == StatusTransaction.Error)
                {
                    //lbAlertMsg.Text = "เกิดความผิดพลาดทางเทคนิค ไม่สามารถแสดงผลบน unit display ได้";
                }
                Class.FunctionDataCls func = new Class.FunctionDataCls();
                resultUltrasound = func.popupUltrasoundLower();
                if (resultUltrasound == PopupUltrasoundLower.ResultPopupUltrasoundLower.BeforeStation)
                {
                    EmrClass.GetDataMasterCls mst = new EmrClass.GetDataMasterCls();
                    List <int> mvt = mst.GetMstRoomEventByMrm(Program.CurrentRoom.mrm_id).Select(x => x.mvt_id).ToList();

                    Class.FunctionDataCls.sendQueueStatus result = func.sendQueueUltrasoundLower(resultUltrasound, mvt);
                    if (result == Class.FunctionDataCls.sendQueueStatus.error)
                    {
                        lbAlertMsg.Text = "เกิดความผิดพลาดทางเทคนิค ไม่สามารถส่งไป ultrasound ได้ กรุณาติดต่อผู้ดูแลระบบ";
                        AlertOutDepartment.LoadTime();
                        StatusWK();
                    }
                    else if (result == Class.FunctionDataCls.sendQueueStatus.sendSuccess)
                    {
                        new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendUltraSoundBefore,
                                                    (int)tpr_id,
                                                    (int)tps_id,
                                                    Program.CurrentSite.mhs_id,
                                                    Program.CurrentRoom.mrd_ename,
                                                    Program.CurrentUser.mut_username);

                        new ClsTCPClient().sendClearUnitDisplay();
                        StatusEmptyRoom();
                        lbAlertMsg.Text = func.GetStrSaveAndSend((int)tpr_id, "US", "UL");
                        this.tpr_id     = null;
                    }
                }
                else if (resultUltrasound == PopupUltrasoundLower.ResultPopupUltrasoundLower.AfterStation)
                {
                    AlertOutDepartment.LoadTime();

                    ReserveSkipCls reserveSkip = new ReserveSkipCls();
                    int?           skipRoom    = reserveSkip.CheckRoomSkip(tpr_id);
                    string         alert       = reserveSkip.MessegeAlertSkip(skipRoom);
                    StatusSendUltrasoundAfter();
                    lbAlertMsg.Text = alert;
                }
                else if (resultUltrasound == PopupUltrasoundLower.ResultPopupUltrasoundLower.AskMeLater)
                {
                    AlertOutDepartment.LoadTime();

                    ReserveSkipCls reserveSkip = new ReserveSkipCls();
                    int?           skipRoom    = reserveSkip.CheckRoomSkip(tpr_id);
                    StatusWK();
                    string alert = reserveSkip.MessegeAlertSkip(skipRoom);
                    lbAlertMsg.Text = alert;
                }
            }
            else if (ready == StatusTransaction.Error)
            {
                lbAlertMsg.Text = "กรุณากดปุ่ม Ready อีกครั้ง";
                StatusNSWR();
            }
        }
Exemple #24
0
        public StatusTransaction pendingOnStationSendAuto(int tpr_id, int mvt_id, int mrm_id, int mhs_id, int tps_id)
        {
            try
            {
                using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                {
                    Class.clsLogSendAuto logCls   = new Class.clsLogSendAuto();
                    List <log_send_auto> log_auto = null;
                    try
                    {
                        List <vw_patient_room> vw_pa_room = logCls.getLogSendAuto(tpr_id);
                        if (vw_pa_room != null)
                        {
                            log_auto = vw_pa_room.Select(x => new log_send_auto
                            {
                                tpr_id         = x.tpr_id,
                                process_type   = "P",
                                process_tps_id = tps_id,
                                login_flag     = x.login_flag,
                                mhs_code       = x.mhs_code,
                                mhs_ename      = x.mhs_ename,
                                mrm_ename      = x.mrm_ename,
                                mrm_id         = x.mrm_id,
                                mrm_seq_room   = x.mrm_seq_room,
                                mvt_code       = x.mvt_code,
                                mvt_id         = x.mvt_id,
                                mvt_type_cate  = x.mvt_type_cate.ToString(),
                                mze_code       = x.mze_code,
                                mze_ename      = x.mze_ename,
                                mze_id         = x.mze_id,
                                patient_vip    = x.patient_vip,
                                send_type      = x.send_type,
                                site_rm        = x.site_rm,
                                skip_seq       = x.skip_seq,
                                skip_type      = x.skip_type,
                                waiting_person = x.waiting_person,
                                waiting_time   = x.waiting_time
                            }).ToList();
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.MessageError("log_send_auto", "", ex, false);
                    }

                    List <int>        list_mvt_id = new Class.FunctionDataCls().get_mvt_id(mrm_id);
                    StatusTransaction result      = CallQueue.PSendAutoAllRoom(Class.SendType.Pending, mrm_id, list_mvt_id, tps_id);
                    if (result == StatusTransaction.SendCheckB)
                    {
                        if (Program.CurrentSite.mhs_extra_pe_type == true && Program.CurrentRegis.tpr_pe_site2 == 'N' && (Program.CurrentRegis.tpr_pd_pe_site2 == null || Program.CurrentRegis.tpr_pd_pe_site2 == false))
                        {
                            return(StatusTransaction.ReSendManualSite2);
                        }
                        else
                        {
                            string            messege = "";
                            StatusTransaction returnB = new Class.SendQueue().ReturnToCheckB(Class.SendType.Pending, tpr_id, mrm_id, tps_id, list_mvt_id, ref messege);
                            if (returnB == StatusTransaction.True)
                            {
                                //new ClsTCPClient().sendClearUnitDisplay();
                                //new Class.FunctionDataCls().SendToCheckPointB(tpr_id, tps_id);
                            }
                            System.Windows.Forms.MessageBox.Show("ระบบไม่สามารถส่งห้องที่เหลือแบบอัตโนมัติได้ ผู้รับบริการจะถูกส่งไป Check point B", "Send Queue Alert", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                            return(returnB);
                        }
                    }
                    else if (result == StatusTransaction.True)
                    {
                        try
                        {
                            if (log_auto != null)
                            {
                                string queue_no   = cdc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).Select(x => x.tpr_queue_no).FirstOrDefault();
                                int?   log_tps_id = logCls.get_tps_id(tpr_id);
                                int    index      = 1;
                                log_auto.ForEach(x => { x.tps_id = log_tps_id; x.seq_id = index++; x.tpr_queue_no = queue_no; });
                                cdc.log_send_autos.InsertAllOnSubmit(log_auto);
                                cdc.SubmitChanges();
                            }
                        }
                        catch (Exception ex)
                        {
                            Program.MessageError("log_send_auto", "", ex, false);
                        }
                        return(result);
                    }
                    else
                    {
                        return(result);
                    }
                }
                //InhCheckupDataContext cdc = new InhCheckupDataContext();

                //trn_patient_regi tpr = cdc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault();
                //tpr.tpr_pending = true;
                //updatePendingPatientPlan(ref tpr, mvt_id, mrm_id, mhs_id);
                //cdc.SubmitChanges();
                //updatePendingPatientQueue(ref cdc, ref tpr, mrm_id);
                //insertPatientPending(ref tpr, mrm_id);
                //CallQueue.PSendAutoAllRoom(true);
                //// alert
                //try
                //{
                //    cdc.SubmitChanges();
                //}
                //catch (System.Data.Linq.ChangeConflictException)
                //{
                //    foreach (ObjectChangeConflict occ in cdc.ChangeConflicts)
                //    {
                //        cdc.Refresh(System.Data.Linq.RefreshMode.KeepChanges, occ.Object);
                //    }
                //    cdc.SubmitChanges();
                //}
                //return true;
            }
            catch (Exception ex)
            {
                Program.MessageError("ClsPendingOnStation", "pendingOnStationSendAuto", ex, false);
                return(StatusTransaction.Error);
            }
        }
Exemple #25
0
        private void btnSendAuto_Click(object sender, EventArgs e)
        {
            DisableBtnAll();
            DateTime startDate = DateTime.Now;

            this.AutoScrollPosition = new Point(0, 0);

            Class.FunctionDataCls     func = new Class.FunctionDataCls();
            EmrClass.GetDataMasterCls mst  = new EmrClass.GetDataMasterCls();
            frmBGScreen frmbg = new frmBGScreen();

            frmbg.Show();
            Application.DoEvents();

            try
            {
                if (resultUltrasound == PopupUltrasoundLower.ResultPopupUltrasoundLower.AfterStation)
                {
                    List <int> mvt = mst.GetMstRoomEventByMrm(Program.CurrentRoom.mrm_id).Select(x => x.mvt_id).ToList();

                    Class.FunctionDataCls.sendQueueStatus result = func.sendQueueUltrasoundLower(resultUltrasound, mvt);
                    if (result == Class.FunctionDataCls.sendQueueStatus.error)
                    {
                        lbAlertMsg.Text = "เกิดความผิดพลาดทางเทคนิค ไม่สามารถส่งไป ultrasound ได้ กรุณาติดต่อผู้ดูแลระบบ";
                        StatusWK();
                    }
                    else if (result == Class.FunctionDataCls.sendQueueStatus.sendSuccess)
                    {
                        new ClsTCPClient().sendClearUnitDisplay();
                        lbAlertMsg.Text = func.GetStrSaveAndSend((int)tpr_id, "US", "UL");
                        StatusEmptyRoom();
                        this.tpr_id = null;
                    }
                }
                else
                {
                    if (new Class.FunctionDataCls().ChkSendAutoNewModule(Program.CurrentRegis))
                    {
                        string msgAlert = "";
                        bool   isPopup  = false;
                        QueueClass.SendAutoCls.ResultSendQueue result = new QueueClass.SendAutoCls().SendAuto((int)tps_id, user, ref msgAlert, ref isPopup);
                        if (result == QueueClass.SendAutoCls.ResultSendQueue.Error)
                        {
                            lbAlertMsg.Text = msgAlert;
                            StatusWK();
                        }
                        else
                        {
                            lbAlertMsg.Visible = true;
                            if (result == QueueClass.SendAutoCls.ResultSendQueue.SendComplete)
                            {
                                new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendAuto,
                                                            (int)tpr_id,
                                                            (int)tps_id,
                                                            Program.CurrentSite.mhs_id,
                                                            Program.CurrentRoom.mrd_ename,
                                                            Program.CurrentUser.mut_username,
                                                            startDate);

                                new ClsTCPClient().sendClearUnitDisplay();
                                new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                                StatusEmptyRoom();
                                this.tpr_id = null;
                                if (isPopup)
                                {
                                    MessageBox.Show(msgAlert, "EMR Checkup.");
                                }
                                else
                                {
                                    lbAlertMsg.Text = msgAlert;
                                }
                            }
                            else
                            {
                                if (isPopup)
                                {
                                    MessageBox.Show(msgAlert, "EMR Checkup.");
                                }
                                else
                                {
                                    lbAlertMsg.Text = msgAlert;
                                }
                            }
                        }
                    }
                    else
                    {
                        StatusTransaction result = CallQueue.SendAutoOnStation();
                        if (result == StatusTransaction.True || result == StatusTransaction.SendCheckB)
                        {
                            new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendAuto,
                                                        (int)tpr_id,
                                                        (int)tps_id,
                                                        Program.CurrentSite.mhs_id,
                                                        Program.CurrentRoom.mrd_ename,
                                                        Program.CurrentUser.mut_username,
                                                        startDate);

                            new ClsTCPClient().sendClearUnitDisplay();
                            lbAlertMsg.Visible = true;
                            new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                            lbAlertMsg.Text = new Class.FunctionDataCls().getStringGotoNextRoom((int)tpr_id);
                            StatusEmptyRoom();
                            this.tpr_id = null;
                        }
                        else if (result == StatusTransaction.Error)
                        {
                            lbAlertMsg.Text = "โปรดกด Send Auto อีกครั้ง";
                            StatusWK();
                        }
                        else if (result == StatusTransaction.False)
                        {
                            lbAlertMsg.Text = "Save Data Complete.";
                            StatusWK();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lbAlertMsg.Text = ex.Message;
                StatusWK();
            }
            frmbg.Close();
        }
Exemple #26
0
        private List <MailRoundCustomersReportViewModel> GetCustomersForMatrixReport(long healthPlanId, CallQueue callQueue)
        {
            var list = new List <MailRoundCustomersReportViewModel>();

            if (callQueue == null)
            {
                return(list);
            }

            var       pageNumber = 1;
            const int pageSize   = 100;

            var filter = new OutboundCallQueueFilter();

            filter.HealthPlanId  = healthPlanId;
            filter.CallQueueId   = callQueue.Id;
            filter.GmsAccountIds = _settings.GmsAccountIds;

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);

            while (true)
            {
                int totalRecords;
                var model = _callQueueCustomerReportService.GetCustomersForMatrixReport(pageNumber, pageSize, filter, callQueue, out totalRecords);
                if (model == null || model.Collection == null || !model.Collection.Any())
                {
                    break;
                }

                list.AddRange(model.Collection);
                _logger.Info(String.Format("\n\nPageNumber:{0} TotalRecords: {1},  Current Length: {2}", pageNumber, totalRecords, list.Count));

                pageNumber++;

                if (list.Count >= totalRecords)
                {
                    break;
                }
            }
            return(list);
        }
Exemple #27
0
        public OutboundCallQueueListModel GetnOutboundZipRadiusCallQueueListModel(OutboundCallQueueFilter filter, CallQueue callQueue, int pageSize, long criteriaId, out int totalRecords)
        {
            var callQueueCustomers = _callQueueCustomerRepository.GetZipRadiusCallQueueCustomer(filter, filter.PageNumber, pageSize, criteriaId, out totalRecords);

            if (callQueueCustomers.IsNullOrEmpty())
            {
                return(new OutboundCallQueueListModel {
                    IsQueueGenerated = true
                });
            }

            return(OutboundCallQueueListModel(callQueueCustomers, filter.CustomCorporateTag));
        }
Exemple #28
0
        public List <CallQueueCustomer> GetCallQueueCustomers(CallQueue queue)
        {
            var callQueuesCriterias = _callQueueCriteriaRepository.GetByCallQueueId(queue.Id);

            var callCriterias = (from qc in callQueuesCriterias
                                 orderby qc.Sequence
                                 select new
            {
                Id = qc.Id,
                CriteriaId = qc.CriteriaId,
                CallQueueId = qc.CallQueueId,
                qc.Condition,
                qc.Radius,
                qc.Zipcode,
                CustomerTempList = new List <CallQueueCustomer>()
            }).ToList();

            var customerList = new List <CallQueueCustomer>();

            for (int i = 0; i < callCriterias.Count(); i++)
            {
                if (callCriterias[i].CriteriaId == (long)QueueCriteria.AllCustomers)
                {
                    var customers = _customerRepository.GetCustomerBasedOnGeography(callCriterias[i].Zipcode, callCriterias[i].Radius, false);
                    if (customers == null || !customers.Any())
                    {
                        continue;
                    }
                    foreach (long customerId in customers)
                    {
                        callCriterias[i].CustomerTempList.Add(new CallQueueCustomer {
                            CallQueueId = queue.Id, CustomerId = customerId, CallQueueCriteriaId = callCriterias[i].Id
                        });
                    }
                }
                else if (callCriterias[i].CriteriaId == (long)QueueCriteria.AllCustomersOlderThanOneYear)
                {
                    var customers = _customerRepository.GetCustomerBasedOnGeography(callCriterias[i].Zipcode, callCriterias[i].Radius, true);
                    if (customers == null || !customers.Any())
                    {
                        continue;
                    }
                    foreach (long customerId in customers)
                    {
                        callCriterias[i].CustomerTempList.Add(new CallQueueCustomer {
                            CallQueueId = queue.Id, CustomerId = customerId, CallQueueCriteriaId = callCriterias[i].Id
                        });
                    }
                }
                else if (callCriterias[i].CriteriaId == (long)QueueCriteria.PhysicianPartner)
                {
                    var customers = _customerRepository.GetPhysicianPartnerCustomerBasedOnGeography(callCriterias[i].Zipcode, callCriterias[i].Radius, _settings.PhysicianPartnerAccountId);
                    if (customers == null || !customers.Any())
                    {
                        continue;
                    }
                    foreach (long customerId in customers)
                    {
                        callCriterias[i].CustomerTempList.Add(new CallQueueCustomer {
                            CallQueueId = queue.Id, CustomerId = customerId, CallQueueCriteriaId = callCriterias[i].Id
                        });
                    }
                }
                else
                {
                    var prospects = _prospectCustomerRepository.GetProspectsBasedOnGeography(callCriterias[i].Zipcode, callCriterias[i].Radius, ((QueueCriteria)callCriterias[i].CriteriaId).ToString());
                    if (prospects == null || !prospects.Any())
                    {
                        continue;
                    }
                    foreach (var pc in prospects)
                    {
                        callCriterias[i].CustomerTempList.Add(new CallQueueCustomer {
                            CallQueueId = queue.Id, CustomerId = pc.SecondValue, ProspectCustomerId = pc.FirstValue, CallQueueCriteriaId = callCriterias[i].Id
                        });
                    }
                }
            }

            //creating master list from individual call criterias
            for (int i = 0; i < callCriterias.Count(); i++)
            {
                if (callCriterias.Count() == 1)
                {
                    customerList = callCriterias[0].CustomerTempList;
                }
                else
                {
                    //putting list in 0th element in the master list
                    if (i == 0)
                    {
                        customerList = callCriterias[0].CustomerTempList;
                    }
                    else
                    {
                        //comparing condition between (AND/Or) current and previows element
                        if (!callCriterias[i].Condition)
                        {
                            customerList.AddRange(callCriterias[i - 1].CustomerTempList.AsEnumerable().Intersect(callCriterias[i].CustomerTempList.AsEnumerable(), new CallQueueCustomerEqualityComparer()).ToList());
                        }
                        else
                        {
                            customerList.AddRange(callCriterias[i].CustomerTempList);
                        }
                    }
                }
            }

            var finalList = (from c in customerList
                             group c by new { c.CallQueueId, c.CustomerId, c.ProspectCustomerId }
                             into g
                             select new CallQueueCustomer {
                CallQueueId = g.Key.CallQueueId, CustomerId = g.Key.CustomerId, ProspectCustomerId = g.Key.ProspectCustomerId, CallQueueCriteriaId = g.Min(c => c.CallQueueCriteriaId)
            }).ToList();

            return(finalList);
        }
Exemple #29
0
        public long SaveViciDialerCall(ViciDialerCallModel model, long orgRoleUserId)
        {
            long status      = 0;
            var  disposition = string.Empty;

            if (model.Disposition.ToUpper() == "ANS.MACH")//Left Voice mail
            {
                status = (long)CallStatus.VoiceMessage;
            }
            else if (model.Disposition.ToUpper() == "NO.ANS" || model.Disposition.ToUpper() == "BUSY") //No Answer/Busy/Mail Full
            {
                status = (long)CallStatus.NoAnswer;
            }
            else if (model.Disposition.ToUpper() == "DEAD") //Incorrect Phone number
            {
                status      = (long)CallStatus.TalkedtoOtherPerson;
                disposition = ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString();
            }
            CallQueue callQueue = null;

            if (model.CallQueueId > 0)
            {
                callQueue = _callQueueRepository.GetById(model.CallQueueId);
            }

            var customer = _customerRepository.GetCustomer(model.CustomerId);
            var account  = _corporateAccountRepository.GetByTag(customer.Tag);

            bool?isContacted = false;

            if (callQueue == null || callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation)
            {
                isContacted = null;
            }
            else
            {
                isContacted = (status == (long)CallStatus.Attended || status == (long)CallStatus.VoiceMessage || status == (long)CallStatus.LeftMessageWithOther);
            }

            var call = new Call()
            {
                CallDateTime           = model.CallStartDateTime,
                StartTime              = model.CallStartDateTime,
                EndTime                = model.CallEndDateTime,
                CallStatus             = CallType.Existing_Customer.GetDescription(),
                IsIncoming             = false,
                CalledCustomerId       = model.CustomerId,
                Status                 = status,
                CreatedByOrgRoleUserId = orgRoleUserId,
                IsNewCustomer          = false,
                DateCreated            = model.CallStartDateTime,
                DateModified           = model.CallStartDateTime,
                ReadAndUnderstood      = true,
                HealthPlanId           = account != null ? account.Id : (long?)null,
                CallQueueId            = callQueue != null ? callQueue.Id : (long?)null,
                DialerType             = (long)DialerType.Vici,
                CalledInNumber         = model.CallerId,
                CallerNumber           = model.CallerPhoneNumber,
                CallBackNumber         = model.CallerPhoneNumber,
                IsContacted            = isContacted,
                Disposition            = disposition,
                ProductTypeId          = customer.ProductTypeId
            };

            call = _callCenterCallRepository.Save(call);

            if (status == (long)CallStatus.TalkedtoOtherPerson && disposition == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString())
            {
                _customerService.UpdateIsIncorrectPhoneNumber(model.CustomerId, true, orgRoleUserId);
            }

            if (!string.IsNullOrEmpty(model.CallerId))
            {
                var customerAccountGlocomNumber = new CustomerAccountGlocomNumber
                {
                    CallId       = call.Id,
                    CustomerId   = model.CustomerId,
                    GlocomNumber = PhoneNumber.ToNumber(model.CallerId),
                    CreatedDate  = model.CallStartDateTime,
                    IsActive     = true
                };
                _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber);
            }

            if (callQueue != null)
            {
                var callQueueCustomer = _callQueueCustomerRepository.GetCallQueueCustomerByCustomerIdAndHealthPlanId(model.CustomerId, account.Id, callQueue.Category);

                var callQueueCustomerCall = new CallQueueCustomerCall {
                    CallQueueCustomerId = callQueueCustomer.Id, CallId = call.Id
                };
                _callQueueCustomerCallRepository.Save(callQueueCustomerCall);



                bool removeFromCallQueue = status == (long)CallStatus.TalkedtoOtherPerson;
                var  callQueueStatus     = CallQueueStatus.Initial;
                if (removeFromCallQueue)
                {
                    callQueueStatus = CallQueueStatus.Removed;
                }

                _callQueueCustomerContactService.SetCallQueueCustomerStatus(callQueueCustomer, callQueueStatus, orgRoleUserId, false, status, model.CallStartDateTime);


                var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0;

                if (prospectCustomerId == 0)
                {
                    var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(model.CustomerId);
                    if (prospectCustomer != null)
                    {
                        prospectCustomerId = prospectCustomer.Id;
                    }
                }

                _callQueueCustomerRepository.UpdateOtherCustomerAttempt(callQueueCustomer.Id, model.CustomerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId, status, model.CallStartDateTime, isForParsing: true, disposition: disposition);
            }

            return(call.Id);
        }
Exemple #30
0
        private void btnSendAuto_Click(object sender, EventArgs e)
        {
            DisableBtnAll();
            DateTime startDate = DateTime.Now;

            this.AutoScrollPosition = new Point(0, 0);
            //tps_id = Program.CurrentPatient_queue.tps_id;

            Class.FunctionDataCls     func = new Class.FunctionDataCls();
            EmrClass.GetDataMasterCls mst  = new EmrClass.GetDataMasterCls();
            frmBGScreen frmbg = new frmBGScreen();

            frmbg.Show();
            Application.DoEvents();

            try
            {
                int patientMvt = paRegis.trn_patient_queues.Where(x => x.tps_id == tps_id)
                                 .Select(x => (int)x.mvt_id).FirstOrDefault();
                using (InhCheckupDataContext contxt = new InhCheckupDataContext())
                {
                    string mvt_code = contxt.mst_events.Where(x => x.mvt_id == patientMvt).Select(x => x.mvt_code).FirstOrDefault();
                    if (mvt_code == "PE")
                    {
                        if (new Class.FunctionDataCls().checkPassedCheckPointB((int)this.tpr_id))
                        {
                            this.PatientEvent = PatientEventStatus.PEAfterCheckB;
                        }
                        else
                        {
                            this.PatientEvent = PatientEventStatus.PEBeforeCheckB;
                        }
                    }
                    else
                    {
                        this.PatientEvent = PatientEventStatus.Result;
                    }
                }

                if (saveData())
                {
                    if (this.PatientEvent == PatientEventStatus.PEBeforeCheckB)
                    {
                        bool sent = new QueueClass.TransactionQueueCls().SendQueueDoctorPEBeforeCheckB((int)tpr_id, (int)tps_id, user.mut_username);
                        if (sent)
                        {
                            lbAlertMsg.Text = new Class.FunctionDataCls().getStringGotoNextRoom((int)tpr_id);
                            StatusEmptyRoom();
                        }
                        else
                        {
                            lbAlertMsg.Text = "โปรดกด Send Auto อีกครั้ง";;
                            StatusWK();
                        }
                    }
                    else if (this.PatientEvent == PatientEventStatus.PEAfterCheckB)
                    {
                        if (resultUltrasound == PopupUltrasoundLower.ResultPopupUltrasoundLower.AfterStation)
                        {
                            List <int> mvt = mst.GetMstRoomEventByMrm(Program.CurrentRoom.mrm_id).Select(x => x.mvt_id).ToList();

                            Class.FunctionDataCls.sendQueueStatus result = func.sendQueueUltrasoundLower(resultUltrasound, mvt);
                            if (result == Class.FunctionDataCls.sendQueueStatus.error)
                            {
                                lbAlertMsg.Text = "เกิดความผิดพลาดทางเทคนิค ไม่สามารถส่งไป ultrasound ได้ กรุณาติดต่อผู้ดูแลระบบ";
                                StatusWK();
                            }
                            else if (result == Class.FunctionDataCls.sendQueueStatus.sendSuccess)
                            {
                                new ClsTCPClient().sendClearUnitDisplay();
                                lbAlertMsg.Text = func.GetStrSaveAndSend((int)tpr_id, "US", "UL");
                                StatusEmptyRoom();
                                this.tpr_id = null;
                            }
                        }
                        else
                        {
                            if (new Class.FunctionDataCls().ChkSendAutoNewModule(Program.CurrentRegis))
                            {
                                string     msgAlert    = "";
                                bool       isPopup     = false;
                                List <int> list_mvt_id = new List <int> {
                                    patientMvt
                                };
                                QueueClass.SendAutoCls.ResultSendQueue result = new QueueClass.SendAutoCls().SendAuto((int)tps_id, list_mvt_id, user, ref msgAlert, ref isPopup);
                                if (result == QueueClass.SendAutoCls.ResultSendQueue.Error)
                                {
                                    lbAlertMsg.Text = msgAlert;
                                    StatusWK();
                                }
                                else
                                {
                                    lbAlertMsg.Visible = true;
                                    if (result == QueueClass.SendAutoCls.ResultSendQueue.SendComplete)
                                    {
                                        new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendAuto,
                                                                    (int)tpr_id,
                                                                    (int)tps_id,
                                                                    Program.CurrentSite.mhs_id,
                                                                    Program.CurrentRoom.mrd_ename,
                                                                    Program.CurrentUser.mut_username,
                                                                    startDate);

                                        new ClsTCPClient().sendClearUnitDisplay();
                                        new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                                        StatusEmptyRoom();
                                        this.tpr_id = null;
                                        if (isPopup)
                                        {
                                            MessageBox.Show(msgAlert, "EMR Checkup.");
                                        }
                                        else
                                        {
                                            lbAlertMsg.Text = msgAlert;
                                        }
                                    }
                                    else
                                    {
                                        if (isPopup)
                                        {
                                            MessageBox.Show(msgAlert, "EMR Checkup.");
                                        }
                                        else
                                        {
                                            lbAlertMsg.Text = msgAlert;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                StatusTransaction result = CallQueue.SendAutoOnStation();
                                if (result == StatusTransaction.True || result == StatusTransaction.SendCheckB)
                                {
                                    new Class.logPatientFlowCls(Class.logPatientFlowCls.sendType.SendAuto,
                                                                (int)tpr_id,
                                                                (int)tps_id,
                                                                Program.CurrentSite.mhs_id,
                                                                Program.CurrentRoom.mrd_ename,
                                                                Program.CurrentUser.mut_username,
                                                                startDate);

                                    new ClsTCPClient().sendClearUnitDisplay();
                                    lbAlertMsg.Visible = true;
                                    new Class.ReserveSkipCls().SendAndReserve(tpr_id);
                                    lbAlertMsg.Text = new Class.FunctionDataCls().getStringGotoNextRoom((int)tpr_id);
                                    StatusEmptyRoom();
                                    this.tpr_id = null;
                                }
                                else if (result == StatusTransaction.Error)
                                {
                                    lbAlertMsg.Text = "โปรดกด Send Auto อีกครั้ง";
                                    StatusWK();
                                }
                                else if (result == StatusTransaction.False)
                                {
                                    lbAlertMsg.Text = "Save Data Complete.";
                                    StatusWK();
                                }
                            }
                        }
                    }
                    else if (this.PatientEvent == PatientEventStatus.Result)
                    {
                        bool sent = new QueueClass.TransactionQueueCls().SendQueueDoctorResult((int)tps_id, user.mut_username);
                        if (sent)
                        {
                            lbAlertMsg.Text = "Sent To Checkpoint C.";
                            StatusEmptyRoom();
                        }
                        else
                        {
                            lbAlertMsg.Text = "Save Data Incomplete. Please Try Again.";
                            StatusWK();
                        }
                    }
                }
                else
                {
                    lbAlertMsg.Text = "Save Data Incomplete. Please Try Again.";
                    StatusWK();
                }
            }
            catch (Exception ex)
            {
                lbAlertMsg.Text = ex.Message;
                StatusWK();
            }
            frmbg.Close();
        }