Skip to content

Commit

Permalink
PIDP-(827/840) Endorsement Request/Response Email (#482)
Browse files Browse the repository at this point in the history
* Added Notification service for 30days inactive users

* Added EndorsementActionRequied Notification and modified EndorsementInactive notificaton

* Added Endorsement Inactive Notification and  7 day reminder email changes

* Added a common method to get the body string

* Merge with dev branch

* Resolve merge conflicts

* restore nl

* Modified changes after review

* passing null to 7 day alert email for token

* modified url concating for licensed link

* code optimized removed redundant variables

* Modified test case for token check in 7Days

* Modified token for 7days and reverted test scenario

* changed  receiving  to  requesting

* notification to requesting party

---------

Co-authored-by: James Hollinger <[email protected]>
Co-authored-by: James Hollinger <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent d281b80 commit f84506a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ public async Task ExpireOldEndorsementRequestsAsync()
var now = this.clock.GetCurrentInstant();

var oldRequests = await this.context.EndorsementRequests
.Include(request => request.RequestingParty)
.Where(request => inProgressStatuses.Contains(request.Status)
&& request.StatusDate < now - Duration.FromDays(30))
.ToListAsync();

foreach (var request in oldRequests)
{
request.Status = EndorsementRequestStatus.Expired;
request.StatusDate = now;
var email = request.RequestingParty!.Email;

if (!string.IsNullOrEmpty(email))
{
await this.SendExpireOldEndorsementRequestsEmailAsync(email);
request.Status = EndorsementRequestStatus.Expired;
request.StatusDate = now;
}
}

await this.context.SaveChangesAsync();
Expand Down Expand Up @@ -93,39 +100,76 @@ public async Task SendReminderEmailsAsync()

private async Task SendEmailAsync(string partyEmail, Guid? token)
{
var url = this.applicationUrl.SetQueryParam("endorsement-token", token);
var link = $"<a href=\"{url}\" target=\"_blank\" rel=\"noopener noreferrer\">{this.applicationUrl}</a>";
var pidpSupportEmail = $"<a href=\"mailto:{EmailService.PidpEmail}\">{EmailService.PidpEmail}</a>";
var pidpSupportPhone = $"<a href=\"tel:{EmailService.PidpSupportPhone}\">{EmailService.PidpSupportPhone}</a>";

var email = new Email(
from: EmailService.PidpEmail,
to: partyEmail,
subject: "OneHealthID Endorsement - Action Required",
body: $@"Hello,
body: this.GetBodyString(token, true)
);
await this.emailService.SendAsync(email);
}

private async Task SendExpireOldEndorsementRequestsEmailAsync(string partyEmail)
{
var email = new Email(
from: EmailService.PidpEmail,
to: partyEmail,
subject: "OneHealthID Endorsement – Endorsement Request Expired",
body: this.GetBodyString()
);
await this.emailService.SendAsync(email);
}

private string GetBodyString(Guid? token = null, bool is7DaysNotify = false)
{
var url = this.applicationUrl.SetQueryParam("endorsement-token", token);
var link = $"<a href=\"{url}\" target=\"_blank\" rel=\"noopener noreferrer\">OneHealthID Service</a>";
var licensedlink = $"<a href=\"https://www.doctorsofbc.ca/sites/default/files/endorsement_licensed_initiated_4.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">Licensed Initiated</a>";
var unLicensedlink = $"<a href=\"https://www.doctorsofbc.ca/sites/default/files/endorsement_unlicensed_initiated_4.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">Unlicensed Initiated</a>";
var pidpSupportEmail = $"<a href=\"mailto:{EmailService.PidpEmail}\">{EmailService.PidpEmail}</a>";
var pidpSupportPhone = $"<a href=\"tel:{EmailService.PidpSupportPhone}\">{EmailService.PidpSupportPhone}</a>";

var bodyString = $@"Hello,
<br>
<br>Recently an endorsement for the OneHealthID was started either by you or another member of
your clinic. This process has not been completed. Completing the endorsement process allows
users who are not physicians or nurse practitioners to access common healthcare services, such
as the Provincial Attachment System (PAS).
<br>This email is to inform you that your endorsement request has now expired due to inactivity of 30 days or more.
<br>
<br>To complete the pending endorsement(s), log into the OneHealthID Service with your BC
Services Card app: {link}
<br>If you would like to restart the process and set up an endorsement, log into the OneHealthID Service with your BC Services Card app: {link}
<br>
<br>After logging in, please:
<br>&emsp;1. Complete the mandatory first time login steps (if this is your first time logging in to OneHealthID).
<br>For additional support and information on the endorsement process,
please refer to these infographics hosted on the Doctors of BC website here: {licensedlink} or {unLicensedlink}.
Or contact the OneHealthID Service desk:
<br>
<br>&emsp;• By email at {pidpSupportEmail}
<br>
<br>&emsp;• By phone at {pidpSupportPhone}
<br>
<br>Thank you.";

if (is7DaysNotify)
{
bodyString = $@"Hello,
<br>
<br>You recently started an endorsement request with another individual in OneHealthID.
Users have 30 days to complete the endorsement process before it expires.
Your request has been inactive for 7 days. To complete the pending endorsements,
log into the OneHealthID Service with your BC Services Card app: {link}
<br>
<br>After logging in, please complete these steps, if applicable:
<br>&emsp;1. Mandatory first-time login steps (if this is your first time logging in to OneHealthID).
<br>&emsp;2. Review the pending endorsements in the “Endorsements” tile under “Organization Info”.
<br>&emsp;3. Each pending endorsement will be listed under “Incoming Requests.” To confirm the endorsement, click “Approve” next to the request.
<br>
<br>For additional support, contact the OneHealthID Service desk:
<br>For additional support and information on the endorsement process,
please refer to these infographics hosted on the Doctors of BC website here: {licensedlink} or {unLicensedlink}.
Or contact the OneHealthID Service desk:
<br>
<br>&emsp;• By email at {pidpSupportEmail}
<br>
<br>&emsp;• By phone at {pidpSupportPhone}
<br>
<br>Thank you."
);
await this.emailService.SendAsync(email);
<br>Thank you.";
}
return bodyString;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ public static partial class UpdateBcProviderAttributesConsumerLoggingExtensions
[LoggerMessage(1, LogLevel.Error, "Error when updating attributes to User {upn} in Azure AD.")]
public static partial void LogUpdateBcProviderAttributesFailed(this ILogger<UpdateBcProviderAttributesConsumer> logger, string upn);
}

4 changes: 4 additions & 0 deletions backend/webapi/pidp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.Graph" Version="5.11.0" />
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.11.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ ol {
margin-bottom: 0;
width: var(--form-card-width);
opacity: 0;
visibility: hidden;

& p {
margin: 0;
Expand All @@ -245,7 +244,6 @@ ol {
padding: var(--gap);
margin-bottom: var(--gap);
opacity: 1;
visibility: visible;
border: solid 1px pidp.$grey-30;
border-radius: var(--card-border-radius);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
margin-bottom: 0;
width: var(--form-card-width);
opacity: 0;
visibility: hidden;

& p {
margin: 0;
Expand All @@ -76,7 +75,6 @@
padding: var(--gap);
margin-bottom: var(--gap);
opacity: 1;
visibility: visible;
border: solid 1px pidp.$grey-30;
border-radius: var(--card-border-radius);
}
Expand Down

0 comments on commit f84506a

Please sign in to comment.