Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
neophyte57 committed Apr 29, 2024
2 parents eaaf5d6 + d9d691c commit 4c7fa11
Show file tree
Hide file tree
Showing 18 changed files with 17,389 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import { FormUtilsService } from '@core/services/form-utils.service';
import { CareSettingEnum } from '@shared/enums/care-setting.enum';
import { AuthService } from '@auth/shared/services/auth.service';
import { PermissionService } from '@auth/shared/services/permission.service';
import { Role } from '@auth/shared/enum/role.enum';

import { EnrolmentRoutes } from '@enrolment/enrolment.routes';
import { OboSite } from '@enrolment/shared/models/obo-site.model';
import { CareSetting } from '@enrolment/shared/models/care-setting.model';
import { BaseEnrolmentProfilePage } from '@enrolment/shared/classes/enrolment-profile-page.class';
import { EnrolmentFormStateService } from '@enrolment/shared/services/enrolment-form-state.service';
Expand All @@ -29,6 +27,7 @@ import { FormArrayValidators } from '@lib/validators/form-array.validators';
styleUrls: ['./care-setting.component.scss']
})
export class CareSettingComponent extends BaseEnrolmentProfilePage implements OnInit, OnDestroy {

public careSettingTypes: Config<number>[];
public filteredCareSettingTypes: Config<number>[];
public healthAuthorities: Config<number>[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
let-setting="setting"
let-settingPlural="settingPlural"
let-settingCode="settingCode"
let-healthAuthorityCode="healthAuthorityCode"
let-formArray="formArray"
let-formArrayName="formArrayName"
let-subheaderContent="subheaderContent">
Expand All @@ -73,7 +74,7 @@
[index]="i"
[validate]="true"
[showRemoveButton]="i>0"
(remove)="removeEmail(settingCode, $event)">
(remove)="removeEmail(settingCode, healthAuthorityCode, $event)">
</app-email-form>
</ng-container>
</div>
Expand All @@ -82,7 +83,7 @@
<button mat-button
type="button"
color="primary"
(click)="addEmptyEmailInput(settingCode)">
(click)="addEmptyEmailInput(settingCode, healthAuthorityCode)">
<mat-icon>add</mat-icon>
Add email of PharmaNet administrator
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FormUtilsService } from '@core/services/form-utils.service';
import { ToastService } from '@core/services/toast.service';
import { UtilsService } from '@core/services/utils.service';
import { EnrolmentRoutes } from '@enrolment/enrolment.routes';
import { Config } from '@config/config.model';
import { BaseEnrolmentProfilePage } from '@enrolment/shared/classes/enrolment-profile-page.class';
import { EnrolmentFormStateService } from '@enrolment/shared/services/enrolment-form-state.service';
import { EnrolmentResource } from '@enrolment/shared/services/enrolment-resource.service';
Expand All @@ -18,6 +19,7 @@ import { DialogOptions } from '@shared/components/dialogs/dialog-options.model';
import { AgreementTypeGroup } from '@shared/enums/agreement-type-group.enum';
import { CareSettingEnum } from '@shared/enums/care-setting.enum';
import { EnrolmentStatusEnum } from '@shared/enums/enrolment-status.enum';
import { HealthAuthorityEnum } from '@lib/enums/health-authority.enum';
import { Enrolment } from '@shared/models/enrolment.model';
import { EMPTY } from 'rxjs';
import { exhaustMap } from 'rxjs/operators';
Expand All @@ -37,6 +39,7 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn

public CareSettingEnum = CareSettingEnum;
public EnrolmentStatus = EnrolmentStatusEnum;
public HealthAuthorityEnum = HealthAuthorityEnum;

public showCommunityHealth: boolean;
public showPharmacist: boolean;
Expand All @@ -46,11 +49,13 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn

public initialEnrolment: boolean;
public complete: boolean;
public healthAuthorities: Config<number>[];

public careSettingConfigs: {
setting: string,
settingPlural: string,
settingCode: number,
healthAuthorityCode: number,
formArray: FormArray,
formArrayName: string,
subheaderContent: string;
Expand All @@ -70,6 +75,7 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
protected utilService: UtilsService,
protected formUtilsService: FormUtilsService,
protected authService: AuthService,
private configService: ConfigService,
) {
super(
route,
Expand All @@ -90,6 +96,7 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
this.showDeviceProvider = true;
this.title = 'Next Steps To Get PharmaNet';
this.careSettingConfigs = [];
this.healthAuthorities = this.configService.healthAuthorities;
}

public get careSettings() {
Expand All @@ -104,8 +111,28 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
return this.form.get('pharmacistEmails') as FormArray;
}

public get healthAuthorityEmails(): FormArray {
return this.form.get('healthAuthorityEmails') as FormArray;
public get healthAuthorityFraserEmails(): FormArray {
return this.form.get('healthAuthorityFraserEmails') as FormArray;
}

public get healthAuthorityNorthernEmails(): FormArray {
return this.form.get('healthAuthorityNorthernEmails') as FormArray;
}

public get healthAuthorityIslandEmails(): FormArray {
return this.form.get('healthAuthorityIslandEmails') as FormArray;
}

public get healthAuthorityInteriorEmails(): FormArray {
return this.form.get('healthAuthorityInteriorEmails') as FormArray;
}

public get healthAuthorityPHSAEmails(): FormArray {
return this.form.get('healthAuthorityPHSAEmails') as FormArray;
}

public get healthAuthorityVancouverCoastalEmails(): FormArray {
return this.form.get('healthAuthorityVancouverCoastalEmails') as FormArray;
}

public get deviceProviderEmails(): FormArray {
Expand Down Expand Up @@ -160,8 +187,9 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
return {
emails: config.formArray.value.map(email => email.email),
careSettingCode: config.settingCode,
};
})
healthAuthorityCode: config.settingCode === CareSettingEnum.HEALTH_AUTHORITY ? config.healthAuthorityCode : null,
}
});

