Ejemplo n.º 1
0
        /// <summary>
        /// Get a collection of practitioner given parameter
        /// </summary>
        /// <param name="para"> a string of content to be filtered </param>
        /// <returns> a collection of practitioner </returns>
        public async Task <IEnumerable <IPractitioner> > GetPractitionersAsync(string para = "")
        {
            var responseString = await client.GetStringAsync(PRACTITIONER_PAGE + para);

            var jObject       = JObject.Parse(responseString);
            var practitioners = new List <IPractitioner>();
            var array         = jObject["entry"].Children <JObject>();

            // Parsing the data in each json entry and add them into the practitioner list
            foreach (var o in array)
            {
                PractitionerParser practitionerParser = new PractitionerParser();
                var toParse = (JObject)o["resource"];
                // Certain practitioner does not have address so only include those have address
                var checkProperty = toParse.ContainsKey("address");
                if (checkProperty)
                {
                    practitioners.Add(practitionerParser.Parse(toParse));
                }
            }
            return(practitioners);
        }