internal BlobStream(HealthRecordAccessor record, Blob blob) { _record = record; _blob = blob; _length = blob.ContentLength; _canWrite = true; }
public static HealthRecordItemCollection GetHVItemsOffline(Guid personId, Guid recordGuid, DateTime? lastSync) { // Do the offline connection OfflineWebApplicationConnection offlineConn = new OfflineWebApplicationConnection(personId); offlineConn.RequestTimeoutSeconds = 180; //extending time to prevent time outs for accounts with large number of items offlineConn.Authenticate(); HealthRecordAccessor accessor = new HealthRecordAccessor(offlineConn, recordGuid); HealthRecordSearcher searcher = accessor.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(Exercise.TypeId, AerobicSession.TypeId); if (lastSync.HasValue) filter.UpdatedDateMin = (DateTime)lastSync; searcher.Filters.Add(filter); HealthRecordItemCollection items = null; try { items = searcher.GetMatchingItems()[0]; } catch (Exception err) { WlkMiTracer.Instance.Log("HVSync.cs:GetHVItemsOffline", WlkMiEvent.AppSync, WlkMiCat.Error, string.Format("Error for user {0} : {1} ", recordGuid.ToString(), err.ToString())); } return items; }
/// <summary> /// Constructs an instance of the Blob class with the specified values. /// </summary> /// /// <param name="name"> /// The name of the BLOB. It can be <see cref="String.Empty"/> but cannot be <b>null</b>. /// </param> /// /// <param name="contentType"> /// The content type of the BLOB. /// </param> /// /// <param name="currentContentEncoding"> /// The current content encoding of the BLOB or <b>null</b> if the BLOB is not encoded. /// </param> /// /// <param name="legacyContentEncoding"> /// The previous content encoding of the BLOB (if any). /// </param> /// /// <param name="record"> /// The health record to write the BLOB data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="name"/> or <paramref name="contentType"/> is <b>null</b>. /// </exception> /// internal Blob( string name, string contentType, string currentContentEncoding, string legacyContentEncoding, HealthRecordAccessor record) : this(name, contentType, currentContentEncoding, legacyContentEncoding, null, record) { }
private string getGroupAverage(string tGroup, string thing) { int sumWt = 0; int sumAge = 0; ParticipantDAO dao = new ParticipantDAO(); ICollection<Participant> participantList = dao.GetTrialGroup(tGroup); foreach (var participant in participantList) { try { OfflineWebApplicationConnection conn = HVConnectionManager.CreateConnection(participant.HVPersonID); HealthRecordAccessor accessor = new HealthRecordAccessor(conn, participant.HVRecordID); HealthRecordSearcher search = accessor.CreateSearcher(); search.Filters.Add(new HealthRecordFilter(Weight.TypeId)); search.Filters.Add(new HealthRecordFilter(Basic.TypeId)); HealthRecordItemCollection items = null; items = search.GetMatchingItems()[0]; var firstStr = items[0].ToString(); var secStr = firstStr.Substring(0, firstStr.IndexOf(" ")); int intVal = Convert.ToInt32(secStr); sumWt = sumWt + intVal; items = search.GetMatchingItems()[1]; var age = items[0].ToString(); age = age.Substring(age.Length-4, 4); intVal = Convert.ToInt32(age); sumAge = sumAge + intVal; } catch (HealthServiceException ex) { String msg = String.Empty; if (ex is HealthServiceAccessDeniedException) msg = "The application may be trying to read user data from an anonymous connection.\n"; msg += ex.Error.ErrorInfo + "\n" + ex.Message.ToString(); Debug.WriteLine(msg); } } if (participantList.Count > 0) { if (thing == "Weight") return (sumWt / participantList.Count).ToString(); else if (thing == "Age") return (2013 - (sumAge / participantList.Count)).ToString(); } return "No participants in Group " + tGroup; }
protected void btnSubmit_Click(object sender, EventArgs e) { OfflineWebApplicationConnection conn = HVConnectionManager.CreateConnection(selectedParticipant.HVPersonID); HealthRecordAccessor accessor = new HealthRecordAccessor(conn, selectedParticipant.HVRecordID); double weight = 300.0; Weight w = new Weight( new HealthServiceDateTime(DateTime.Now), new WeightValue(weight * 1.6, new DisplayValue(weight, "lbs", "lbs"))); accessor.NewItem(w); //CodableValue allergyCV = new CodableValue("Allergy"); //Allergy allergy = new Allergy(allergyCV); //allergy. //allergy.Name = "Cats"; //allergy.Reaction = "Itchy Eyes"; //accessor.NewItem(allergy); }
private void DisplaySelectedParticipant(Participant participant) { lblPatientHeader.Text = participant.FullName; try { OfflineWebApplicationConnection conn = HVConnectionManager.CreateConnection(participant.HVPersonID); HealthRecordAccessor accessor = new HealthRecordAccessor(conn, participant.HVRecordID); HealthRecordSearcher search = accessor.CreateSearcher(); search.Filters.Add(new HealthRecordFilter(Basic.TypeId)); search.Filters.Add(new HealthRecordFilter(Condition.TypeId)); search.Filters.Add(new HealthRecordFilter(Procedure.TypeId)); search.Filters.Add(new HealthRecordFilter(Medication.TypeId)); HealthRecordItemCollection items = null; //Basic info = (Basic)items[0]; items = search.GetMatchingItems()[0]; //Debug.WriteLine(search.GetMatchingItemsRaw()); if (items.Count > 0) lblPatientBasic.Text = "Gender, Birth Year: " + items[0].ToString(); else lblPatientBasic.Text = "No Basic Info Available"; items = search.GetMatchingItems()[1]; if (items.Count > 0) lblPatientCondition.Text = "Condition: " + items[0].ToString(); else lblPatientCondition.Text = "No Weight Info Available"; items = search.GetMatchingItems()[2]; if (items.Count > 0) lblPatientProcedure.Text = "Procedure: " + items[0].ToString(); else lblPatientProcedure.Text = "No Weight Info Available"; items = search.GetMatchingItems()[3]; if (items.Count > 0) lblPatientMedication.Text = "Medications Prescribed: " + items[0].ToString(); else lblPatientMedication.Text = "No Medication Info Available"; } catch (HealthServiceException ex) { String msg = String.Empty; if (ex is HealthServiceAccessDeniedException) msg = "The application may be trying to read user data from an anonymous connection.\n"; msg += ex.Error.ErrorInfo + "\n" + ex.Message.ToString(); Debug.WriteLine(msg); } }
/// <summary> /// Fills in the data table with data from the HealthVault service /// starting at the specific index for the count specified. /// </summary> /// /// <param name="record"> /// The health record to get the data from. /// </param> /// /// <param name="startIndex"> /// The index to start retrieving full data from HealthVault. /// </param> /// /// <param name="count"> /// The count of full items to retrieve. /// </param> /// /// <remarks> /// This method makes a web-method call to the HealthVault service. /// /// The default <see cref="GetData(HealthRecordAccessor)"/> implementation /// fills the data with complete information for all items matching /// the filter. If the <see cref="HealthRecordItemDataTable"/> is being /// bound to a HealthServiceDataGrid or other such control that supports /// paging, this may not be the desired result as many calls to /// HealthVault may be required to fetch all the data. This overload /// of GetData allows the caller to specify the index and the count of /// the full items to retrieve to match the page that is currently visible. /// The <see cref="HealthRecordItemDataTable"/> will be filled with /// empty values except for the rows specified. /// </remarks> /// /// <exception cref="HealthServiceException"> /// An error occurred while accessing the HealthVault service. /// </exception> /// public void GetData( HealthRecordAccessor record, int startIndex, int count) { HealthRecordItemDataTableView effectiveView = this.ApplyEffectiveView(record.Connection); // Need to specify the type version to ensure that the columns match when the app // supports multiple versions. if (effectiveView == HealthRecordItemDataTableView.SingleTypeTable) { for (int index = 0; index < this.Filter.TypeIds.Count; ++index) { this.Filter.View.TypeVersionFormat.Add(this.Filter.TypeIds[index]); } } HealthRecordSearcher searcher = record.CreateSearcher(); searcher.Filters.Add(this.Filter); XPathNavigator nav = searcher.GetMatchingItemsRaw(); _hasData = true; XPathNavigator navFiltered = nav.SelectSingleNode("//group/filtered"); if (navFiltered != null) { _wasFiltered = navFiltered.ValueAsBoolean; } int numberOfFullThingsToRetrieve = AddRows(nav); List<HealthRecordItemKey> partialThingKeys = GetPartialThingKeys(nav); int thingIndex = numberOfFullThingsToRetrieve; int partialThingsCurrentIndex = 0; while (thingIndex < startIndex && partialThingsCurrentIndex < partialThingKeys.Count) { AddPartialThingRow(partialThingKeys[partialThingsCurrentIndex++]); ++thingIndex; } while (thingIndex < startIndex + count && partialThingsCurrentIndex < partialThingKeys.Count) { nav = GetPartialThings( record, partialThingKeys, partialThingsCurrentIndex, numberOfFullThingsToRetrieve); // Note, not all partial things may still exist when doing // the next query so AddRows may return less than // numberOfFullThingsToRetrieve. Just skip anything that is // missing. AddRows(nav); partialThingsCurrentIndex += numberOfFullThingsToRetrieve; thingIndex += numberOfFullThingsToRetrieve; } while (partialThingsCurrentIndex < partialThingKeys.Count) { AddPartialThingRow(partialThingKeys[partialThingsCurrentIndex++]); ++thingIndex; } }
/// <summary> /// Fills in the data table with data from the HealthVault service. /// </summary> /// /// <param name="record"> /// The health record to get the data from. /// </param> /// /// <remarks> /// This method makes a web-method call to the HealthVault service. /// </remarks> /// /// <exception cref="HealthServiceException"> /// An error occurred while accessing the HealthVault service. /// </exception> /// public void GetData(HealthRecordAccessor record) { GetData(record, 0, Int32.MaxValue); }
/// <summary> /// Releases the authorization of the application on the health record. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <exception cref="HealthServiceException"> /// Errors during the authorization release. /// </exception> /// /// <remarks> /// Once the application releases the authorization to the health record, /// calling any methods of this <see cref="HealthRecordAccessor"/> will result /// in a <see cref="HealthServiceAccessDeniedException"/>." /// </remarks> public static void RemoveApplicationAuthorization( ApplicationConnection connection, HealthRecordAccessor accessor) { HealthVaultPlatformRecord.Current.RemoveApplicationAuthorization(connection, accessor); }
/// <summary> /// Constructs an instance of a HealthRecordExporter for the specified /// health record and the specified transform tag. /// </summary> /// /// <param name="record"> /// The health record to export data from. /// </param> /// /// <param name="transformTag"> /// The name of the transform to be retrieved from HealthVault to convert /// the HealthVault XML to the destination format. For example, "toccr" will /// convert the data to the Continuity of Care Record XML format. /// </param> /// /// <remarks> /// Note, this constructor makes a call to HealthVault to retrieve the specified /// data transform. The web request may cause a variety of WebExceptions to be thrown. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="record"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="transformTag"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="WebException"> /// If the transform with the specified <paramref name="transformTag"/> /// could not be found. /// </exception> /// public HealthRecordExporter(HealthRecordAccessor record, string transformTag) { Validator.ThrowIfArgumentNull(record, "record", "HealthRecordExporterCtorArgumentNull"); Validator.ThrowIfStringNullOrEmpty(transformTag, "transformTag"); _record = record; _transform = GetTransform(transformTag); }
/// <summary> /// Fetch the <see cref="HealthRecordItem" /> instances that are specified /// in the ChangedItems collection. /// </summary> /// <remarks> /// After the operation has completed, see <see cref="HealthRecordItemChangedItem.Item" /> /// to use the fetched <see cref="HealthRecordItem" /> /// /// Items that have been removed from a record or are otherwise inaccessible will /// have a <see cref="HealthRecordItemChangedItem.Item" /> value of null. /// </remarks> /// /// <param name="applicationId">The application id to use.</param> /// <param name="healthServiceUrl">The health service URL to use.</param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="healthServiceUrl"/> parameter is <b>null</b>. /// </exception> public void GetItems(Guid applicationId, string healthServiceUrl) { Validator.ThrowIfArgumentNull(healthServiceUrl, "healthServiceUrl", "HealthServiceUrlNull"); if (ChangedItems.Count == 0) { return; } OfflineWebApplicationConnection offlineConn = new OfflineWebApplicationConnection( applicationId, healthServiceUrl, _personId); offlineConn.Authenticate(); HealthRecordAccessor accessor = new HealthRecordAccessor(offlineConn, _recordId); HealthRecordSearcher searcher = accessor.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); searcher.Filters.Add(filter); Dictionary<Guid, HealthRecordItemChangedItem> changedLookup = new Dictionary<Guid, HealthRecordItemChangedItem>(ChangedItems.Count); foreach (HealthRecordItemChangedItem item in ChangedItems) { filter.ItemIds.Add(item.Id); changedLookup.Add(item.Id, item); } HealthRecordItemCollection things = searcher.GetMatchingItems()[0]; // Take the resultant items and put them back in the ChangedItems collection foreach (HealthRecordItem fetchedItem in things) { HealthRecordItemChangedItem item = changedLookup[fetchedItem.Key.Id]; item.Item = fetchedItem; } }
protected override void ProcessRecord() { HealthClientApplication clientApp = HvShellUtilities.GetClient(); List<PersonInfo> authorizedPeople = new List<PersonInfo> (clientApp.ApplicationConnection.GetAuthorizedPeople()); // Create an authorized connection for each person on the // list. HealthClientAuthorizedConnection authConnection = clientApp.CreateAuthorizedConnection( authorizedPeople[0].PersonId); // Use the authorized connection to read the user's default // health record. HealthRecordAccessor access = new HealthRecordAccessor( authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id); Weight weight = new Weight(); weight.Value = new WeightValue(Value / 2.2, new DisplayValue(Value, "pounds")); access.NewItem(weight); }
/// <summary> /// Represents a simple wrapper around the XML request for the web /// service. /// </summary> /// /// <param name="record"> /// The record that prepopulates the request. /// </param> /// /// <param name="methodName"> /// The name of the method to call. /// </param> /// /// <param name="methodVersion"> /// The version of the method to call. /// </param> /// /// <returns> /// A <see cref="Microsoft.Health.HealthServiceRequest"/> that wraps /// the XML request for the web service. /// </returns> /// /// <remarks> /// This method skips the object model provided by the other /// methods of this class and acts as a simple wrapper around /// the XML request for the web service. The caller must provide the /// parameters in the correct format for the called method and parse /// the response data. /// The information in the <paramref name="record"/> parameter /// prepopulates the request. /// <br/><br/> /// By creating the request object directly rather than using the /// object model, you can pass parameters that are not directly /// exposed by the object model. Please provide feedback /// to us if this is the case. This also allows for request-specific /// parameters that are set by default when using the object model. /// For example, you can change the language for a specific request /// without affecting other requests to the HealthVault service through /// the same connection. /// <br/><br/> /// <br/><br/> /// You can find a list of the HealthVault methods (including their /// request and response schema) at /// <a href="http://labs.microsoftlivehealth.com/Lab">the Microsoft /// Live Health Lab</a> site. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="record"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="methodName"/> parameter is <b>null</b> or /// empty. /// </exception> /// public virtual HealthServiceRequest CreateRequest( HealthRecordAccessor record, string methodName, int methodVersion) { Validator.ThrowIfArgumentNull(record, "record", "CreateRequestNullRecord"); Validator.ThrowIfStringNullOrEmpty(methodName, "methodName"); HealthServiceRequest request = CreateRequest(methodName, methodVersion, false); request.RecordId = record.Id; return request; }
/// <summary> /// Gets the health record items that match the filters as specified by /// the properties of this class. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="searcher"> /// The searcher that defines what items to return. /// </param> /// /// <returns> /// An XPathNavigator representing the raw results of the search. /// </returns> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// <br/><br/> /// This method is typically used when the calling application wants to /// handle the raw health record item XML directly instead of using the /// object model. /// </remarks> /// public static XPathNavigator GetMatchingItemsRaw( ApplicationConnection connection, HealthRecordAccessor accessor, HealthRecordSearcher searcher) { return HealthVaultPlatformItem.Current.GetMatchingItemsRaw(connection, accessor, searcher); }
/// <summary> /// Gets the health record items that match the filters as specified by /// the properties of this class. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="searcher"> /// The searcher that defines what items to return. . /// </param> /// /// <returns> /// A collection of health record items that match the applied filters. /// </returns> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// </remarks> /// /// <exception cref="HealthServiceException"> /// The response from the server was anything but /// <see cref="HealthServiceStatusCode.Ok"/>. /// -or- /// <see cref="Microsoft.Health.HealthRecordSearcher.Filters"/> is empty /// or contains invalid filters. /// </exception> /// public static ReadOnlyCollection<HealthRecordItemCollection> GetMatchingItems( ApplicationConnection connection, HealthRecordAccessor accessor, HealthRecordSearcher searcher) { return HealthVaultPlatformItem.Current.GetMatchingItems(connection, accessor, searcher); }
/// <summary> /// Gets the list of alternate IDs that are associated with a record. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// </remarks> /// /// <exception cref="HealthServiceException"> /// The HealthVault service returned an error. /// If the alternate Id is not associated with a person and record id, the ErrorCode property /// will be set to AlternateIdNotFound. /// </exception> /// public static Collection<string> GetAlternateIds( ApplicationConnection connection, HealthRecordAccessor accessor) { return HealthVaultPlatformAlternateId.Current.GetAlternateIds(connection, accessor); }
/// <summary> /// Disassociates an alternate id with a record. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="alternateId"> /// The alternate id. /// </param> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// The connection, accessor, or alternateId parameters are null /// </exception> /// /// <exception cref="ArgumentException"> /// The alternateId parameter is empty, all whitespace, or more than 255 characters in length. /// </exception> /// /// <exception cref="HealthServiceException"> /// The HealthVault service returned an error. /// If the alternate Id is not associated with a person and record id, the ErrorCode property /// will be set to AlternateIdNotFound. /// </exception> /// public static void DisassociateAlternateId( ApplicationConnection connection, HealthRecordAccessor accessor, string alternateId) { HealthVaultPlatformAlternateId.Current.DisassociateAlternateId(connection, accessor, alternateId); }
/// <summary> /// Updates the specified health record items in one batch call to /// the service. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="itemsToUpdate"> /// The health record items to be updated. /// </param> /// /// <remarks> /// Only new items are updated with the appropriate unique identifier. /// All other sections must be updated manually. /// <br/><br/> /// This method accesses the HealthVault service across the network. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="itemsToUpdate"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="itemsToUpdate"/> contains a <b>null</b> member or /// a <see cref="HealthRecordItem"/> instance that does not have an ID. /// </exception> /// /// <exception cref="HealthServiceException"> /// The HealthVault service returned an error. /// The exception's Error property will contain the index of the /// item on which the failure occurred in the ErrorInfo property. If any failures occur, /// no items will have been updated. /// </exception> /// public static void UpdateItems( ApplicationConnection connection, HealthRecordAccessor accessor, IList<HealthRecordItem> itemsToUpdate) { HealthVaultPlatformItem.Current.UpdateItems(connection, accessor, itemsToUpdate); }
/// <summary> /// Marks the specified health record item as deleted. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="itemsToRemove"> /// The unique item identifiers of the items to remove. /// </param> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// <br/><br/> /// Health record items are never completely deleted. They are marked /// as deleted and are ignored for most normal operations. Items can /// be undeleted by contacting customer service. /// </remarks> /// /// <exception cref="ArgumentException"> /// The <paramref name="itemsToRemove"/> parameter is empty. /// </exception> /// /// <exception cref="HealthServiceException"> /// Errors removed the health record items from the server. /// The exception's Error property will contain the index of the /// item on which the failure occurred in the ErrorInfo property. If any failures occur, /// no items will have been removed. /// </exception> /// public static void RemoveItems( ApplicationConnection connection, HealthRecordAccessor accessor, IList<HealthRecordItemKey> itemsToRemove) { HealthVaultPlatformItem.Current.RemoveItems(connection, accessor, itemsToRemove); }
private XPathNavigator GetPartialThings( HealthRecordAccessor record, IList<HealthRecordItemKey> thingKeys, int currentThingKeyIndex, int numberOfFullThingsToRetrieve) { HealthRecordSearcher searcher = record.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(); for (int i = currentThingKeyIndex; i < thingKeys.Count && i < currentThingKeyIndex + numberOfFullThingsToRetrieve; i++) { filter.ItemKeys.Add(thingKeys[i]); } filter.View = this.Filter.View; filter.States = this.Filter.States; filter.CurrentVersionOnly = this.Filter.CurrentVersionOnly; searcher.Filters.Add(filter); return searcher.GetMatchingItemsRaw(); }
/// <summary> /// Creates an instance of a HealthRecordAccessor object using /// the specified XML. /// </summary> /// /// <param name="connection"> /// A connection for the current user. /// </param> /// /// <param name="navigator"> /// The XML containing the record information. /// </param> /// /// <returns> /// A new instance of a HealthRecordAccessor object containing the /// record information. /// </returns> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="connection"/> or <paramref name="navigator"/> /// parameter is <b>null</b>. /// </exception> /// public static HealthRecordAccessor CreateFromXml( ApplicationConnection connection, XPathNavigator navigator) { Validator.ThrowIfArgumentNull(connection, "connection", "PersonInfoConnectionNull"); Validator.ThrowIfArgumentNull(navigator, "navigator", "ParseXmlNavNull"); HealthRecordAccessor recordInfo = new HealthRecordAccessor(connection); recordInfo.ParseXml(navigator); return recordInfo; }
/// <summary> /// Gets the health record items that match the filters as specified by /// the properties of this class. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="searcher"> /// The searcher that defines what items to return. /// </param> /// /// <returns> /// An XmlReader representing the raw results of the search. /// </returns> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// <br/><br/> /// This method is typically used when the calling application wants to /// handle the raw health record item XML directly instead of using the /// object model. /// </remarks> /// public static XmlReader GetMatchingItemsReader( ApplicationConnection connection, HealthRecordAccessor accessor, HealthRecordSearcher searcher) { return HealthVaultPlatformItem.Current.GetMatchingItemsReader(connection, accessor, searcher); }
/// <summary> /// Gets valid group memberships for a record. /// </summary> /// /// <remarks> /// Group membership thing types allow an application to signify that the /// record belongs to an application defined group. A record in the group may be /// eligible for special programs offered by other applications, for example. /// Applications then need a away to query for valid group memberships. /// <br/> /// Valid group memberships are those memberships which are not expired, and whose /// last updating application is authorized by the the last updating person to /// read and delete the membership. /// </remarks> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="applicationIds"> /// A collection of unique application identifiers for which to /// search for group memberships. For a null or empty application identifier /// list, return all valid group memberships for the record. Otherwise, /// return only those group memberships last updated by one of the /// supplied application identifiers. /// </param> /// /// <returns> /// A List of HealthRecordItems representing the valid group memberships. /// </returns> /// <exception cref="HealthServiceException"> /// If an error occurs while contacting the HealthVault service. /// </exception> public static Collection<HealthRecordItem> GetValidGroupMembership( ApplicationConnection connection, HealthRecordAccessor accessor, IList<Guid> applicationIds) { return HealthVaultPlatformRecord.Current.GetValidGroupMembership(connection, accessor, applicationIds); }
/// <summary> /// Creates a new instance of the <see cref="HealthServiceRequest"/> /// class for the specified method. /// </summary> /// /// <param name="connection"> /// The client-side representation of the HealthVault service. /// </param> /// /// <param name="methodName"> /// The name of the method to invoke on the service. /// </param> /// /// <param name="methodVersion"> /// The version of the method to invoke on the service. /// </param> /// /// <param name="record"> /// The record to use. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="connection"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// The <paramref name="methodName"/> parameter is <b>null</b> or empty. /// </exception> /// public HealthServiceRequest( HealthServiceConnection connection, string methodName, int methodVersion, HealthRecordAccessor record) : this(connection, methodName, methodVersion) { _recordId = record.Id; }
protected override void ProcessRecord() { HealthClientApplication clientApp = HvShellUtilities.GetClient(); List<PersonInfo> authorizedPeople = new List<PersonInfo>(clientApp.ApplicationConnection.GetAuthorizedPeople()); // Create an authorized connection for each person on the // list. HealthClientAuthorizedConnection authConnection = clientApp.CreateAuthorizedConnection( authorizedPeople[0].PersonId); // Use the authorized connection to read the user's default // health record. HealthRecordAccessor access = new HealthRecordAccessor( authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id); // Search the health record for basic demographic // information. // Most user records contain an item of this type. HealthRecordSearcher search = access.CreateSearcher(); search.Filters.Add(new HealthRecordFilter(HvShellUtilities.NameToTypeId(Type))); foreach (Object o in search.GetMatchingItems()) { WriteObject(o); } }
/// <summary> /// Fills in the data table with data from a list of HealthRecordItem. /// </summary> public void GetData( HealthRecordAccessor record, IList<HealthRecordItem> items, int startIndex, int count) { HealthRecordItemDataTableView effectiveView = this.ApplyEffectiveView(record.Connection); IDictionary<Guid, HealthRecordItemTypeDefinition> typeDefDict = ItemTypeManager.GetHealthRecordItemTypeDefinition(_filter.TypeIds, record.Connection); HealthRecordItemTypeDefinition sttTypeDef = typeDefDict.Count == 1 ? typeDefDict[_filter.TypeIds[0]] : null; bool firstRow = true; string transformName = (effectiveView == HealthRecordItemDataTableView.SingleTypeTable) ? "stt" : "mtt"; for (int i = startIndex; i < items.Count && i < count; ++i) { HealthRecordItem item = items[i]; XPathNavigator itemTransformNav; IDictionary<string, XmlDocument> transformedXmlData = item.TransformedXmlData; if (transformedXmlData.ContainsKey(transformName)) { itemTransformNav = transformedXmlData[transformName].CreateNavigator().SelectSingleNode( "//data-xml/row"); } else { string transform = (sttTypeDef == null) ? typeDefDict[item.TypeId].TransformItem(transformName, item) : sttTypeDef.TransformItem(transformName, item); itemTransformNav = new XPathDocument(XmlReader.Create(new StringReader( transform))).CreateNavigator(); if (!itemTransformNav.MoveToFirstChild()) { continue; } } if (firstRow) { SetupColumns(itemTransformNav.Clone()); firstRow = false; } AddRow(itemTransformNav); } }
/// <summary> /// Constructs an instance of a HealthRecordExporter for the specified /// health record and the specified transform. /// </summary> /// /// <param name="record"> /// The health record to export data from. /// </param> /// /// <param name="transform"> /// The transform used to convert HealthVault XML to the destination format. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="record"/> parameter is <b>null</b>. /// </exception> /// public HealthRecordExporter(HealthRecordAccessor record, XslCompiledTransform transform) { Validator.ThrowIfArgumentNull(record, "record", "HealthRecordExporterCtorArgumentNull"); _record = record; _transform = transform; }
/// <summary> /// Fills in the data table with data from the HealthVault service. /// </summary> /// /// <param name="recordId"> /// The unique health record identifier to get the data from. /// </param> /// /// <param name="connection"> /// The connection to the HealthVault service to use. /// </param> /// /// <remarks> /// This method makes a web-method call to the HealthVault service. /// </remarks> /// /// <exception cref="HealthServiceException"> /// An error occurred while accessing the HealthVault service. /// </exception> /// public void GetData( Guid recordId, ApplicationConnection connection) { HealthRecordAccessor record = new HealthRecordAccessor(connection, recordId); GetData(record); }
/// <summary> /// Constructs an instance of a HealthRecordExporter for the specified /// health record. /// </summary> /// /// <param name="record"> /// The health record to export data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="record"/> parameter is <b>null</b>. /// </exception> /// public HealthRecordExporter(HealthRecordAccessor record) { Validator.ThrowIfArgumentNull(record, "record", "HealthRecordExporterCtorArgumentNull"); _record = record; }
/// <summary> /// Gets the permissions which the authenticated person /// has when using the calling application for the specified item types /// in this record. /// </summary> /// /// <param name="connection"> /// The connection to use to access the data. /// </param> /// /// <param name="accessor"> /// The record to use. /// </param> /// /// <param name="healthRecordItemTypeIds"> /// A collection of unique identifiers to identify the health record /// item types, for which the permissions are being queried. /// </param> /// /// <returns> /// Returns a dictionary of <see cref="HealthRecordItemTypePermission"/> /// with health record item types as the keys. /// </returns> /// /// <remarks> /// If the list of health record item types is empty, an empty dictionary is /// returned. If for a health record item type, the person has /// neither online access nor offline access permissions, /// <b> null </b> will be returned for that type in the dictionary. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="healthRecordItemTypeIds"/> is <b>null</b>. /// </exception> /// /// <exception cref="HealthServiceException"> /// If there is an exception during executing the request to HealthVault. /// </exception> /// public static IDictionary<Guid, HealthRecordItemTypePermission> QueryPermissionsByTypes( ApplicationConnection connection, HealthRecordAccessor accessor, IList<Guid> healthRecordItemTypeIds) { return HealthVaultPlatformRecord.Current.QueryPermissionsByTypes(connection, accessor, healthRecordItemTypeIds); }