Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRIME-2371 Non-BC Certification #2631

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prime-angular-frontend/src/app/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class LicenseConfig extends Config<number> implements IWeightedConfig {
validate: boolean;
manual: boolean;
prescriberIdType: PrescriberIdTypeEnum;
multijurisdictional: boolean;
}

export interface CollegeLicenseConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
*matHeaderCellDef
scope="col"
class="prefix-header pl-3">
ARRA
Remote Access
</th>
<td mat-cell
class="pl-3"
Expand All @@ -139,6 +139,20 @@
</td>
</ng-container>

<ng-container matColumnDef="multijurisdictional">
<th mat-header-cell
*matHeaderCellDef
scope="col"
class="prefix-header pl-3">
Multijur.
</th>
<td mat-cell
class="pl-3"
*matCellDef="let row;">
{{ row.multijurisdictional }}
</td>
</ng-container>

<tr mat-header-row
*matHeaderRowDef="columns; sticky: true"></tr>
<tr mat-row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class LicenseMaintenanceConfig implements IWeightedConfig {
prescriberIdType?: PrescriberIdTypeEnum;
weight: number;
collegeLicenseGroupingCode: number;
multijurisdictional?: boolean;
}

@Component({
Expand Down Expand Up @@ -51,7 +52,8 @@ export class LicenseClassesMaintenancePageComponent implements OnInit {
'manual',
'validate',
'prescriberIdType',
'allowRequestRemoteAccess'
'allowRequestRemoteAccess',
'multijurisdictional'
];
this.dataSource = new MatTableDataSource<LicenseMaintenanceConfig>([]);
this.routeUtils = new RouteUtils(route, router, AdjudicationRoutes.routePath(AdjudicationRoutes.ENROLLEES));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Enrolment } from '@shared/models/enrolment.model';

export interface EnrolmentRegulatoryForm extends Pick<Enrolment, 'certifications' | 'enrolleeDeviceProviders'> { }
export interface EnrolmentRegulatoryForm extends Pick<Enrolment, 'certifications' | 'enrolleeDeviceProviders' | 'unlistedCertifications'> { }
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ConfigService } from '@config/config.service';
import { CollegeLicenceClassEnum } from '@shared/enums/college-licence-class.enum';

import { EnrolmentRegulatoryForm } from './enrolment-regulatory-form.model';
import { UnlistedCertification } from '@paper-enrolment/shared/models/unlisted-certification.model';
export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryForm> {
public colleges: CollegeConfig[];

Expand Down Expand Up @@ -39,6 +40,10 @@ export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryFo
return this.formInstance.get('certificationNumber') as FormControl;
}

public get unlistedCertifications(): FormArray {
return this.formInstance.get('unlistedCertifications') as FormArray;
}

