Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paahn committed Mar 26, 2024
2 parents 57fe789 + 49b76da commit 99ee87b
Show file tree
Hide file tree
Showing 58 changed files with 2,369 additions and 61 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/dev-deploy-db-migration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy DB Migration - Dev

on:
push:
branches: [develop]
workflow_dispatch:

# This will terminate builds that are previously, but continuing to run. Saves GHA hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

helm-deployment:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1

- name: Authenticate and set context
uses: redhat-actions/[email protected]
with:
openshift_server_url: ${{secrets.OPENSHIFT_CLUSTER_URL}}
openshift_token: ${{secrets.OPENSHIFT_PIPELINE_SERVICE_ACCOUNT_TOKEN}}

- name: deply db migration job
run: |
oc project d8a8f9-dev
echo deleting dev-webapi-migrations job
oc delete job/dev-webapi-migrations --ignore-not-found
echo applying web-api-migration template...
helm template dev charts/webapi -n d8a8f9-dev --values ./deploy/dev_values.yaml -s templates/migrations.yaml --wait --debug| oc apply -n d8a8f9-dev -f -
echo deleting dev-plr-intake-migrations job
oc delete job/dev-plr-intake-migrations --ignore-not-found
echo applying plr-intake-migration template...
helm template dev charts/plr-intake -n d8a8f9-dev --values ./deploy/dev_values.yaml -s templates/migrations.yaml --wait --debug| oc apply -n d8a8f9-dev -f -
40 changes: 40 additions & 0 deletions .github/workflows/main-deploy-db-migration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy DB Migration - Prod

on:
push:
branches: [main]
workflow_dispatch:

# This will terminate builds that are previously, but continuing to run. Saves GHA hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

helm-deployment:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1

- name: Authenticate and set context
uses: redhat-actions/[email protected]
with:
openshift_server_url: ${{secrets.OPENSHIFT_CLUSTER_URL}}
openshift_token: ${{secrets.OPENSHIFT_PIPELINE_SERVICE_ACCOUNT_TOKEN}}

- name: deply db migration job
run: |
oc project d8a8f9-prod
echo deleting prod-webapi-migrations job
oc delete job/prod-webapi-migrations -n d8a8f9-prod --ignore-not-found
echo applying web-api-migration template...
helm template prod charts/webapi -n d8a8f9-prod --values ./deploy/prod_values.yaml -s templates/migrations.yaml --wait --debug| oc apply -n d8a8f9-prod -f -
echo deleting prod-plr-intake-migrations job
oc delete job/prod-plr-intake-migrations -n d8a8f9-prod --ignore-not-found
echo applying plr-intake-migration template...
helm template prod charts/plr-intake -n d8a8f9-prod --values ./deploy/prod_values.yaml -s templates/migrations.yaml --wait --debug| oc apply -n d8a8f9-prod -f -
40 changes: 40 additions & 0 deletions .github/workflows/test-deploy-db-migration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy DB Migration - Test

on:
push:
branches: [test]
workflow_dispatch:

# This will terminate builds that are previously, but continuing to run. Saves GHA hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

helm-deployment:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1

- name: Authenticate and set context
uses: redhat-actions/[email protected]
with:
openshift_server_url: ${{secrets.OPENSHIFT_CLUSTER_URL}}
openshift_token: ${{secrets.OPENSHIFT_PIPELINE_SERVICE_ACCOUNT_TOKEN}}

