public DropOffResponse DropOffForPackageId(DropOffRequest request) { // request.PackageId must not be null or empty in this case. return (DropOff(ref request, true)); }
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); }
public DropOffResponse DropOffForPatient(DropOffRequest request) { return (DropOff(ref request, false)); }