예제 #1
0
        public static void CreateAssociateTickets(AnestheticServiceNote asn, AriClinicContext ctx)
        {
            // Does this customer have a primary policy with that service?
            Policy pol = PrimaryPolicy(asn.Customer);
            if (pol == null)
            {
                throw new AriCliException(1, "There isn't a primary policy for this customer");
            }
            // Delete all tickets
            ctx.Delete(asn.AnestheticTickets);
            foreach (Procedure proc in asn.Procedures)
            {
                // Does this policy includes related (from procedure) services
                InsuranceService ins = PolicyIncludesService(pol, proc.Service);
                if (ins == null)
                {
                    throw new AriCliException(3, "The insurance company have not the nomenclator service assigned");
                }
                // Everything seems ok, we can add anesthetic ticket
                AnestheticTicket atck = new AnestheticTicket()
                {
                    TicketDate = asn.ServiceNoteDate,
                    Description = String.Format("{0} ({1})", proc.Name, ins.Service.Name),
                    Amount = ins.Price,
                    Policy = pol,
                    InsuranceService = ins,
                    User = asn.User,
                    Clinic = asn.Clinic,
                    Professional = asn.Professional,
                    Surgeon = asn.Surgeon,
                    Procedure = proc,
                    AnestheticServiceNote = asn
                };
                ctx.Add(atck);
                ctx.SaveChanges();
            }

        }
예제 #2
0
 public static void ApplyPCA(AnestheticServiceNote asn, AriClinicContext ctx)
 {
     // Read parameters
     AriCliModel.Parameter parameter = GetParameter(ctx);
     Service painPump = parameter.PainPump;
     // Do we need check pain pump?
     if (painPump != null && asn.Chk1)
     {
         // Is there a pain pump assigned?
         var rs = from t in asn.AnestheticTickets
                  where t.InsuranceService.Service.ServiceId == painPump.ServiceId
                  select t;
         if (rs.Count() == 0)
         {
             // Does this customer have a primary policy with that service?
             Policy pol = PrimaryPolicy(asn.Customer);
             if (pol == null)
             {
                 throw new AriCliException(1, "There isn't a primary policy for this customer");
             }
             // Does this policy (insurance) includes a pain pump service?
             InsuranceService ins = PolicyIncludesService(pol, painPump);
             if (ins == null)
             {
                 throw new AriCliException(2, "The insurance company have not the pain pump service assigned");
             }
             // More expensive procedure
             AnestheticTicket aatck = asn.AnestheticTickets.OrderByDescending(x => x.Amount).FirstOrDefault<AnestheticTicket>();
             if (aatck != null)
             {
                 Procedure proc = aatck.Procedure;
                 // Everything seems ok, we can add the ticket
                 AnestheticTicket atck = new AnestheticTicket()
                 {
                     TicketDate = asn.ServiceNoteDate,
                     Description = String.Format("{0} ({1})", proc.Name, ins.Service.Name),
                     Amount = ins.Price,
                     Policy = pol,
                     InsuranceService = ins,
                     User = asn.User,
                     Clinic = asn.Clinic,
                     Professional = asn.Professional,
                     Surgeon = asn.Surgeon,
                     Procedure = proc,
                     AnestheticServiceNote = asn
                 };
                 ctx.Add(atck);
                 ctx.SaveChanges();
             }
         }
     }
 }
예제 #3
0
 public static bool IsItInChecks(AnestheticTicket atck, IList<SaveCheck> lsck)
 {
     bool res = false;
     SaveCheck sc = (from sck in lsck
                     where sck.ProcedureId == atck.Procedure.ProcedureId
                     select sck).FirstOrDefault<SaveCheck>();
     if (sc != null)
         res = true;
     return res;
 }
