Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using System.Windows.Media.Imaging;
  7. using Healix.Forms.BaseControls;
  8. using Healix.Wpf.Forms.AssessmentClaims.Events;
  9. using Healix.Wpf.Parts.ClaimClosureCheckList.Events;
  10. using HIHWebAPI;
  11. using HIHWebAPI.Models;
  12.  
  13. namespace Healix.Wpf.Parts.ClaimClosureCheckList.Models
  14. {
  15.     public class ClaimClosureCheckListModel
  16.     {
  17.         public ClaimClosureCheckListModel(int claimId, int memberId)
  18.         {
  19.             _claimId = claimId;
  20.             MemberId = memberId;
  21.  
  22.             Entity = HihFacade.WebAPI.ClosureChecklistOperations.GetByClaimId(claimId) ?? new ClosureChecklist() { ClaimId = claimId };
  23.             ClaimClosureChecklistResult = HihFacade.WebAPI.ClosureChecklistOperations.GetClaimClosureChecklist(claimId) ?? new ClaimClosureChecklistResult();
  24.             ClosureChecklistOperations = HihFacade.WebAPI.ClosureChecklistOperations;
  25.         }
  26.  
  27.         private IClosureChecklistOperations ClosureChecklistOperations;
  28.         private int _claimId;
  29.         private ClosureChecklist Entity { get; set; }
  30.         private ClaimClosureChecklistResult ClaimClosureChecklistResult { get; set; }
  31.  
  32.         public int Id
  33.         {
  34.             get => Entity.Id;
  35.             set
  36.             {
  37.                 Entity.Id = value;
  38.                 NotifyPropertyChanged(nameof(Id));
  39.             }
  40.         }
  41.  
  42.         private int MemberId { get; set; }
  43.  
  44.         public int ClaimId
  45.         {
  46.             get => Entity.ClaimId;
  47.             set
  48.             {
  49.                 Entity.ClaimId = value;
  50.                 NotifyPropertyChanged(nameof(ClaimId));
  51.             }
  52.         }
  53.  
  54.  
  55.         public bool IsProjectedCost
  56.         {
  57.             get => Entity.IsProjectedCost ?? false;
  58.             set
  59.             {
  60.                 Entity.IsProjectedCost = value;
  61.                 UnchekTickToConfirmChecklistComplete(value);
  62.                 Entity = ClosureChecklistOperations.AddEdit(Entity);
  63.                 NotifyPropertyChanged(nameof(IsProjectedCost));
  64.                 NotifyPropertyChanged(nameof(IsTickToConfirmChecklistCompleteEnabled));
  65.             }
  66.         }
  67.  
  68.         public bool IsSapSetUp
  69.         {
  70.             get => Entity.IsSapSetUp ?? false;
  71.             set
  72.             {
  73.                 Entity.IsSapSetUp = value;
  74.                 UnchekTickToConfirmChecklistComplete(value);
  75.                 Entity = ClosureChecklistOperations.AddEdit(Entity);
  76.                 NotifyPropertyChanged(nameof(IsSapSetUp));
  77.                 NotifyPropertyChanged(nameof(IsTickToConfirmChecklistCompleteEnabled));
  78.             }
  79.         }
  80.  
  81.         public bool? IsAdmissionDateAndDischargeDateSelected
  82.         {
  83.             get => Entity.IsAdmissionDateAndDischargeDateSelected;
  84.             set
  85.             {
  86.                 Entity.IsAdmissionDateAndDischargeDateSelected = value;
  87.                 Entity = ClosureChecklistOperations.AddEdit(Entity);
  88.                 NotifyPropertyChanged(nameof(IsAdmissionDateAndDischargeDateSelected));
  89.                 NotifyPropertyChanged(nameof(IsTickToConfirmChecklistCompleteEnabled));
  90.                 //NotifyPropertyChanged(nameof(IsAdmissionDateAndDischargeDate));
  91.  
  92.                 //UnchekTickToConfirmChecklistComplete(IsAdmissionDateAndDischargeDate);
  93.             }
  94.         }
  95.  
  96.         //public bool IsAdmissionDateAndDischargeDate
  97.         //{
  98.         //    get => (IsAdmissionDateAndDischargeDateSelected == false) || (IsAdmissionDateAndDischargeDateSelected == true) && IsInpatientDates;
  99.         //}
  100.  
  101.         public bool IsRecoveryTabCompletedAppropriately
  102.         {
  103.             get => (Entity.IsRecoveryTabCompletedAppropriately ?? false);
  104.             set
  105.             {
  106.                 Entity.IsRecoveryTabCompletedAppropriately = value;
  107.                 UnchekTickToConfirmChecklistComplete(value);
  108.                 Entity = ClosureChecklistOperations.AddEdit(Entity);
  109.                 NotifyPropertyChanged(nameof(IsRecoveryTabCompletedAppropriately));
  110.                 NotifyPropertyChanged(nameof(IsTickToConfirmChecklistCompleteEnabled));
  111.             }
  112.         }
  113.  
  114.         public bool IsFinalCourtesyCall
  115.         {
  116.             get => Entity.IsFinalCourtesyCall ?? false;
  117.             set
  118.             {
  119.                 Entity.IsFinalCourtesyCall = value;
  120.                 UnchekTickToConfirmChecklistComplete(value);
  121.                 Entity = ClosureChecklistOperations.AddEdit(Entity);
  122.                 NotifyPropertyChanged(nameof(IsFinalCourtesyCall));
  123.                 NotifyPropertyChanged(nameof(IsTickToConfirmChecklistCompleteEnabled));
  124.             }
  125.         }
  126.  
  127.         public bool IsTickToConfirmChecklistCompleteEnabled
  128.         {
  129.             get => IsProjectedCost
  130.                    && IsSapSetUp
  131.                    && IsRecoveryTabCompletedAppropriately
  132.                    && ((IsAdmissionDateAndDischargeDateSelected == false) || (IsAdmissionDateAndDischargeDateSelected == true) && IsInpatientDates);
  133.         }
  134.  
  135.         public bool IsTickToConfirmChecklistComplete
  136.         {
  137.             get => Entity.IsTickToConfirmChecklistComplete ?? false;
  138.             set
  139.             {
  140.                 if (value)
  141.                 {
  142.                     MessageBox.Show("To complete the closure process please update the Claim Status and ensure a final update is sent to the Underwriter.", Properties.Resources.DialogCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
  143.                     Cursor.Current = Cursors.WaitCursor;
  144.                     var cmd = new CmsCommand
  145.                     {
  146.                         MethodName = "CreateChecklistCompletedAction",
  147.                         UserName = ProgramBase.UserInfo?.DisplayName,
  148.                         UserId = ProgramBase.UserId
  149.                     };
  150.  
  151.                     cmd["ClaimId"] = ClaimId;
  152.                     cmd["MemberId"] = MemberId;
  153.                     TaskRuner.HIHFacade.Invoke(f => f.Execute(cmd));
  154.  
  155.                     Cursor.Current = Cursors.Default;
  156.                 }
  157.  
  158.                 Entity.IsTickToConfirmChecklistComplete = value;
  159.                 Entity = ClosureChecklistOperations.AddEdit(Entity);
  160.                 NotifyPropertyChanged(nameof(IsTickToConfirmChecklistComplete));
  161.  
  162.                 if(value)
  163.                     ClaimDetailEditModeEvent.RaiseEvent(this, new GenericEventArgs<int>(_claimId));
  164.             }
  165.         }
  166.  
  167.         public bool IsMembershipVisible
  168.         {
  169.             get => ClaimClosureChecklistResult.MembershipResultList != null && ClaimClosureChecklistResult.MembershipResultList.Count > 1;
  170.         }
  171.  
  172.         public bool IsPolicyVerified
  173.         {
  174.             get => ClaimClosureChecklistResult.CheckboxResultList.Any(c => c.IsPolicyVerified);
  175.         }
  176.  
  177.         public string CoverDecision
  178.         {
  179.             get => ClaimClosureChecklistResult.ActionTypeResultList.FirstOrDefault(_ => _.CoverDecisionDescription != "0")?.CoverDecisionDescription;
  180.         }
  181.  
  182.         public bool IsCoverDecisionMultipleVisible
  183.         {
  184.             get => ClaimClosureChecklistResult.ActionTypeResultList.Count(_ => _.CoverDecisionDescription != "0") > 1;
  185.         }
  186.  
  187.         public string AssessmentOutcome
  188.         {
  189.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.AssessmentOutcome;
  190.         }
  191.  
  192.         public string Excess
  193.         {
  194.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.Excess;
  195.         }
  196.  
  197.         public bool? IsReciprocalHealthAgreement
  198.         {
  199.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.IsReciprocalHealthAgreement ?? false;
  200.         }
  201.  
  202.         public string ProjectedCost
  203.         {
  204.             get => Math.Round(ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ProjectedCost ?? 0, 2).ToString();
  205.         }
  206.  
  207.         public string ClientClaimRef
  208.         {
  209.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ClientClaimRef;
  210.         }
  211.  
  212.         public bool? IsSapMembership
  213.         {
  214.             get => ClaimClosureChecklistResult.MembershipResultList.Count > 0 && ClaimClosureChecklistResult.MembershipResultList.FirstOrDefault(_ => _.SAPlans != 0)?.SAPlans != null;
  215.         }
  216.  
  217.         public string AdmissionDate
  218.         {
  219.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.AdmissionDate?.ToString("dd/MM/yyyy");
  220.         }
  221.         public string DischargeDate
  222.         {
  223.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.DischargeDate?.ToString("dd/MM/yyyy");
  224.         }
  225.  
  226.         public bool IsInpatientDates
  227.         {
  228.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.AdmissionDate != null &&
  229.                    ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.DischargeDate != null;
  230.         }
  231.  
  232.         public string LatestSummary
  233.         {
  234.             get => ClaimClosureChecklistResult.ActionTypeResultList.FirstOrDefault(_ => _.LatestSummaryDescription != "0")?.LatestSummaryDescription;
  235.         }
  236.  
  237.         public bool IsComplaintNotificationSent
  238.         {
  239.             get => ClaimClosureChecklistResult.CheckboxResultList.Any(c => c.IsComplaintNotificationSent);
  240.         }
  241.  
  242.         public bool IsHCNSent
  243.         {
  244.             get => CheckIsHCNSent(ClaimClosureChecklistResult.ActionTypeResultList);
  245.         }
  246.  
  247.         private bool CheckIsHCNSent(IList<ActionTypeResult> actionList)
  248.         {
  249.             var HCNSentDate = ClaimClosureChecklistResult.ActionTypeResultList
  250.                 .FirstOrDefault(t => t.HCNSentDescription != "0" && t.HCNSentDescription.Contains("sent"))?.CreatedOn;
  251.             var projectedCostChangedDate = ClaimClosureChecklistResult.ActionTypeResultList
  252.                 .FirstOrDefault(t => t.ProjectedCostChangedDescription != "0")?.CreatedOn;
  253.  
  254.             if (HCNSentDate != null && projectedCostChangedDate != null && HCNSentDate > projectedCostChangedDate)
  255.                 return true;
  256.             else return false;
  257.         }
  258.  
  259.         public bool? UnderwriterReferenceReq
  260.         {
  261.             get => ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.UnderwriterReferenceReq;
  262.         }
  263.  
  264.         public bool IsClientClaimRef
  265.         {
  266.             get => !string.IsNullOrEmpty(ClientClaimRef) || (UnderwriterReferenceReq ?? false);
  267.         }
  268.  
  269.         public bool IsClientClaimRefRed
  270.         {
  271.             get => string.IsNullOrEmpty(ClientClaimRef) && (UnderwriterReferenceReq ?? false);
  272.         }
  273.  
  274.         public BitmapSource WarningImage
  275.         {
  276.             get
  277.             {
  278.                 return Properties.Resources.WarningIconSmall.ToWpfBitmap();
  279.             }
  280.         }
  281.  
  282.         public string SapMembershipText
  283.         {
  284.             get => (IsSapMembership ?? false) ? Properties.Resources.SapMembershipTextChecked : Properties.Resources.SapMembershipTextUnchecked;
  285.         }
  286.  
  287.         public bool? HCNSentCheckBoxState
  288.         {
  289.             get
  290.             {
  291.                 return !IsHCNSent &&
  292.                        (ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ClaimCostThreshold == 0 ||
  293.                        (ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ProjectedCost <
  294.                         ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ClaimCostThreshold))
  295.                     ? (bool?) null
  296.                     : (!IsHCNSent &&
  297.                        (ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ProjectedCost >=
  298.                         ClaimClosureChecklistResult.ClaimDetailResultList.FirstOrDefault()?.ClaimCostThreshold))
  299.                         ? false
  300.                         : true;
  301.             }
  302.             //get => null;
  303.             //get => false;
  304.             //get => true;
  305.         }
  306.  
  307.         public bool IsActiveComplaint
  308.         {
  309.             get => ClaimClosureChecklistResult.CheckboxResultList.Any(c => c.IsActiveComplaint);
  310.         }
  311.  
  312.         public bool? ComplaintNotificationSentCheckBoxState
  313.         {
  314.             get => !IsActiveComplaint
  315.                     ? (bool?)null
  316.                     : (IsComplaintNotificationSent ? true : false);
  317.             //get => null;
  318.             //get => false;
  319.             //get => true;
  320.         }
  321.  
  322.         void UnchekTickToConfirmChecklistComplete(bool b)
  323.         {
  324.             if (!b && IsTickToConfirmChecklistComplete)
  325.                 IsTickToConfirmChecklistComplete = b;
  326.         }
  327.  
  328.         public event PropertyChangedEventHandler PropertyChanged;
  329.         internal void NotifyPropertyChanged(string propertyName)
  330.         {
  331.             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  332.         }
  333.     }
  334. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement