Beispiel #1
0
        public void RemoveRisk_ShouldCallRiskRepositoryEdit()
        {
            var riskRepositoryMock   = new Mock <IRiskRepository>();
            var policyRepositoryMock = new Mock <IPolicyRepository>();

            var riskService = new RiskService(policyRepositoryMock.Object,
                                              riskRepositoryMock.Object);

            var EffectiveDate = DateTime.Now;

            policyRepositoryMock.Setup(mock => mock.Get(It.IsAny <string>()))
            .Returns(new PolicyModel()
            {
                ValidTill = EffectiveDate.AddMonths(6)
            });

            riskRepositoryMock.Setup(mock => mock.Get(It.IsAny <string>()))
            .Returns(new RiskModel()
            {
            });

            riskService.RemoveRisk(DEFAULT_OBJECT_NAME, new Risk()
            {
                Name = DEFAULT_RISK_NAME
            },
                                   EffectiveDate.AddMonths(2), EffectiveDate);

            riskRepositoryMock.Verify(mock => mock.Edit(It.IsAny <RiskModel>()), Times.Once);
        }
Beispiel #2
0
        public void GetAllRisksTest()
        {
            var service  = new RiskService();
            var allRisks = service.GetAllRisks();

            Assert.AreNotEqual(0, allRisks);
        }
 public async Task UpdateOFACStatus(UpdateOFACStatusRequest request)
 {
     try
     {
         await RiskService.UpdateOFACStatus(new External.Model.Request.UpdateOFACStatusRequest()
         {
             AccountIdentifier = request.AccountIdentifier,
             IsOfacMatch       = request.IsOfacMatch,
             CaseNumber        = request.CaseNumber
         });
     }
     catch (GdErrorException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new GdErrorException(
                   "Error when executing UpdateOFACStatus",
                   new LogObject("CaseManager",
                                 new Dictionary <string, object> {
             { "AccountIdentifier", request.AccountIdentifier }
         }), ex);
     }
 }
Beispiel #4
0
        public void GetRiskByNameTest()
        {
            var service  = new RiskService();
            var riskItem = service.GetRiskByName("Sport");

            Assert.AreEqual("Sport", riskItem.Name);
        }
Beispiel #5
0
        public void GetRisksByCategoryTest()
        {
            var service = new RiskService();
            var risks   = service.GetRiskByCategory(1);

            Assert.AreEqual(2, risks.Count());
        }
Beispiel #6
0
        public decimal CalculatePrice(InsuranceDto insurance)
        {
            var service     = new PriceListItemService();
            var riskService = new RiskService();

            var     duration           = (insurance.EndDate - insurance.StartDate).Days;
            decimal durationPercentage = 0;

            if (duration == 0 || (duration > 0 && duration < 8))
            {
                durationPercentage = 1;
            }
            else if (duration > 7 && duration < 15)
            {
                durationPercentage = 0.9M;
            }
            else if (duration > 14 && duration < 31)
            {
                durationPercentage = 0.8M;
            }
            else
            {
                durationPercentage = 0.75M;
            }

            var     numOfInsurants      = int.Parse(insurance.NumberOfInsurants);
            decimal insurantsPercentage = 0;

            if (numOfInsurants < 5)
            {
                insurantsPercentage = 1;
            }
            else if (numOfInsurants > 4 && numOfInsurants < 10)
            {
                insurantsPercentage = 0.9M;
            }
            else
            {
                insurantsPercentage = 0.85M;
            }

            var durationPrice = service.GetPricelistItemByRiskItemId(18).First().Price *service.GetPricelistItemByRiskItemId(18).First().Coefficient;
            var regionPrice   = insurance.Region != 0 ? service.GetPricelistItemByRiskItemId(insurance.Region).First().Price *service.GetPricelistItemByRiskItemId(insurance.Region).First().Coefficient : 0.0M;
            var agePrice      = insurance.Age != 0 ? service.GetPricelistItemByRiskItemId(insurance.Age).First().Price *service.GetPricelistItemByRiskItemId(insurance.Age).First().Coefficient : 0.0M;
            var sportPrice    = insurance.Sport != 0 ? service.GetPricelistItemByRiskItemId(insurance.Sport).First().Price *service.GetPricelistItemByRiskItemId(insurance.Sport).First().Coefficient : 0.0M;
            var valuePrice    = insurance.InsuredValue != 0 ? service.GetPricelistItemByRiskItemId(insurance.InsuredValue).First().Price *service.GetPricelistItemByRiskItemId(insurance.InsuredValue).First().Coefficient : 0.0M;

            var durationPriceTotal = durationPrice * duration * durationPercentage;

            var totalPrice = durationPriceTotal + regionPrice + agePrice + sportPrice + valuePrice;

            var insurantPrice  = service.GetPricelistItemByRiskItemId(19).First().Price *service.GetPricelistItemByRiskItemId(19).First().Coefficient;
            var insurantsTotal = insurantPrice * numOfInsurants * insurantsPercentage;

            return(totalPrice * insurantsTotal);
        }
