/// <summary> /// Queries the Google Health Profile Register feed for the list of notices. This /// is for ClientLogin related queries. /// </summary> /// <param name="profileId">The profile to query against.</param> /// <returns>The list of notices available on this profile.</returns> public List <Notice> GetNotices(string profileId) { HealthQuery query = new HealthQuery(RegisterFeed + profileId); query.Digest = true; HealthFeed feed = this.Query(query); List <Notice> notices = new List <Notice>(); foreach (AtomEntry entry in feed.Entries) { notices.Add(Notice.FromAtomEntry(entry)); } return(notices); }
/// <summary> /// Queries the profile feed for the list of available CCR records. Available /// for ClientLogin related queries. /// </summary> /// <param name="profileId">The profile to query against.</param> /// <param name="digest">True to aggregate all CCR into a single CCR element, false otherwise.</param> /// <returns>The list of CCR records available.</returns> public List <ContinuityOfCareRecord> GetCareRecords(string profileId, bool digest) { HealthQuery query = new HealthQuery(ProfileFeed + profileId); query.Digest = true; HealthFeed feed = this.Query(query); List <ContinuityOfCareRecord> ccrs = new List <ContinuityOfCareRecord>(); foreach (AtomEntry entry in feed.Entries) { IExtensionElementFactory factory = entry.FindExtension("ContinuityOfCareRecord", "urn:astm-org:CCR"); if (factory != null) { XmlExtension extension = factory as XmlExtension; XmlSerializer serializer = new XmlSerializer(typeof(ContinuityOfCareRecord)); XmlTextReader reader = new XmlTextReader(new StringReader(extension.Node.OuterXml)); ccrs.Add(serializer.Deserialize(reader) as ContinuityOfCareRecord); } } return(ccrs); }
/// <summary> /// overloaded to create typed version of Query /// </summary> /// <param name="feedQuery"></param> /// <returns>EventFeed</returns> public HealthFeed Query(HealthQuery feedQuery) { return(base.Query(feedQuery) as HealthFeed); }
/// <summary> /// Queries the Google Health Profile Register feed for the list of notices. This /// is for ClientLogin related queries. /// </summary> /// <param name="profileId">The profile to query against.</param> /// <returns>The list of notices available on this profile.</returns> public List<Notice> GetNotices(string profileId) { HealthQuery query = new HealthQuery(RegisterFeed + profileId); query.Digest = true; HealthFeed feed = this.Query(query); List<Notice> notices = new List<Notice>(); foreach (AtomEntry entry in feed.Entries) { notices.Add(Notice.FromAtomEntry(entry)); } return notices; }
/// <summary> /// overloaded to create typed version of Query /// </summary> /// <param name="feedQuery"></param> /// <returns>EventFeed</returns> public HealthFeed Query(HealthQuery feedQuery) { return base.Query(feedQuery) as HealthFeed; }
/// <summary> /// Queries the profile feed for the list of available CCR records. Available /// for ClientLogin related queries. /// </summary> /// <param name="profileId">The profile to query against.</param> /// <param name="digest">True to aggregate all CCR into a single CCR element, false otherwise.</param> /// <returns>The list of CCR records available.</returns> public List<ContinuityOfCareRecord> GetCareRecords(string profileId, bool digest) { HealthQuery query = new HealthQuery(ProfileFeed + profileId); query.Digest = true; HealthFeed feed = this.Query(query); List<ContinuityOfCareRecord> ccrs = new List<ContinuityOfCareRecord>(); foreach (AtomEntry entry in feed.Entries) { IExtensionElementFactory factory = entry.FindExtension("ContinuityOfCareRecord", "urn:astm-org:CCR"); if (factory != null) { XmlExtension extension = factory as XmlExtension; XmlSerializer serializer = new XmlSerializer(typeof(ContinuityOfCareRecord)); XmlTextReader reader = new XmlTextReader(new StringReader(extension.Node.OuterXml)); ccrs.Add(serializer.Deserialize(reader) as ContinuityOfCareRecord); } } return ccrs; }
static void Main(string[] args) { if (args.Length == 0) { ShowUsage(); return; } string pid = findValue(args, "pid", null); string pname = findValue(args, "pname", null); string authToken = findValue(args, "a", null); string exchangeToken = findValue(args, "e", null); string userName = findValue(args, "user", null); string passWord = findValue(args, "pwd", null); bool isRegister = isOption(args, "register", false); bool isInsert = isOption(args, "insert", false); bool isClean = isOption(args, "clean", false); bool isShow = isOption(args, "show", false); bool isList = isOption(args, "list", false); bool doCCR = isOption(args, "ccr", false); bool doSummary = isOption(args, "summary", false); if ((pid == null && pname == null && isList == false) && (exchangeToken == null && authToken == null)) { ShowUsage(); return; } HealthService service = new HealthService(ApplicationName); if (authToken != null) { Console.WriteLine("Using AuthSubToken: " + authToken); GAuthSubRequestFactory factory = new GAuthSubRequestFactory(HealthService.ServiceName, ApplicationName); factory.Token = authToken; service.RequestFactory = factory; } else if (exchangeToken != null) { Console.WriteLine("Using Onetime token: " + exchangeToken); authToken = AuthSubUtil.exchangeForSessionToken(exchangeToken, null); Console.WriteLine("Exchanged for Session Token: " + exchangeToken); GAuthSubRequestFactory factory = new GAuthSubRequestFactory(HealthService.ServiceName, ApplicationName); factory.Token = authToken; service.RequestFactory = factory; } else { Console.WriteLine("Setting user credentials for: " + userName); service.setUserCredentials(userName, passWord); } HealthQuery query; try { if (isList == true) { HealthFeed feed = service.Query(new HealthQuery(HealthQuery.ProfileListFeed)); Console.WriteLine ("Feed =" + feed); foreach (AtomEntry entry in feed.Entries) { Console.WriteLine("\tProfile " + entry.Title.Text + " has ID: " + entry.Content.Content); } return; } if (pid == null && pname != null) { // need to find the ID first. // so we get the list feed, find the name in the TITLE, and then // get the ID out of the content field HealthFeed feed = service.Query(new HealthQuery(HealthQuery.ProfileListFeed)); foreach (AtomEntry entry in feed.Entries) { if (entry.Title.Text == pname) { pid = entry.Content.Content; } } } if (authToken != null) { if (isRegister == true) { query = new HealthQuery(HealthQuery.AuthSubRegisterFeed); } else { query = new HealthQuery(HealthQuery.AuthSubProfileFeed); if (doSummary == true) { query.Digest = true; } } } else { if (isRegister == true) { query = HealthQuery.RegisterQueryForId(pid); } else { query = HealthQuery.ProfileQueryForId(pid); if (doSummary == true) { query.Grouped = true; query.GroupSize = 1; } } } Console.WriteLine("Resolved targetUri to: " + query.Uri.ToString()); if (doCCR == true) { HealthFeed feed = service.Query(query); foreach (HealthEntry e in feed.Entries ) { XmlNode ccr = e.CCR; if (ccr != null) { XmlTextWriter writer = new XmlTextWriter(Console.Out); writer.Formatting = Formatting.Indented; ccr.WriteTo(writer); } } } else { if (isShow == true || doSummary == true) { Stream result = service.Query(query.Uri); DumpStream(result); } } if (isInsert == true) { String input = Console.In.ReadToEnd(); Console.Write(input); Stream result = service.StringSend(query.Uri, input, GDataRequestType.Insert); DumpStream(result); } if (isClean == true) { int count = 0; AtomFeed feed = service.Query(query); Console.WriteLine("Retrieved Feed, now deleting all entries in the feed"); foreach (AtomEntry entry in feed.Entries) { Console.WriteLine(".... deleting entry " + entry.Title.Text); entry.Delete(); count++; } Console.WriteLine("Deleted " + count + " entries"); } } catch (GDataRequestException e) { HttpWebResponse response = e.Response as HttpWebResponse; Console.WriteLine("Error executing request for Verb, Errorcode: " + response.StatusCode); Console.WriteLine(response.StatusDescription); Console.WriteLine(e.ResponseString); } }