public static async Task <Person.Models.Person> GetNextApptforDoc(string tenant, string appname, string doctor)
        {
            //url from workflow:

            try
            {
                //prepare paramters to send to logic app by putting them into JSON
                //see article https://www.codeproject.com/Articles/1136839/Using-Azure-Logic-Apps-with-HTTP-Requests

                //json properties pulled from Request model (under Models folder)
                var json = new Request();
                json.properties = new Properties();

                json.properties.appname       = new AppName();
                json.properties.appname.value = appname;
                json.properties.appname.type  = "string";

                json.properties.tenant       = new Tenant();
                json.properties.tenant.value = tenant;
                json.properties.tenant.type  = "string";

                json.properties.doctor       = new Doctor();
                json.properties.doctor.value = doctor;
                json.properties.doctor.type  = "string";

                string jsonStr = JsonConvert.SerializeObject(json);
                string url     = "https://prod-20.eastus.logic.azure.com:443/workflows/61055bd24809473398ba94ad694a6f7b/triggers/request/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Frequest%2Frun&sv=1.0&sig=D54PpxSp4fi8PrrM8LeAo1jkCPsj-6Xq3h7Wrb5S4Rk";

                using (var client = new HttpClient())
                {
                    var content = new StringContent(jsonStr, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await client.PostAsync(url, content);

                    //HttpResponseMessage response = await client.GetAsync("/appname/" + encodedappname + "/doctor/" + doctor + "/tenant/" + encodedtenant);
                    if (response.IsSuccessStatusCode)
                    {
                        string data = await response.Content.ReadAsStringAsync();

                        Person.Models.Person nextPatient = JsonConvert.DeserializeObject <Person.Models.Person>(data);
                        return(nextPatient);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(null);
        }
Esempio n. 2
0
        public async Task GetNextAppt(IDialogContext context, LuisResult result)
        {
            try
            {
                //you have determined that the user is intending on finding their next patient \
                //so call the workflow function within the ServiceWrapper cs

                Person.Models.Person NextApptPatient = new Person.Models.Person();
                NextApptPatient = await ServiceWrapper.GetNextApptforDoc("GeannieandNicky", "Discharge", "1");

                //string replyText = "Your next appointment is with " + NextApptPatient.FName + " " + NextApptPatient.LastName + " at " + NextApptPatient.NextAppt.ToString();
                //create hero image with reply...


                Activity nextApptCard = (Activity)context.MakeMessage();

                List <CardImage> cardImages = new List <CardImage>();
                cardImages.Add(new CardImage(url: "http://img.s-msn.com/tenant/amp/entityid/AA2snpK?m=2&w=480&h=480&f=PNG&h=480&w=480&m=6&q=60&o=t&l=f"));

                nextApptCard.Recipient   = nextApptCard.Recipient;
                nextApptCard.Type        = "message";
                nextApptCard.Attachments = new List <Attachment>();

                ThumbnailCard patientCard = new ThumbnailCard()
                {
                    Title = "Your next appt. is with  " + NextApptPatient.FName + " " + NextApptPatient.LastName + ".",
                    //Subtitle = "Appointment Date/Time: " + NextApptPatient.NextAppt.ToString(),
                    Images = cardImages
                };

                Attachment patientAttachment = patientCard.ToAttachment();
                nextApptCard.Attachments.Add(patientAttachment);

                //change replyText to activity variable in order to send a card back
                await context.PostAsync(nextApptCard);

                Thread.Sleep(3000);
                //20170411 - Here I need to add code to start a child dialog asking user to set the context of the current user or not
                await context.PostAsync("If you are ready to start logging the visit for this patient, just tell me to add CC");
            }
            catch (Exception)
            {
                await context.PostAsync("Sorry, we couldn't find your next appointment or you don't have one");
            }
        }
        public static async Task <string> UpdatePerson(Person.Models.Person Patient)
        {
            var json = new OverviewRequest();

            json.properties = new OverviewProps();

            //json.properties.requestPerson = new Person.Models.Person();
            json.properties.requestPerson = Patient;

            string jsonStr = JsonConvert.SerializeObject(json);
            string url     = "https://prod-27.eastus.logic.azure.com:443/workflows/63b68fb6fa344ddc86b758078e17a90d/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=YWCTQQYNwXnwPfzVmSp5CMjdgPewFp2TGTfGWjVM_Ac";

            try
            {
                using (var client = new HttpClient())
                {
                    var content = new StringContent(jsonStr, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await client.PostAsync(url, content);

                    //HttpResponseMessage response = await client.GetAsync("/appname/" + encodedappname + "/doctor/" + doctor + "/tenant/" + encodedtenant);
                    if (response.IsSuccessStatusCode)
                    {
                        string data = await response.Content.ReadAsStringAsync();

                        //Person.Models.Person nextPatient = JsonConvert.DeserializeObject<Person.Models.Person>(data);
                        return(data);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(null);
        }
Esempio n. 4
0
        public async Task UpdatePatient(IDialogContext context, LuisResult result)
        {
            try
            {
                string patientName = string.Empty;
                string replyText   = string.Empty;

                //adding this to test pulling a name.
                List <Person.Models.Person> PeopleResults = new List <Person.Models.Person>();
                PeopleResults = await ServiceWrapper.GetPersonByName("Chris Baker");

                Person.Models.Person UpdPerson = new Person.Models.Person();
                UpdPerson = PeopleResults.First();

                try
                {
                    //extract height and weight from language
                    if (result.Entities.Count > 0)
                    {
                        UpdPerson.ChatHeight = "";
                        UpdPerson.ChatWeight = 0;

                        EntityRecommendation Heightfeet;
                        if (result.TryFindEntity("heightfeet", out Heightfeet))
                        {
                            UpdPerson.ChatHeight = Heightfeet.Entity;
                        }

                        EntityRecommendation Heightinches;
                        if (result.TryFindEntity("heightinches", out Heightinches))
                        {
                            UpdPerson.ChatHeight += "'" + Heightinches.Entity;
                        }

                        EntityRecommendation Weight;
                        if (result.TryFindEntity("weight", out Weight))
                        {
                            UpdPerson.ChatWeight = Convert.ToInt32(Weight.Entity);
                        }
                    }

                    //call Person API to update with Chat content
                    string workflowid = await ServiceWrapper.UpdatePerson(UpdPerson);

                    //IMessageActivity msg = Activity.CreateMessageActivity();
                    IMessageActivity msg = context.MakeMessage();
                    msg.Type  = "event";
                    msg.Value = "Update Patient";
                    msg.Text  = "Patient updated on the right. Confirm and/or make additonal changes in the form and then type confirm";


                    await context.PostAsync(msg.Text);

                    context.Done(workflowid);
                }
                catch (Exception)
                {
                    await context.PostAsync("Something really bad happened. You can try again later meanwhile I'll check what went wrong.");

                    context.Wait(MessageReceived);
                }
            }
            catch (Exception e)
            {
                await context.PostAsync(e.InnerException.Message);

                context.Wait(MessageReceived);
            }
        }