Exemplo n.º 1
0
        public static BenefitsInformation GetBenefitsInformation(string planId, string keyword)
        {
            BenefitsInformation benefitsInformation = null;

            try
            {
                JObject memberJSON = SendApiRequest($"GetAnswerToUserQuery?id={planId}&keywords={keyword}", null);
                benefitsInformation = JsonConvert.DeserializeObject <BenefitsInformation>(memberJSON.ToString());
            }
            catch (Exception exception)
            {
            }
            return(benefitsInformation);
        }
        public async Task Member_Benefits(IDialogContext context, LuisResult luisResult)
        {
            if (null == Member || null == Member.activePlan)
            {
                await context.PostAsync($"No member or plan found");
            }
            else
            {
                EntityRecommendation benefitRecommendation;


                if (luisResult.TryFindEntity("Benefit", out benefitRecommendation))
                {
                    Benefit = benefitRecommendation.Entity;
                }

                if (string.IsNullOrEmpty(Benefit))
                {
                    await context.PostAsync($"Sorry I did not understand service you are looking for, We have recorded your query. Can you please try with some other words ?");
                }
                else
                {
                    EntityRecommendation costRecommendation;

                    if (luisResult.TryFindEntity("CostType", out costRecommendation))
                    {
                        CostType = costRecommendation.Entity;
                    }

                    BenefitsInformation benefitsInformation = Helper.GetBenefitsInformation(Member.activePlan.PlanId, Benefit);

                    if (benefitsInformation.BenefitsCovered)
                    {
                        await context.PostAsync($"Member is **covered** for {Benefit}{Environment.NewLine} *please find below benefits*");

                        var bmessage = context.MakeMessage();
                        bmessage.Attachments =
                            Helper.GetBenefitsCard(benefitsInformation.Benefits);
                        bmessage.AttachmentLayout = "carousel";
                        await context.PostAsync(bmessage);

                        if (string.IsNullOrEmpty(CostType))
                        {
                            PromptDialog.Choice(context,
                                                CostSelected,
                                                new List <string>()
                            {
                                "CoPay",
                                "CoInsurance",
                                "Deductible"
                            },
                                                "What do you want to know?", "What do you want to know?", 3);
                        }
                        else
                        {
                            Cost cost    = Helper.GetCostDetails(Member.activePlan.EnrollId, CostType);
                            var  message = context.MakeMessage();
                            message.Attachments = new List <Attachment>
                            {
                                Helper.GetCostCard(cost).ToAttachment()
                            };
                            message.AttachmentLayout = "carousel";

                            await context.PostAsync(message);

                            CostType = string.Empty;

                            context.Wait(this.MessageReceived);
                        }
                    }
                    else
                    {
                        await context.PostAsync($"{Benefit} is not covered");

                        CostType = string.Empty;

                        context.Wait(this.MessageReceived);
                    }
                }
            }
        }