Exemplo n.º 1
0
        public HttpResponseMessage SaveUpdates([FromBody] string ClaimUpdateDTO)
        {
            HttpResponseMessage message     = new HttpResponseMessage();
            Claim_Update        claimUpdate = new Claim_Update();

            try
            {
                dynamic claimupdateDto = JObject.Parse(ClaimUpdateDTO);

                claimUpdate = ((JObject)claimupdateDto.claimUpdate).ToObject <Claim_Update>();
                Claim_Updates_Billing updatesBilling = ((JObject)claimupdateDto.claimUpdatesBilling).ToObject <Claim_Updates_Billing>();
                claimUpdate.DateTimeSubmitted_ = DateTime.UtcNow;
                context.Claim_Updates.InsertOnSubmit(claimUpdate);
                context.SubmitChanges(); //submit because the claim update id is needed for foreign key

                //set billing update foreign key to claim updateID
                updatesBilling.UpdateID = claimUpdate.UpdateID;
                context.Claim_Updates_Billings.InsertOnSubmit(updatesBilling);
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message));
            }
            message.StatusCode = HttpStatusCode.Created;
            message.Content    = new StringContent(claimUpdate.UpdateID.ToString());
            return(message);
        }
Exemplo n.º 2
0
        public void SendCMRReportToClient(int UpdateID)
        {
            SmtpClient       smtp = new SmtpClient();
            MailMessage      mm;
            Claim_Update_Cmr cmr = _ctx.Claim_Update_Cmrs.SingleOrDefault(i => i.UpdateID == UpdateID);

            if (cmr == null)
            {
                return;
            }


            Claim_Update  claimUpdate     = _ctx.Claim_Updates.SingleOrDefault(i => i.UpdateID == UpdateID);
            Claim_Contact EmployerContact = _ctx.Claim_Contacts.SingleOrDefault(i => i.ContactID == cmr.EmployerContactID);
            Claim_Emp_ContactTypeDetail EmployeeContact = _ctx.Claim_Emp_ContactTypeDetails.SingleOrDefault(i => i.EmpID == cmr.EmployeeContactID);
            List_ClaimStatus            claimStatus     = _ctx.List_ClaimStatus.SingleOrDefault(i => i.index == cmr.ClaimStatusID);
            List <string> emails     = new List <string>();
            User_Profile  OSIContact = _ctx.User_Profiles.SingleOrDefault(i => i.UserID == cmr.OSIContactID);

            //emails.Add(EmployerContact.Con_Email);
            //emails.Add(EmployeeContact.ContactDetail);
            emails.Add("EmailHere");
            //create email body
            string EmailTemplate = File.ReadAllText(HostingEnvironment.MapPath(@"~/EmailTemplates/CMREmailTemplate.html"));

            EmailTemplate = EmailTemplate.Replace(" {{ReportedComments}}", claimUpdate.ReportedComments);

            //create cmr pdf
            string cmrhtml = File.ReadAllText(HostingEnvironment.MapPath(@"~/EmailTemplates/CMRTemplate.html"));

            cmrhtml = cmrhtml.Replace("{{ClaimStatus}}", claimStatus.Status_EN);
            cmrhtml = cmrhtml.Replace("{{DateOfReport}}", cmr.DateOfReport.ToLongDateString());
            cmrhtml = cmrhtml.Replace("{{EmployeeName}}", cmr.EmployeeName);
            cmrhtml = cmrhtml.Replace("{{EmployeeEmail}}", EmployeeContact.ContactDetail);
            cmrhtml = cmrhtml.Replace("{{EmployeeID}}", cmr.EmployeeID.ToString());
            cmrhtml = cmrhtml.Replace("{{ReferalDate}}", cmr.DateOfReferal.ToLongDateString());
            cmrhtml = cmrhtml.Replace("{{Location}}", cmr.Location);
            cmrhtml = cmrhtml.Replace("{{AbsenceDate}}", cmr.DateOfAbsence.ToLongDateString());
            cmrhtml = cmrhtml.Replace("{{EmployerContact}}", EmployerContact.Con_Email);
            cmrhtml = cmrhtml.Replace("{{OSIContact}}", OSIContact.Email);
            cmrhtml = cmrhtml.Replace("{{HistoryInformation}}", cmr.ClaimHistoryInformation);
            cmrhtml = cmrhtml.Replace("{{AbsenceAuthorization}}", cmr.AbsenceAuthorization);
            cmrhtml = cmrhtml.Replace("{{TreatmentPlan}}", cmr.TreatmentPlan);
            cmrhtml = cmrhtml.Replace("{{Recommendations}}", cmr.ReturntoWorkRecommendations);
            cmrhtml = cmrhtml.Replace("{{NextSteps}}", cmr.NextSteps);

            string FilePath = HostingEnvironment.MapPath(@"~/TempFiles/ClaimUpdate" + claimUpdate.ClaimRefNu + "-" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf");
            string Html     = "<html><head><title></title><style>" + File.ReadAllText(HostingEnvironment.MapPath(@"~/Content/bootstrap.min.css")) + "</style></head><body>" + cmrhtml + "</body></html>";
            var    pdf      = Pdf
                              .From(Html)
                              .OfSize(PaperSize.A4)
                              .Content();

            System.IO.File.WriteAllBytes(FilePath, pdf);

            foreach (string email in emails)
            {
                smtp.UseDefaultCredentials = false;
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtp.Credentials           = new NetworkCredential("noreply", "44bananas55$");
                smtp.Host      = "connect.orgsoln.com"; //Change for smtp from OSI
                smtp.EnableSsl = false;
                smtp.Port      = 25;

                mm            = new MailMessage("*****@*****.**", email);
                mm.Subject    = "Claim update for " + claimUpdate.ClaimRefNu;
                mm.IsBodyHtml = true;
                mm.Body       = EmailTemplate;

                mm.Attachments.Add(new Attachment(FilePath));
                smtp.Send(mm);
                smtp.Dispose();
                mm.Attachments.Dispose();

                File.Delete(FilePath);
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage ArchiveClaimUpdateAndBilling([FromBody] string UpdatesBilling, int updateID, string Token)
        {
            //insert into archive table
            Claim_Update          claimUpdate    = _ctx.Claim_Updates.Single(i => i.UpdateID == updateID);
            Claim_Updates_Billing updatesBilling = _ctx.Claim_Updates_Billings.Single(i => i.UpdateID == updateID);
            Session session = _ctx.Sessions.FirstOrDefault(i => i.SessionToken == Token);


            Claim_Updates_Billing_PR_Archive archive = new Claim_Updates_Billing_PR_Archive()
            {
                UserID           = claimUpdate.UserID,
                ClaimRefNu       = claimUpdate.ClaimRefNu,
                ActionType       = claimUpdate.ActionType,
                Archived_By      = Convert.ToInt32(session.UserID),
                BillID           = updatesBilling.BillID,
                Billable         = claimUpdate.Billable,
                Comments         = updatesBilling.Comments,
                Completed        = updatesBilling.Completed,
                CompletionDate   = updatesBilling.CompletionDate,
                Courier          = updatesBilling.Courier,
                Date_Archived    = DateTime.Now,
                DirectContact    = updatesBilling.DirectContact,
                Duration         = updatesBilling.Duration,
                EmployeeComments = claimUpdate.EmployeeComments,
                InternalComments = claimUpdate.InternalComments,
                IsArchived       = claimUpdate.IsArchived,
                IsInReview       = true,
                Method           = updatesBilling.Method,
                Postage          = updatesBilling.Postage,
                Reason           = updatesBilling.Reason,
                ReportedComments = claimUpdate.ReportedComments,
                UpdateBy         = Convert.ToInt32(session.UserID),
                UpdateId         = claimUpdate.UpdateID,
                UpdatesDate      = claimUpdate.UpdatesDate,
                SeniorConsulting = updatesBilling.SeniorConsulting
            };

            _ctx.Claim_Updates_Billing_PR_Archives.InsertOnSubmit(archive);
            _ctx.SubmitChanges();



            dynamic updates = JsonConvert.DeserializeObject(UpdatesBilling);

            claimUpdate.InternalComments = updates.InternalComments;
            claimUpdate.ReportedComments = updates.ReportedComments;
            claimUpdate.EmployeeComments = updates.EmployeeComments;
            claimUpdate.Billable         = updates.Billable;

            updatesBilling.CompletionDate   = Convert.ToDateTime(updates.CompletionDate);
            updatesBilling.DirectContact    = Convert.ToBoolean(updates.DirectContact);
            updatesBilling.Postage          = Convert.ToBoolean(updates.Postage);
            updatesBilling.Courier          = Convert.ToBoolean(updates.Courier);
            updatesBilling.Method           = updates.Method;
            updatesBilling.Reason           = updates.Reason;
            updatesBilling.Duration         = updates.Duration;
            updatesBilling.Comments         = updates.Comments;
            updatesBilling.SeniorConsulting = updates.SeniorConsulting;

            _ctx.SubmitChanges();


            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent("")
            });
        }
Exemplo n.º 4
0
        public HttpResponseMessage ArchiveUpdate(string token, int updateID)
        {
            Claim_Update claimUpdate = context.Claim_Updates.Single(i => i.UpdateID == updateID);
            Session      session     = context.Sessions.FirstOrDefault(i => i.SessionToken == token);

            if (claimUpdate.DateTimeSubmitted_ < DateTime.UtcNow.AddHours(-2))
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    Content = new StringContent("Claim update exceeded 2 hours old, cannot be archived.")
                });
            }

            if (claimUpdate.UserID != Convert.ToInt32(session.UserID))
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    Content = new StringContent("You did not create this claim update. you cannot delete it")
                });
            }
            Claim_Updates_Billing            updatesBilling   = context.Claim_Updates_Billings.Single(i => i.UpdateID == updateID);
            Claim_Update_Cmr                 oldCMR           = context.Claim_Update_Cmrs.SingleOrDefault(i => i.UpdateID == updateID);
            List <Claim_Updates_Document>    updatesDocuments = context.Claim_Updates_Documents.Where(i => i.UpdateID == updateID).ToList();
            Claim_Peer_Review                peerReview       = context.Claim_Peer_Reviews.SingleOrDefault(i => i.Update_ID == updateID);
            Claim_Updates_Billing_PR_Archive archive          = new Claim_Updates_Billing_PR_Archive()
            {
                UserID           = claimUpdate.UserID,
                ClaimRefNu       = claimUpdate.ClaimRefNu,
                ActionType       = claimUpdate.ActionType,
                Archived_By      = Convert.ToInt32(session.UserID),
                BillID           = updatesBilling.BillID,
                Billable         = claimUpdate.Billable,
                Comments         = updatesBilling.Comments,
                Completed        = updatesBilling.Completed,
                CompletionDate   = updatesBilling.CompletionDate,
                Courier          = updatesBilling.Courier,
                Date_Archived    = DateTime.Now,
                DirectContact    = updatesBilling.DirectContact,
                Duration         = updatesBilling.Duration,
                EmployeeComments = claimUpdate.EmployeeComments,
                InternalComments = claimUpdate.InternalComments,
                IsArchived       = claimUpdate.IsArchived,
                IsInReview       = false,
                Method           = updatesBilling.Method,
                Postage          = updatesBilling.Postage,
                Reason           = updatesBilling.Reason,
                ReportedComments = claimUpdate.ReportedComments,
                UpdateBy         = Convert.ToInt32(session.UserID),
                UpdateId         = claimUpdate.UpdateID,
                UpdatesDate      = claimUpdate.UpdatesDate,
                SeniorConsulting = updatesBilling.SeniorConsulting
            };

            if (oldCMR != null)
            {
                Claim_Update_Cmr_Archive cmrarchive = new Claim_Update_Cmr_Archive()
                {
                    UserID                      = oldCMR.UserID,
                    UpdateID                    = oldCMR.UpdateID,
                    AbsenceAuthorization        = oldCMR.AbsenceAuthorization,
                    ArchiveDate                 = DateTime.Now,
                    ArchivedBy                  = Convert.ToInt32(session.UserID),
                    ClaimHistoryInformation     = oldCMR.ClaimHistoryInformation,
                    ClaimStatusID               = oldCMR.ClaimStatusID,
                    DateOfAbsence               = oldCMR.DateOfAbsence,
                    DateOfReferal               = oldCMR.DateOfReferal,
                    DateOfReport                = oldCMR.DateOfReport,
                    EmployeeID                  = oldCMR.EmployeeID,
                    EmployeeName                = oldCMR.EmployeeName,
                    EmployerContactID           = oldCMR.EmployerContactID,
                    Location                    = oldCMR.Location,
                    NextSteps                   = oldCMR.NextSteps,
                    OSIContactID                = oldCMR.OSIContactID,
                    ReturntoWorkRecommendations = oldCMR.ReturntoWorkRecommendations,
                    TreatmentPlan               = oldCMR.TreatmentPlan
                };
                context.Claim_Update_Cmr_Archives.InsertOnSubmit(cmrarchive);
            }
            foreach (Claim_Updates_Document doc in updatesDocuments)
            {
                Claim_Updates_Documents_Archive docarchive = new Claim_Updates_Documents_Archive()
                {
                    UserID         = doc.UserID,
                    UpdateID       = doc.UpdateID,
                    ArchivedBy     = Convert.ToInt32(session.UserID),
                    ClaimReference = doc.ClaimReference,
                    DateArchived   = DateTime.Now,
                    DocumentID     = doc.DocumentID,
                    FileExt        = doc.FileExt,
                    FileName       = doc.FileName,
                    Timestamp      = doc.Timestamp,
                    VersionNumber  = doc.VersionNumber
                };
                context.Claim_Updates_Documents_Archives.InsertOnSubmit(docarchive);
            }
            if (peerReview != null)
            {
                context.Claim_Peer_Reviews.DeleteOnSubmit(peerReview);
            }
            context.Claim_Updates_Billing_PR_Archives.InsertOnSubmit(archive);
            context.SubmitChanges();
            context.Claim_Updates.DeleteOnSubmit(claimUpdate);
            context.Claim_Updates_Billings.DeleteOnSubmit(updatesBilling);
            if (oldCMR != null)
            {
                context.Claim_Update_Cmrs.DeleteOnSubmit(oldCMR);
            }
            foreach (Claim_Updates_Document doc in updatesDocuments)
            {
                context.Claim_Updates_Documents.DeleteOnSubmit(doc);
            }
            context.SubmitChanges();

            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent("Claim update and child records successfuly archived")
            });
        }