Beispiel #7
0
        public static void InitializeCollection()
        {
            RiskService data        = new RiskService();
            var         ListOfRiscs = data.GetRisks();

            //foreach (var item in ListOfRiscs)
            //{
            //    Console.WriteLine(item.Owner.Name+ "  --" + item.Title);

            //}
            List <Risk> resultOwned = ListOfRiscs.FindAll(x => x.Owner.Name == "Matt Sharpe");

            PrintSelectedRisc(resultOwned);

            List <Risk> resultStatus = ListOfRiscs.FindAll(x => x.Status.ToString() != "Unapproved");

            PrintSelectedRisc(resultStatus);

            List <Risk> resultInTitle = ListOfRiscs.FindAll(x => x.Title.Contains("fire"));

            PrintSelectedRisc(resultInTitle);
            Console.ReadLine();
        }
Beispiel #8
0
        public void automate()
        {
            if (status != null)
            {
                try
                {
                    //status.LogHeartbeat(this.Text);
                }
                catch (Exception ex)
                {
                    //  Logger.Instance.WriteToLog(ex.ToString());
                }
            }

            List <int> apptIDs = new List <int>();

            /***********************   get appointments to automate   ********************/
            SqlDataReader reader;
            string        CustomAutomationString = Configurator.getNodeValue("DatabaseInfo", "AUTOMATION_SQL");

            if (string.IsNullOrEmpty(CustomAutomationString) == false)
            {
                reader = BCDB2.Instance.ExecuteReader(CustomAutomationString);
            }
            else
            {
                reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_Automation", null);
            }
            try
            {
                while (reader.Read())
                {
                    if (reader.IsDBNull(0) == false)
                    {
                        apptIDs.Add(reader.GetInt32(0));
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Instance.WriteToLog("Error getting appointment IDs: " + e.ToString());
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            if (apptIDs.Count == 0)
            {
                ProcessingThread.ReportProgress(0,
                                                "No appointments are marked for automation - " + DateTime.Now.ToString());
                return;
            }


            /***********************    automation cycle   ********************/
            foreach (int apptid in apptIDs)
            {
                if (ProcessingThread.CancellationPending)
                {
                    return;
                }

                ProcessingThread.ReportProgress(0, "Running automation for appt: " + apptid.ToString() + ".");

                /***********************  Get Unitnum & set active patient  ********************/
                string unitnum         = "";
                ParameterCollection pc = new ParameterCollection("apptID", apptid);
                using (reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_3_GetUnitnum", pc))
                //ExecuteReader("SELECT unitnum FROM tblAppointments WHERE apptID = " + apptid))
                {
                    if (reader != null && reader.Read())
                    {
                        unitnum = reader.GetValue(0).ToString();
                    }
                }

                //StatusReport sr = new StatusReport();
                //sr.apptid = apptid;
                //sr.description = "Started Automation cycle";
                //ProcessingThread.ReportProgress(300, sr);

                //StatusReport sr = (StatusReport)e.UserState;
                //if (status != null)
                //{
                try
                {
                    //temp debug
                    //status.LogStatus(this.Text,
                    //         "Automation",
                    //         "Ok",
                    //         "tarted Automation cycle " + apptid.ToString());
                }
                catch (Exception ex)
                {
                    Logger.Instance.WriteToLog(ex.ToString());
                }
                //}
                SessionManager.Instance.SetActivePatientNoCallback(unitnum, (int)apptid);

                /***********************  Risk Calculations   ********************/
                try
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Running risk calculations for appointment: " + apptid.ToString() +
                                                    ".");
                    SessionManager.Instance.GetActivePatient().RecalculateRisk();
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Risk calculations FAILED for appointment: " + apptid.ToString() +
                                                    ". " + e.ToString());
                }

                /***********************  Update BigQueue   ********************/
                try
                {
                    ProcessingThread.ReportProgress(1, "Updating BigQueue for appointment: " + apptid.ToString() + ".");
                    pc = new ParameterCollection("unitnum", unitnum);
                    BCDB2.Instance.RunSPWithParams("sp_3_populateBigQueue", pc);
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Updating BigQueue FAILED for appointment: " + apptid.ToString() +
                                                    ". " + e.ToString());
                }

                /***********************  Process Queue Documents    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Processing Queue Documents for appointment: " + apptid.ToString() + ".");
                pc = new ParameterCollection("apptID", apptid);
                BCDB2.Instance.RunSPWithParams("sp_processQueueDocuments", pc);



                /***********************  Process Automation Save Documents    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Processing Auto Save Documents: " + apptid.ToString() + ".");
                ApptUtils.saveAutomationDocumentsToPrintQueue(apptid);


                /***********************  Run Automation Stored Procedures    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Run Automation Stored Procedures  : " + apptid.ToString() + ".");

                ApptUtils.runAutomationStoredProcedures(apptid);

                /***********************  export HL7 files    ********************/
                ProcessingThread.ReportProgress(1,
                                                "Export HL7 File: " + apptid.ToString() + ".");
                RiskService.exportHL7File(apptid);

                /***********************  Print Documents   ********************/
                try
                {
                    ProcessingThread.ReportProgress(1, "Printing documents for appointment: " + apptid.ToString() + ".");
                    ParameterCollection printDocArgs = new ParameterCollection();
                    printDocArgs.Add("apptid", apptid);
                    reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_AutomationHtmlDocsToPrint", printDocArgs);

                    int    templateID = -1;
                    string printer    = "";

                    while (reader.Read())
                    {
                        if (reader.IsDBNull(0) == false)
                        {
                            templateID = reader.GetInt32(0);
                        }
                        if (reader.IsDBNull(1) == false)
                        {
                            printer = reader.GetString(1);
                        }

                        if (templateID > 0)
                        {
                            if (string.IsNullOrEmpty(printer) == false)
                            {
                                if (printer.ToUpper() != "NO_PRINT")
                                {
                                    ProcessingThread.ReportProgress(1,
                                                                    "Printing templateID " + templateID.ToString() +
                                                                    " for apptID " + apptid.ToString() + ".");
                                    HtmlDocument hdoc = new HtmlDocument(templateID, unitnum, apptid);
                                    hdoc.targetPrinter = printer;
                                    hdoc.apptid        = apptid;
                                    htmlInProgress     = true;


                                    //try
                                    //{
                                    //    ////temp debug
                                    //    //status.LogStatus(this.Text,
                                    //    //                 "Automation",
                                    //    //                 "Ok",
                                    //    //                 "Appt " + hdoc.apptid.ToString() + " Sent doc " + hdoc.template.documentTemplateID.ToString() + " to " + hdoc.targetPrinter);
                                    //}
                                    //catch (Exception ex) { Logger.Instance.WriteToLog(ex.ToString()); }

                                    if (status != null)
                                    {
                                        try
                                        {
                                            status.LogStatus(this.Text,
                                                             "Automation",
                                                             "Ok",
                                                             "Appt " + hdoc.apptid.ToString() + " Sent doc " +
                                                             hdoc.template.documentTemplateID.ToString() + " to " +
                                                             hdoc.targetPrinter);
                                        }
                                        catch (System.Web.Services.Protocols.SoapException e)
                                        {
                                            //do nothing
                                        }
                                        catch (Exception ex)
                                        {
                                            Logger.Instance.WriteToLog(ex.ToString());
                                        }
                                    }


                                    ProcessingThread.ReportProgress(100, hdoc);
                                    while (htmlInProgress)
                                    {
                                        Thread.Sleep(100);
                                    }

                                    string sqlStr =
                                        "INSERT INTO tblDocuments([apptID],[documentTemplateID],[created],[createdBy]) VALUES(" +
                                        hdoc.apptid.ToString() + "," + hdoc.template.documentTemplateID + "," + "'" +
                                        DateTime.Now +
                                        "','AUTOMATION');";

                                    BCDB2.Instance.ExecuteNonQuery(sqlStr);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    "Printing FAILED for appointment: " + apptid.ToString() + ". " +
                                                    e.ToString());
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
                /***********************  Mark as printed to complete automation   ********************/
                try
                {
                    String sqlStr = "UPDATE tblRiskData SET printed = 1 WHERE apptid = " + apptid.ToString() + ";";
                    BCDB2.Instance.ExecuteNonQuery(sqlStr);
                }
                catch (Exception e)
                {
                    ProcessingThread.ReportProgress(1,
                                                    ("Automation - unable to update appt id=" + apptid.ToString() +
                                                     " printed=1.\n" + e.ToString()));
                }

                ProcessingThread.ReportProgress(200, "");
            }
        }
Beispiel #9
0
 public EvaluationController(EvaluationService evaluationService, EmployeeService employeeService, RiskService riskService)
 {
     _evaluationService = evaluationService;
     _employeeService   = employeeService;
     _riskService       = riskService;
 }
Beispiel #10
0
 public RiskController(RiskService riskService)
 {
     _riskService = riskService;
 }
Beispiel #11
0
        public ActionResult GetAllRisks()
        {
            var service = new RiskService();

            return(Json(service.GetAllRisks(), JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        public ActionResult GetRisksByCategory(int id)
        {
            var service = new RiskService();

            return(Json(service.GetRiskByCategory(id), JsonRequestBehavior.AllowGet));
        }