public DeletePendingConnectionResponse DeletePendingConnection(DeletePendingConnectionRequest request) { DeletePendingConnectionResponse response = new DeletePendingConnectionResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.LocalRecordId)) { throw (new System.ArgumentNullException("LocalRecordId", AppSettings.NullInputEncountered)); } HealthVaultConnection hv = new HealthVaultConnection(request.Token); hv.DeletePendingConnectionRequest(request.LocalRecordId); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public RevokeApplicationConnectionResponse RevokeApplicationConnection(RevokeApplicationConnectionRequest request) { RevokeApplicationConnectionResponse response = new RevokeApplicationConnectionResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } if (request.PersonId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("PersonId", AppSettings.NullInputEncountered)); } HealthVaultConnection hv = new HealthVaultConnection(request.Token, request.PersonId); hv.RevokeApplicationConnection(request.RecordId); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public GetUpdatedRecordsResponse GetUpdatedRecords(GetUpdatedRecordsRequest request) { GetUpdatedRecordsResponse response = new GetUpdatedRecordsResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } HealthVaultConnection hv = new HealthVaultConnection(request.Token); IList <HealthRecordUpdateInfo> records = hv.GetUpdatedRecordsSince(request.SinceDate); response.UpdatedRecords = new List <RecordUpdateInfo>(); foreach (HealthRecordUpdateInfo r in records) { response.UpdatedRecords.Add(new RecordUpdateInfo(r.LastUpdateDate, r.PersonId, r.RecordId)); } } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public HVProxyResponse DeletePendingForPackageId(string token, string dopuPackageId) { HVProxyResponse response = new HVProxyResponse(); try { if (string.IsNullOrEmpty(token)) throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(dopuPackageId)) throw (new System.ArgumentNullException("LocalPatientId", AppSettings.NullInputEncountered)); HealthVaultConnection hv = new HealthVaultConnection(token); if (string.IsNullOrEmpty(dopuPackageId)) throw (new System.ArgumentNullException("DopuPackageId", AppSettings.NullInputEncountered)); hv.DeletePendingDropForPackageId(dopuPackageId); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return response; }
public PutThingsResponse PutThings(PutThingsRequest request) { PutThingsResponse response = new PutThingsResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } if (request.PersonId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("PersonId", AppSettings.NullInputEncountered)); } if (request.RecordId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("RecordId", AppSettings.NullInputEncountered)); } response.CountReceived = 0; response.IndexOnError = 0; response.CountSucceeded = 0; foreach (string item in request.XmlInputs) { response.CountReceived += 1; response.IndexOnError = response.CountReceived - 1; XmlDocument doc = new XmlDocument(); doc.LoadXml(item); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator navTypeId = nav.SelectSingleNode("//type-id"); Guid typeId = new Guid(navTypeId.InnerXml); XPathNavigator navData = nav.SelectSingleNode("//data-xml"); navData.MoveToFirstChild(); HealthVaultConnection hv = new HealthVaultConnection(request.Token, request.PersonId); HealthRecordItem newItem = new HealthRecordItem(typeId, navData); hv.PutThings(request.RecordId, ref newItem); response.CountSucceeded += 1; } } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public ConnectResponse CreateConnection(ConnectRequest request) { ConnectResponse response = new ConnectResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.LocalRecordId)) { throw (new System.ArgumentNullException("LocalRecordId", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.LocalPersonName)) { throw (new System.ArgumentNullException("LocalPersonName", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.SecretQuestion)) { throw (new System.ArgumentNullException("SecretQuestion", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.SecretAnswer)) { throw (new System.ArgumentNullException("SecretAnswer", AppSettings.NullInputEncountered)); } HealthVaultConnection hv = new HealthVaultConnection(request.Token); response.ConnectionCode = hv.CreateConnectionRequest(request.LocalRecordId, request.LocalPersonName, request.SecretQuestion, request.SecretAnswer); response.PickupUrl = AppSettings.PickupUrl(); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public GetThingsResponse GetThings(GetThingsRequest request) { GetThingsResponse response = new GetThingsResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } if (request.PersonId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("PersonId", AppSettings.NullInputEncountered)); } foreach (Guid typeId in request.TypeIds) { if (typeId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("TypeId", AppSettings.NullInputEncountered)); } } HealthVaultConnection hv = new HealthVaultConnection(request.Token, request.PersonId); response.Things = hv.GetThings(request.RecordId, request.TypeIds, request.SinceDate); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public ValidatedConnectionsResponse GetValidatedConnections(ValidatedConnectionsRequest request) { ValidatedConnectionsResponse response = new ValidatedConnectionsResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } HealthVaultConnection hv = new HealthVaultConnection(request.Token); Collection <ValidatedPatientConnection> Connections = hv.GetValidatedConnectionsSince(request.SinceDate); response.Connections = new Collection <ValidatedConnection>(); foreach (ValidatedPatientConnection hvconn in Connections) { ValidatedConnection conn = new ValidatedConnection(); conn.ApplicationId = hvconn.ApplicationId; conn.ApplicationPatientId = hvconn.ApplicationPatientId; conn.ApplicationSpecificRecordId = hvconn.ApplicationSpecificRecordId; conn.PersonId = hvconn.PersonId; conn.RecordId = hvconn.RecordId; response.Connections.Add(conn); } } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
public PreAllocatePackageIdResponse PreAllocatePackageId(string token) { PreAllocatePackageIdResponse response = new PreAllocatePackageIdResponse(); try { if (string.IsNullOrEmpty(token)) throw (new System.ArgumentNullException("token", AppSettings.NullInputEncountered)); HealthVaultConnection hv = new HealthVaultConnection(token); response.DopuPackageId = hv.AllocatePackageId(); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return response; }
public PutThingResponse PutThing(PutThingRequest request) { PutThingResponse response = new PutThingResponse(); try { if (string.IsNullOrEmpty(request.Token)) { throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); } if (request.PersonId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("PersonId", AppSettings.NullInputEncountered)); } if (request.RecordId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("RecordId", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.TypeName)) { throw (new System.ArgumentNullException("TypeName", AppSettings.NullInputEncountered)); } if (request.TypeId.Equals(Guid.Empty)) { throw (new System.ArgumentNullException("TypeId", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.XmlItem)) { throw (new System.ArgumentNullException("XmlItem", AppSettings.NullInputEncountered)); } XmlDocument doc = new XmlDocument(); doc.LoadXml(request.XmlItem); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator navData = nav.SelectSingleNode("//" + request.TypeName); if (navData.LocalName.CompareTo(request.TypeName) != 0) { throw (new System.ArgumentException("Specified TypeName not found within input string argument.", "XmlItem")); } HealthVaultConnection hv = new HealthVaultConnection(request.Token, request.PersonId); HealthRecordItem newItem = new HealthRecordItem(request.TypeId, navData); hv.PutThings(request.RecordId, ref newItem); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return(response); }
private DropOffResponse DropOff(ref DropOffRequest request, bool isForPackageId) { DropOffResponse response = new DropOffResponse(); try { if ((isForPackageId) && (string.IsNullOrEmpty(request.DopuPackageId))) throw (new System.ArgumentNullException("DopuPackageId", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(request.LocalPatientId)) throw (new System.ArgumentNullException("LocalPatientId", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(request.Token)) throw (new System.ArgumentNullException("Token", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(request.FromName)) throw (new System.ArgumentNullException("FromName", AppSettings.NullInputEncountered)); if (request.EmailTo.Count == 0) throw (new System.ArgumentNullException("EmailTo", AppSettings.NullInputEncountered)); foreach (string email in request.EmailTo) { if (string.IsNullOrEmpty(email)) throw (new System.ArgumentNullException("EmailTo", AppSettings.NullInputEncountered)); } if (string.IsNullOrEmpty(request.EmailFrom)) throw (new System.ArgumentNullException("EmailFrom", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(request.EmailSubject)) throw (new System.ArgumentNullException("EmailSubject", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(request.SecretQuestion)) throw (new System.ArgumentNullException("SecretQuestion", AppSettings.NullInputEncountered)); if (string.IsNullOrEmpty(request.SecretAnswer)) throw (new System.ArgumentNullException("SecretAnswer", AppSettings.NullInputEncountered)); if (request.Things.Count == 0) throw (new System.ArgumentNullException("Things", AppSettings.NullInputEncountered)); List<HealthRecordItem> newRecords = new List<HealthRecordItem>(); foreach (string thing in request.Things) { XmlDocument doc = new XmlDocument(); doc.LoadXml(thing); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator navTypeId = nav.SelectSingleNode("//type-id"); Guid typeId = new Guid(navTypeId.InnerXml); XPathNavigator navData = nav.SelectSingleNode("//data-xml"); navData.MoveToFirstChild(); newRecords.Add(new HealthRecordItem(typeId, navData)); } HealthVaultConnection hv = new HealthVaultConnection(request.Token); if (isForPackageId) response.SecretCode = hv.DropOff(request.DopuPackageId, request.FromName, request.LocalPatientId, request.SecretQuestion, request.SecretAnswer, ref newRecords); else response.SecretCode = hv.DropOff(request.FromName, request.LocalPatientId, request.SecretQuestion, request.SecretAnswer, ref newRecords); // Compose the pickup URL using the Microsoft.Health.Web utilities... // e.g. https://account.healthvault-ppe.com/patientwelcome.aspx?packageid=JKXF-JRMX-ZKZM-KGZM-RKKX // e.g. https://shellhostname/redirect.aspx?target=PICKUP&targetqs=packageid%3dJKYZ-QNMN-VHRX-ZGNR-GZNH response.PickupUrl = AppSettings.PickupUrl(); response.PickupUrl += @"?packageid="; response.PickupUrl += response.SecretCode; string emailBody = AppSettings.DOPUemailTemplate.Replace("[PICKUP]", response.PickupUrl); emailBody = emailBody.Replace("[SECRET]", response.SecretCode); hv.SendInsecureMessageFromApplication(request.EmailTo, request.EmailFrom, request.EmailSubject, emailBody); } catch (Microsoft.Health.HealthServiceException hex) { response.Success = false; response.Message = hex.ToString(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; response.Stack = ex.StackTrace; } return (response); }