- name: deply db migration job into d8a8f9-test
run: |
oc project d8a8f9-test
echo deleting test-webapi-migrations job
oc delete job/test-webapi-migrations --ignore-not-found
echo applying web-api-migration template...
helm template test charts/webapi -n d8a8f9-test --values ./deploy/test_values.yaml -s templates/migrations.yaml --wait --debug| oc apply -f -
echo deleting test-plr-intake-migrations job
oc delete job/test-plr-intake-migrations --ignore-not-found
echo applying plr-intake-migration template...
helm template test charts/plr-intake -n d8a8f9-test --values ./deploy/test_values.yaml -s templates/migrations.yaml --wait --debug| oc apply -f -
6 changes: 6 additions & 0 deletions backend/pidp-backend.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "endorsement-reminder", "ser
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "endorsement-reminder.tests", "services.endorsement-reminder.tests\endorsement-reminder.tests.csproj", "{1251BD7F-30CB-4333-87D3-A96912F86361}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "update-opid", "tools.update-opid\update-opid.csproj", "{631ECF6D-6E61-49EF-933B-B9423A068032}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -48,5 +50,9 @@ Global
{1251BD7F-30CB-4333-87D3-A96912F86361}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1251BD7F-30CB-4333-87D3-A96912F86361}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1251BD7F-30CB-4333-87D3-A96912F86361}.Release|Any CPU.Build.0 = Release|Any CPU
{631ECF6D-6E61-49EF-933B-B9423A068032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{631ECF6D-6E61-49EF-933B-B9423A068032}.Debug|Any CPU.Build.0 = Debug|Any CPU
{631ECF6D-6E61-49EF-933B-B9423A068032}.Release|Any CPU.ActiveCfg = Release|Any CPU
{631ECF6D-6E61-49EF-933B-B9423A068032}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
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
2 changes: 1 addition & 1 deletion backend/services.plr-intake/Models/PlrRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class PlrRecord : BaseAuditable

public static bool ComputeGoodStanding(string? statusCode, string? statusReasonCode)
{
var goodStandingReasons = new[] { "GS", "PRAC", "TEMPPER" };
var goodStandingReasons = new[] { "GS", "PRAC", "TEMPPER", "TI" };
return statusCode == "ACTIVE"
&& goodStandingReasons.Contains(statusReasonCode);
}
Expand Down
19 changes: 19 additions & 0 deletions backend/tools.update-opid/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"dotnet.defaultSolution": "../pidp-backend.sln",
"editor.bracketPairColorization.enabled": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.guides.bracketPairs": "active",
"editor.minimap.enabled": true,
"editor.renderWhitespace": "boundary",
"editor.tabSize": 4,
"files.autoSave": "onFocusChange",
"files.trimTrailingWhitespace": true,
"git.ignoreLimitWarning": true,
"omnisharp.enableEditorConfigSupport": true,
"search.exclude": {
"**/bin": true,
"**/logs": true,
"**/obj": true,
},
}
57 changes: 57 additions & 0 deletions backend/tools.update-opid/HostedServiceWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
namespace UpdateOpId;

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

internal sealed class HostedServiceWrapper : IHostedService
{
private readonly IUpdateOpIdService service;
private readonly IHostApplicationLifetime appLifetime;
private readonly ILogger logger;
private int? exitCode;

public HostedServiceWrapper(
IUpdateOpIdService service,
IHostApplicationLifetime appLifetime,
ILogger<HostedServiceWrapper> logger)
{
this.service = service;
this.appLifetime = appLifetime;
this.logger = logger;
}

public Task StartAsync(CancellationToken cancellationToken)
{
this.appLifetime.ApplicationStarted.Register(async () =>
{
try
{
await this.service.UpdateOpIdAsync();
this.exitCode = 0;
}
catch (Exception ex)
{
this.logger.LogUnhandledException(ex);
this.exitCode = 1;
}
finally
{
this.appLifetime.StopApplication();
}
});

return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
Environment.ExitCode = this.exitCode.GetValueOrDefault(-1);
return Task.CompletedTask;
}
}

public static partial class HostedServiceWrapperLoggingExtensions
{
[LoggerMessage(1, LogLevel.Error, "Unhandled exception in HostedServiceWrapper.")]
public static partial void LogUnhandledException(this ILogger logger, Exception e);
}
12 changes: 12 additions & 0 deletions backend/tools.update-opid/IUpdateOpIdService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace UpdateOpId;

public interface IUpdateOpIdService
{
/// <summary>
/// Generates an identifier for each Party in the database
/// with a BCSC account that does not have an OpId
/// and updates the party in the database.
/// </summary>
/// <returns></returns>
public Task UpdateOpIdAsync();
}
Loading

0 comments on commit 99ee87b

Please sign in to comment.