return this.enrolmentResource.sendProvisionerAccessLink(emailPairs, this.enrolment.id);
} else {
Expand All @@ -177,7 +205,7 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
this.onPageChange({ atEnd: true });
}

public GetEmailsGroup(careSettingCode: number) {
public getEmailsGroup(careSettingCode: number, healthAuthorityCode: number) {
let formArray: FormArray;

switch (careSettingCode) {
Expand All @@ -190,7 +218,32 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
break;
}
case this.CareSettingEnum.HEALTH_AUTHORITY: {
formArray = this.healthAuthorityEmails;
switch (healthAuthorityCode) {
case this.HealthAuthorityEnum.FRASER_HEALTH: {
formArray = this.healthAuthorityFraserEmails;
break;
}
case this.HealthAuthorityEnum.INTERIOR_HEALTH: {
formArray = this.healthAuthorityInteriorEmails;
break;
}
case this.HealthAuthorityEnum.ISLAND_HEALTH: {
formArray = this.healthAuthorityIslandEmails;
break;
}
case this.HealthAuthorityEnum.PROVINCIAL_HEALTH_SERVICES_AUTHORITY: {
formArray = this.healthAuthorityPHSAEmails;
break;
}
case this.HealthAuthorityEnum.NORTHERN_HEALTH: {
formArray = this.healthAuthorityNorthernEmails;
break;
}
case this.HealthAuthorityEnum.VANCOUVER_COASTAL_HEALTH: {
formArray = this.healthAuthorityVancouverCoastalEmails;
break;
}
}
break;
}
case this.CareSettingEnum.DEVICE_PROVIDER: {
Expand Down Expand Up @@ -233,67 +286,102 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
this.enrolmentResource.getCurrentAgreementGroupForAnEnrollee(this.enrolment.id)
.subscribe((group: AgreementTypeGroup) => this.currentAgreementGroup = group)

this.careSettingConfigs = this.careSettings.map(careSetting => {
this.careSettingConfigs = [];
this.careSettings.forEach((careSetting) => {
switch (careSetting.careSettingCode) {
case CareSettingEnum.PRIVATE_COMMUNITY_HEALTH_PRACTICE: {
return {
setting: 'Private Community Health Practice',
settingPlural: 'Private Community Health Practices',
settingCode: careSetting.careSettingCode,
formArray: this.communityHealthEmails,
formArrayName: 'communityHealthEmails',
subheaderContent: `Send your approval to your private community health practice's PharmaNet administrator (e.g. office manager). If you work in more than one clinic make sure you include every PharmaNet administrator's email. Your PharmaNet administrator(s) will contact you once your PharmaNet access has been set up.`
};
this.careSettingConfigs.push(
{
setting: 'Private Community Health Practice',
settingPlural: 'Private Community Health Practices',
settingCode: careSetting.careSettingCode,
healthAuthorityCode: null,
formArray: this.communityHealthEmails,
formArrayName: 'communityHealthEmails',
subheaderContent: `Send your approval to your private community health practice's PharmaNet administrator (e.g. office manager). If you work in more than one clinic make sure you include every PharmaNet administrator's email. Your PharmaNet administrator(s) will contact you once your PharmaNet access has been set up.`
});
}
break;
case CareSettingEnum.COMMUNITY_PHARMACIST: {
return {
this.careSettingConfigs.push({
setting: 'Community Pharmacy',
settingPlural: 'Community Pharmacies',
settingCode: careSetting.careSettingCode,
healthAuthorityCode: null,
formArray: this.pharmacistEmails,
formArrayName: 'pharmacistEmails',
subheaderContent: `Send your approval to your community pharmacy's PharmaNet administrator (e.g. office manager). If you work in more than one clinic make sure you include every PharmaNet administrator's email. Your PharmaNet administrator(s) will contact you once your PharmaNet access has been set up.`
};
});
}
break;
case CareSettingEnum.HEALTH_AUTHORITY: {
return {
setting: 'Health Authority',
settingPlural: 'Health Authorities',
settingCode: careSetting.careSettingCode,
formArray: this.healthAuthorityEmails,
formArrayName: 'healthAuthorityEmails',
subheaderContent: `Send your approval to your health authority's PharmaNet administrator (e.g. office manager). If you work in more than one clinic make sure you include every PharmaNet administrator's email. Your PharmaNet administrator(s) will contact you once your PharmaNet access has been set up.`
};
this.enrolment.enrolleeHealthAuthorities.forEach((eha) => {
this.careSettingConfigs.push({
setting: `Health Authority - ${this.healthAuthorities.find((ha) => ha.code === +eha.healthAuthorityCode).name}`,
settingPlural: 'Health Authorities',
settingCode: careSetting.careSettingCode,
healthAuthorityCode: eha.healthAuthorityCode,
formArray: this.getEmailsGroup(careSetting.careSettingCode, eha.healthAuthorityCode),
formArrayName: this.getHAFormArrayName(eha.healthAuthorityCode),
subheaderContent: `Send your approval to your health authority's PharmaNet administrator (e.g. office manager). If you work in more than one clinic make sure you include every PharmaNet administrator's email. Your PharmaNet administrator(s) will contact you once your PharmaNet access has been set up.`
});
});
}
break;
case CareSettingEnum.DEVICE_PROVIDER: {
return {
this.careSettingConfigs.push({
setting: 'Device Provider',
settingPlural: 'Device Providers',
settingCode: careSetting.careSettingCode,
healthAuthorityCode: null,
formArray: this.deviceProviderEmails,
formArrayName: 'deviceProviderEmails',
subheaderContent: `Send your approval to your device provider's PharmaNet administrator (e.g. office manager). If you work in more than one clinic make sure you include every PharmaNet administrator's email. Your PharmaNet administrator(s) will contact you once your PharmaNet access has been set up.`
};
});
}
break;
}
});
}

public addEmptyEmailInput(settingCode: number) {
let emailsArray = this.GetEmailsGroup(settingCode);
protected getHAFormArrayName(healthAuthorityCode: number): string {
switch (healthAuthorityCode) {
case HealthAuthorityEnum.FRASER_HEALTH:
return "healthAuthorityFraserEmails";
case HealthAuthorityEnum.INTERIOR_HEALTH:
return "healthAuthorityInteriorEmails";
case HealthAuthorityEnum.ISLAND_HEALTH:
return "healthAuthorityIslandEmails";
case HealthAuthorityEnum.NORTHERN_HEALTH:
return "healthAuthorityNorthernEmails";
case HealthAuthorityEnum.PROVINCIAL_HEALTH_SERVICES_AUTHORITY:
return "healthAuthorityPHSAEmails";
case HealthAuthorityEnum.VANCOUVER_COASTAL_HEALTH:
return "healthAuthorityVancouverCoastalEmails";
}
return "";
}

public addEmptyEmailInput(settingCode: number, healthAuthorityCode: number) {
let emailsArray = this.getEmailsGroup(settingCode, healthAuthorityCode);
this.addEmail(emailsArray);
}

public removeEmail(settingCode: number, index: number): void {
let emailsArray = this.GetEmailsGroup(settingCode);
public removeEmail(settingCode: number, healthAuthorityCode: number, index: number): void {
let emailsArray = this.getEmailsGroup(settingCode, healthAuthorityCode);
emailsArray.removeAt(index);
}

protected initForm() {
if (!this.communityHealthEmails.length) {
this.addEmail(this.communityHealthEmails);
this.addEmail(this.pharmacistEmails);
this.addEmail(this.healthAuthorityEmails);
this.addEmail(this.healthAuthorityFraserEmails);
this.addEmail(this.healthAuthorityInteriorEmails);
this.addEmail(this.healthAuthorityIslandEmails);
this.addEmail(this.healthAuthorityNorthernEmails);
this.addEmail(this.healthAuthorityPHSAEmails);
this.addEmail(this.healthAuthorityVancouverCoastalEmails);
this.addEmail(this.deviceProviderEmails);
}
}
Expand Down Expand Up @@ -323,7 +411,12 @@ export class NextStepsComponent extends BaseEnrolmentProfilePage implements OnIn
return this.fb.group({
communityHealthEmails: this.fb.array([], [Validators.required]),
pharmacistEmails: this.fb.array([], [Validators.required]),
healthAuthorityEmails: this.fb.array([], [Validators.required]),
healthAuthorityFraserEmails: this.fb.array([], [Validators.required]),
healthAuthorityInteriorEmails: this.fb.array([], [Validators.required]),
healthAuthorityIslandEmails: this.fb.array([], [Validators.required]),
healthAuthorityNorthernEmails: this.fb.array([], [Validators.required]),
healthAuthorityPHSAEmails: this.fb.array([], [Validators.required]),
healthAuthorityVancouverCoastalEmails: this.fb.array([], [Validators.required]),
deviceProviderEmails: this.fb.array([], [Validators.required]),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
let-setting="setting"
let-settingPlural="settingPlural"
let-settingCode="settingCode"
let-healthAuthorityCode="healthAuthorityCode"
let-formArray="formArray"
let-formArrayName="formArrayName"
let-subheaderContent="subheaderContent">
Expand All @@ -175,7 +176,7 @@
[index]="i"
[validate]="true"
[showRemoveButton]="i>0"
(remove)="removeEmail(settingCode, $event)">
(remove)="removeEmail(settingCode, healthAuthorityCode, $event)">
</app-email-form>
</ng-container>
</div>
Expand All @@ -184,7 +185,7 @@
<button mat-button
type="button"
color="primary"
(click)="addEmptyEmailInput(settingCode)">
(click)="addEmptyEmailInput(settingCode, healthAuthorityCode)">
<mat-icon>add</mat-icon>
Add email of PharmaNet administrator
</button>
Expand Down
Loading

0 comments on commit 4c7fa11

Please sign in to comment.