public async Task <string> GetPatient([FromQuery] string id, [FromQuery] string upn)
        {
            //GET consent for UPN
            // parse CONSENT and make sure it's active
            // [make sure it's unexpired]
            //GET patient ID=$id
            FHIRService fs = new FHIRService();

            var fhirconsent = await fs.GetConsent(id, upn);

            string isActive = (string)fhirconsent.SelectToken("entry.[0].resource.status");

            if (string.IsNullOrEmpty(isActive))
            {
                isActive = "false";
            }

            if (isActive.Equals("active"))
            {
                var patient = await fs.GetPatient(id);

                return(patient.ToString());
            }
            else
            {
                return("401 you don't have access or patient does not exsit");
            }
        }
Example #2
0
        public async Task <string> RemoveSchedules()
        {
            string json = "<b>Schedules with the following ID(s) are deleted: </b>";

            try
            {
                FHIRService fHIRService = new FHIRService();

                JObject jObj = await fHIRService.GetSchedules();



                var entry = jObj["entry"];
                var count = entry.Count();

                for (int i = 0; i < count; i++)
                {
                    string apptID = (string)entry[i]["resource"]["id"];
                    JsonConvert.SerializeObject(await fHIRService.DeleteSchedule(apptID));
                    json = json + " </br> " + apptID;
                }
            }
            catch (Exception ex)
            {
            }


            return(json);
        }
Example #3
0
        public async Task <string> Patients()
        {
            string json = "";

            try
            {
                patientList = new ArrayList();
                for (int i = 0; i < 5; i++)
                {
                    string jsonString = ReadFile("patient" + (i + 1 + ".json"));
                    if (string.IsNullOrEmpty(jsonString))
                    {
                        json = "Patient file not found.";
                    }
                    else
                    {
                        JObject apptObj = JObject.Parse(jsonString);

                        FHIRService fHIRService = new FHIRService();
                        JObject     jobj        = await fHIRService.CreatePatient(apptObj);

                        string id = (string)jobj["id"];
                        patientList.Add(id);
                        json = JsonConvert.SerializeObject(jobj);
                    }
                }
            }
            catch (Exception ex)
            {
            }


            return(json);
        }
Example #4
0
        public async Task <string> RemoveAppointments()
        {
            string json = "<b>Appointments with the following ID(s) are deleted: </b>";

            try
            {
                FHIRService fHIRService = new FHIRService();

                JObject jObj = await fHIRService.GetAppointments();

                List <Appointment> ApptList = new List <Appointment>();


                var entry = jObj["entry"];
                var count = entry.Count();

                for (int i = 0; i < count; i++)
                {
                    string apptID = (string)entry[i]["resource"]["id"];
                    JsonConvert.SerializeObject(await fHIRService.DeleteAppointment(apptID));
                    json = json + " </br> " + apptID;
                }



                //           json = JsonConvert.SerializeObject(await fHIRService.DeleteAppointment("82ef6987-c77e-4e26-8559-2b27f73a8ae9"));
            }
            catch (Exception ex)
            {
            }


            return(json);
        }
Example #5
0
        public async Task <string> GetAppointments()
        {
            FHIRService fHIRService = new FHIRService();
            string      json        = JsonConvert.SerializeObject(await fHIRService.GetAppointments());

            return(json);
        }
Example #6
0
        public async Task <string> RemovePractitioner()
        {
            string json = "<b>Practitioner with the following ID(s) are deleted: </b>";

            try
            {
                FHIRService fHIRService = new FHIRService();

                JObject jObj = await fHIRService.GetPractitioner();

                List <Appointment> ApptList = new List <Appointment>();

                //          var id = jObj["entry"][0]["resource"]["id"];
                var entry = jObj["entry"];
                var count = entry.Count();

                for (int i = 0; i < count; i++)
                {
                    //  Appointment appt = new Appointment { ID = (string)entry[i]["resource"]["id"] };
                    //  ApptList.Add(appt);
                    string apptID = (string)entry[i]["resource"]["id"];
                    JsonConvert.SerializeObject(await fHIRService.DeletePractitioner(apptID));
                    json = json + " </br> " + apptID;
                }
            }
            catch (Exception ex)
            {
            }


            return(json);
        }
Example #7
0
        public async Task <string> GetPractioner()
        {
            FHIRService fHIRService = new FHIRService();
            string      json        = JsonConvert.SerializeObject(await fHIRService.GetPractitioner());

            return(json);
        }
Example #8
0
        public async Task <Object> GetSchedules()
        {
            FHIRService fHIRService = new FHIRService();



            string json = JsonConvert.SerializeObject(await fHIRService.GetSchedules());

            return(json);
        }
Example #9
0
        public async Task <string> Schedules()
        {
            string json = "";

            try
            {
                //   practitionerList = new ArrayList();

                scheduleList = new ArrayList();
                for (int i = 0; i < 5; i++)
                {
                    //   practitionerList.Add("" + i);
                    string jsonString = ReadFile("schedule" + (1 + ".json"));
                    if (string.IsNullOrEmpty(jsonString))
                    {
                        json = "Schedule file not found.";
                    }
                    else
                    {
                        JObject apptObj = JObject.Parse(jsonString);
                        try
                        {
                            var practitioner = apptObj["actor"][0]["reference"];


                            apptObj["actor"][0]["reference"] = "Practitioner/" + practitionerList[i];
                        }
                        catch (Exception ex)
                        {
                        }


                        FHIRService fHIRService = new FHIRService();
                        JObject     jobj        = await fHIRService.CreateSchedule(apptObj);

                        string id = (string)jobj["id"];
                        scheduleList.Add(id);
                        json = JsonConvert.SerializeObject(jobj);
                    }
                }
            }
            catch (Exception ex)
            {
            }


            return(json);
        }
Example #10
0
        public async Task <string> Appointments()
        {
            string json = "";

            try
            {
                for (int i = 0; i < 5; i++)
                {
                    string jsonString = ReadFile("appointment" + (i + 1 + ".json"));
                    if (string.IsNullOrEmpty(jsonString))
                    {
                        json = apptFile + " in not found.";
                    }
                    else
                    {
                        JObject apptObj = JObject.Parse(jsonString);
                        try
                        {
                            var patient      = apptObj["participant"][0]["actor"]["reference"];
                            var practitioner = apptObj["participant"][1]["actor"]["reference"];
                            apptObj["participant"][0]["actor"]["reference"] = "Patient/" + patientList[i];
                            apptObj["participant"][1]["actor"]["reference"] = "Practitioner/" + practitionerList[i];
                        } catch (Exception ex)
                        {
                        }

                        FHIRService fHIRService = new FHIRService();
                        json = JsonConvert.SerializeObject(await fHIRService.CreateAppointment(apptObj));
                    }
                }
            } catch (Exception ex)
            {
            }


            return(json);
        }