예제 #4
0
 public static void CheckAnestheticServiceNoteTickets(AnestheticServiceNote ansn, AriClinicContext ctx, IList<SaveCheck> lschk)
 {
     // Read parameters
     AriCliModel.Parameter parameter = GetParameter(ctx);
     Service painPump = parameter.PainPump;
     bool hRisk = ansn.Chk3;
     //
     AnestheticTicket anstk = null;
     // Do we need check pain pump?
     if (painPump != null && ansn.Chk1)
     {
         // Is there a pain pump assigned?
         var rs = from t in ansn.AnestheticTickets
                  where t.InsuranceService.Service.ServiceId == painPump.ServiceId
                  select t;
         if (rs.Count() == 0)
         {
             // Does this customer have a primary policy with that service?
             Policy pol = PrimaryPolicy(ansn.Customer);
             if (pol == null)
             {
                 throw new AriCliException(1, "There isn't a primary policy for this customer");
             }
             // Does this policy (insurance) includes a pain pump service?
             InsuranceService ins = PolicyIncludesService(pol, painPump);
             if (ins == null)
             {
                 throw new AriCliException(2, "The insurance company have not the pain pump service assigned");
             }
             // Everything seems ok, we can add the ticket
             anstk = new AnestheticTicket()
             {
                 TicketDate = ansn.ServiceNoteDate,
                 Description = String.Format("{0} ({1})", ansn.Procedures[0].Name, ins.Service.Name),
                 Amount = ins.Price,
                 Policy = pol,
                 InsuranceService = ins,
                 User = ansn.User,
                 Clinic = ansn.Clinic,
                 Professional = ansn.Professional,
                 Surgeon = ansn.Surgeon,
                 Procedure = ansn.Procedures[0],
                 AnestheticServiceNote = ansn
             };
             if (ansn.Chk2)
             {
                 anstk.Checked = true;
             }
             else
             {
                 anstk.Checked = CntAriCli.IsItInChecks(anstk, lschk);
             }
             if (hRisk)
                 anstk.Amount = anstk.Amount * 1.5M; // increase 50%
             ctx.Add(anstk);
     
             ctx.SaveChanges();
         }
     }
     // Do we need check procedure - service link?
     if (parameter.UseNomenclator)
     {
         bool multi = false;
         foreach (Procedure p in ansn.Procedures)
         {
             AddAutomaticTicket(ansn, p, ctx, multi, lschk);
             multi = true;
         }
     }
 }
예제 #5
0
 public static void AddAutomaticTicket(AnestheticServiceNote ansn, Procedure proc, AriClinicContext ctx, bool multi, IList<SaveCheck> lschk)
 {
     // Does this customer have a primary policy with that service?
     Policy pol = PrimaryPolicy(ansn.Customer);
     bool hRisk = ansn.Chk3;
     if (pol == null)
     {
         throw new AriCliException(1, "There isn't a primary policy for this customer");
     }
     // Does this policy includes related (from procedure) services
     InsuranceService ins = PolicyIncludesService(pol, proc.Service);
     if (ins == null)
     {
         throw new AriCliException(3, "The insurance company have not the nomenclator service assigned");
     }
     // Everything seems ok, we can add anesthetic ticket
     AnestheticTicket anstk = new AnestheticTicket()
     {
         TicketDate = ansn.ServiceNoteDate,
         Description = String.Format("{0} ({1})", proc.Name, ins.Service.Name),
         Amount = ins.Price,
         Policy = pol,
         InsuranceService = ins,
         User = ansn.User,
         Clinic = ansn.Clinic,
         Professional = ansn.Professional,
         Surgeon = ansn.Surgeon,
         Procedure = proc,
         AnestheticServiceNote = ansn
     };
     if (ansn.Chk2)
     {
         anstk.Checked = true;
     }
     else
     {
         anstk.Checked = CntAriCli.IsItInChecks(anstk, lschk);
     }
     if (multi)
     {
         anstk.Amount = anstk.Amount / 2;
         anstk.Comments = "-50%";
     }
     if (hRisk)
         anstk.Amount = anstk.Amount * 1.5M; // high risk increase 50%
     ctx.Add(anstk);
     ctx.SaveChanges();
 }