/**
* @description
* Access to college certifications where a self-documenting
Expand All @@ -55,7 +60,7 @@ export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryFo
return;
}

const { certifications: rawCertifications, deviceProviderId, deviceProviderRoleCode, certificationNumber } = this.formInstance.getRawValue();
const { certifications: rawCertifications, deviceProviderId, deviceProviderRoleCode, certificationNumber, unlistedCertifications } = this.formInstance.getRawValue();
let certifications = rawCertifications.map(c => {
const { category, ...collegeCertification } = c;
return collegeCertification;
Expand All @@ -69,10 +74,10 @@ export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryFo
const enrolleeDeviceProviders = deviceProviderRoleCode ?
[{ deviceProviderId, deviceProviderRoleCode, certificationNumber }] : [];

return { certifications, enrolleeDeviceProviders }
return { certifications, enrolleeDeviceProviders, unlistedCertifications }
}

public patchValue({ certifications, enrolleeDeviceProviders }: EnrolmentRegulatoryForm): void {
public patchValue({ certifications, enrolleeDeviceProviders, unlistedCertifications }: EnrolmentRegulatoryForm): void {

if (!this.formInstance || !Array.isArray(certifications)) {
return;
Expand All @@ -83,6 +88,9 @@ export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryFo
if (certifications.length) {
certifications.forEach((c: CollegeCertification) => this.addCollegeCertification(c));
}
if (unlistedCertifications && unlistedCertifications.length) {
unlistedCertifications.forEach((c: UnlistedCertification) => this.addUnlistedCertification(c));
}
if (enrolleeDeviceProviders && enrolleeDeviceProviders.length) {
const { deviceProviderId, deviceProviderRoleCode, certificationNumber } = enrolleeDeviceProviders[0];
this.formInstance.patchValue({ certifications, deviceProviderId, deviceProviderRoleCode, certificationNumber });
Expand All @@ -97,7 +105,8 @@ export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryFo
deviceProviderIdentifier: [null, []],
deviceProviderId: [null, []],
deviceProviderRoleCode: [null, []],
certificationNumber: [null, []]
certificationNumber: [null, []],
unlistedCertifications: this.fb.array([]),
});
}

Expand Down Expand Up @@ -148,4 +157,25 @@ export class RegulatoryFormState extends AbstractFormState<EnrolmentRegulatoryFo
const college = this.colleges.find((c) => c.code === collegeCode);
return college ? college.collegeLicenses.some((l) => l.collegeLicenseGroupingCode) : false;
}


public buildUnlistedCollegeCertificationForm(): FormGroup {
return this.fb.group({
collegeName: ['', []],
licenceNumber: ['', []],
licenceClass: ['', []],
renewalDate: ['', []]
})
}

public addUnlistedCertification(unlistedCertification?: UnlistedCertification): void {
const unlistedCert = this.buildUnlistedCollegeCertificationForm();
unlistedCert.patchValue({ ...unlistedCertification });
this.unlistedCertifications.push(unlistedCert);
}

public addEmptyUnlistedCollegeCertification(): void {
this.addUnlistedCertification();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
[index]="i"
[total]="formState.certifications.controls.length"
[selectedColleges]="selectedCollegeCodes"
(licenceCodeSelected)="licenceCodeSelected($event)"
[selectedLicenses]="selectedLicenseCodes"
(remove)="removeCertification($event)">
</app-college-certification-form>
Expand All @@ -142,6 +143,40 @@
</div>
</div>

<div class="row">

<div class="col col-sm-10 py-3"
formArrayName="unlistedCertifications">
<app-toggle-content label="This user has a college licence not listed in the dropdown"
[checked]="hasUnlistedCertification"
[disabled]="disableUnlistedCertificationToggle"
(toggle)="onUnlistedCertification($event)">

<ng-container *ngFor="let unlistedCertificate of formState.unlistedCertifications.controls; let i = index;"
[formGroupName]="i">
<app-unlisted-college-licence-form [form]="unlistedCertificate"
[index]="i"
[total]="formState.unlistedCertifications.controls.length"
[formState]="formState"
[validate]="hasUnlistedCertification"
(remove)="removeUnlistedCertification($event)">

</app-unlisted-college-licence-form>
</ng-container>

<button mat-button
type="button"
color="primary"
(click)="formState.addEmptyUnlistedCollegeCertification()">
<mat-icon>add</mat-icon>
Add additional licences not listed in the dropdown
</button>

</app-toggle-content>
</div>
</div>


</section>

</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('RegulatoryComponent', () => {
licenseCode: 1,
licenseNumber: "12345"
}],
unlistedCertifications: [],
enrolleeDeviceProviders: [],
} as EnrolmentRegulatoryForm;

Expand All @@ -191,6 +192,7 @@ describe('RegulatoryComponent', () => {
licenseCode: 1,
licenseNumber: "12345"
}],
unlistedCertifications: [],
enrolleeDeviceProviders: [],
} as EnrolmentRegulatoryForm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { UtilsService } from '@core/services/utils.service';
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 { DeviceProviderRoleConfig } from '@config/config.model';
import { DeviceProviderRoleConfig, LicenseConfig } from '@config/config.model';
import { DialogOptions } from '@shared/components/dialogs/dialog-options.model';
import { ConfirmDialogComponent } from '@shared/components/dialogs/confirm-dialog/confirm-dialog.component';

Expand All @@ -28,6 +28,7 @@ import { DeviceProviderSite } from '@shared/models/device-provider-site.model';

import { RegulatoryFormState } from './regulatory-form-state';
import { ConfigService } from '@config/config.service';
import { ToggleContentChange } from '@shared/components/toggle-content/toggle-content.component';

@Component({
selector: 'app-regulatory',
Expand All @@ -41,6 +42,11 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
public hasOtherCareSetting: boolean;
public deviceProviderRoles: DeviceProviderRoleConfig[];
public deviceProviderSite: DeviceProviderSite;
public hasUnlistedCertification: boolean;
public unlistedCertificationRequired: boolean;
public disableUnlistedCertificationToggle: boolean;
public multijurisdictionalLicenceCode: LicenseConfig[];

constructor(
protected route: ActivatedRoute,
protected router: Router,
Expand Down Expand Up @@ -68,8 +74,9 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
formUtilsService,
authService
);

this.hasUnlistedCertification = false;
this.cannotRequestRemoteAccess = false;
this.disableUnlistedCertificationToggle = false;
this.deviceProviderRoles = this.configService.deviceProviderRoles;
}

Expand Down Expand Up @@ -99,17 +106,40 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
this.formState.certifications.removeAt(index);
}

public licenceCodeSelected(code: number) {
if (this.multijurisdictionalLicenceCode.some(l => l.code === code)) {
this.hasUnlistedCertification = true;
this.disableUnlistedCertificationToggle = true;
if (!this.formState.unlistedCertifications.length) {
this.formState.addEmptyUnlistedCollegeCertification();
}
} else {
this.hasUnlistedCertification = false;
this.disableUnlistedCertificationToggle = false;
if (this.formState.unlistedCertifications.length) {
this.formState.json.unlistedCertifications = [];
}
}
}

public ngOnInit() {
this.isDeviceProvider = this.enrolmentService.enrolment.careSettings.some((careSetting) =>
careSetting.careSettingCode === CareSettingEnum.DEVICE_PROVIDER);
this.hasOtherCareSetting = this.enrolmentService.enrolment.careSettings.some((careSetting) =>
careSetting.careSettingCode !== CareSettingEnum.DEVICE_PROVIDER);
this.createFormInstance();
this.patchForm().subscribe(() => this.initForm());
this.patchForm().subscribe(() => {
this.initForm();
if (this.formState.json.unlistedCertifications.length > 0) {
this.hasUnlistedCertification = true;
}
});
this.multijurisdictionalLicenceCode = this.configService.licenses.filter(l => l.multijurisdictional);
}

public ngOnDestroy() {
this.removeIncompleteCertifications(true);
this.removeIncompleteUnlistedCertification();
}

protected createFormInstance() {
Expand Down Expand Up @@ -171,8 +201,8 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
}

// Replace previous values on deactivation so updates are discarded
const { certifications, enrolleeDeviceProviders } = this.enrolmentService.enrolment;
this.formState.patchValue({ certifications, enrolleeDeviceProviders });
const { certifications, enrolleeDeviceProviders, unlistedCertifications } = this.enrolmentService.enrolment;
this.formState.patchValue({ certifications, enrolleeDeviceProviders, unlistedCertifications });
}

public onSubmit() {
Expand Down Expand Up @@ -219,6 +249,7 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI

protected afterSubmitIsSuccessful() {
this.removeIncompleteCertifications(true);
this.removeIncompleteUnlistedCertification();
}

protected nextRouteAfterSubmit() {
Expand Down Expand Up @@ -259,6 +290,16 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
}
}

private removeIncompleteUnlistedCertification() {
this.formState.unlistedCertifications.controls
.forEach((control: FormGroup, index: number) => {
// Remove if college code is "None" or the group is invalid
if (!control.get('collegeName').value || (control.invalid && !this.enrolmentService.isProfileComplete)) {
this.formState.unlistedCertifications.removeAt(index);
}
});
}

/**
* @description
* Remove obo sites from the enrolment as enrollees can not have
Expand Down Expand Up @@ -315,4 +356,23 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
this.formState.certificationNumber.disable();
}
}

public onUnlistedCertification({ checked }: ToggleContentChange) {
if (!checked) {
this.hasUnlistedCertification = false;
this.formState.json.unlistedCertifications = [];
} else {
this.hasUnlistedCertification = true;
if (!this.formState.unlistedCertifications.length) {
this.formState.addEmptyUnlistedCollegeCertification();
}
}
}

public removeUnlistedCertification(index: number): void {
this.formState.unlistedCertifications.removeAt(index);
if (!this.formState.unlistedCertifications.length) {
this.hasUnlistedCertification = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ export class EnrolmentFormStateService extends AbstractFormStateService<Enrolmen
(this.identityProvider === IdentityProviderEnum.BCEID)
? this.bceidDemographicFormState.patchValue(enrolment.enrollee)
: this.bcscDemographicFormState.patchValue(enrolment.enrollee);
const { certifications, enrolleeDeviceProviders } = enrolment;
this.regulatoryFormState.patchValue({ certifications, enrolleeDeviceProviders });
const { certifications, enrolleeDeviceProviders, unlistedCertifications } = enrolment;
this.regulatoryFormState.patchValue({ certifications, enrolleeDeviceProviders, unlistedCertifications });

const {
careSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { SelfDeclarationVersion } from '@shared/models/self-declaration-version.
import { EmailsForCareSetting } from '@shared/models/email-for-care-setting.model';
import { EnrolleeDeviceProvider } from '@shared/models/enrollee-device-provider.model';
import { DeviceProviderSite } from "@shared/models/device-provider-site.model";
import { UnlistedCertification } from '@paper-enrolment/shared/models/unlisted-certification.model';

@Injectable({
providedIn: 'root'
Expand All @@ -59,6 +60,8 @@ export class EnrolmentResource {
.pipe(map((response: ApiHttpResponse<CareSetting>) => response.result)),
certifications: this.apiResource.get<CollegeCertification[]>(`enrollees/${enrollee.id}/certifications`)
.pipe(map((response: ApiHttpResponse<CollegeCertification[]>) => response.result)),
unlistedCertifications: this.apiResource.get<UnlistedCertification[]>(`enrollees/${enrollee.id}/unlisted-certifications`)
.pipe(map((response: ApiHttpResponse<UnlistedCertification[]>) => response.result)),
enrolleeDeviceProviders: this.apiResource.get<EnrolleeDeviceProvider[]>(`enrollees/${enrollee.id}/device-providers`)
.pipe(map((response: ApiHttpResponse<EnrolleeDeviceProvider[]>) => response.result)),
enrolleeRemoteUsers: this.apiResource.get<EnrolleeRemoteUser[]>(`enrollees/${enrollee.id}/remote-users`)
Expand Down
Loading
Loading