Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { waitForAsync, ComponentFixture, TestBed, inject } from '@angular/core/t
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';

import * as faker from 'faker';
import { KeycloakService } from 'keycloak-angular';
Expand All @@ -28,7 +29,8 @@ describe('AccessAgreementHistoryEnrolmentComponent', () => {
NgxBusyModule,
HttpClientTestingModule,
RouterTestingModule,
NgxMaterialModule
NgxMaterialModule,
ReactiveFormsModule
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ export class OverviewComponent extends BaseEnrolmentPage implements OnInit {
requiresLicenceUpdate: enrolment.certifications.some((cert: CollegeCertification) =>
this.configService.licenses.some(l => l.code === cert.licenseCode && l.collegeLicenses.some(cl => cl.collegeCode === cert.collegeCode && cl.discontinued))),
requireRedoSelfDeclaration: enrolment.requireRedoSelfDeclaration,
requireUpdateSelfDeclaration: this.enrolmentFormStateService.json.careSettings.some(cs => cs.careSettingCode === CareSettingEnum.DEVICE_PROVIDER)
&& this.enrolmentService.enrolment.selfDeclarations.length == 4 && this.enrolmentService.enrolment.selfDeclarationCompletedDate == enrolment.selfDeclarationCompletedDate,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ export class RegulatoryComponent extends BaseEnrolmentProfilePage implements OnI
}

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.isDeviceProvider = this.enrolmentService.isInitialEnrolment ?
this.enrolmentService.enrolment.careSettings.some((careSetting) =>
careSetting.careSettingCode === CareSettingEnum.DEVICE_PROVIDER) :
this.enrolmentFormStateService.json.careSettings.some(cs => cs.careSettingCode === CareSettingEnum.DEVICE_PROVIDER);

this.hasOtherCareSetting = this.enrolmentService.isInitialEnrolment ?
this.enrolmentService.enrolment.careSettings.some((careSetting) =>
careSetting.careSettingCode !== CareSettingEnum.DEVICE_PROVIDER) :
this.enrolmentFormStateService.json.careSettings.some(cs => cs.careSettingCode !== CareSettingEnum.DEVICE_PROVIDER);

this.createFormInstance();
this.patchForm().subscribe(() => this.initForm());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,10 @@ export class EnrolmentFormStateService extends AbstractFormStateService<Enrolmen
const selfDeclarationDetails = selfDeclarations
.find(esd => esd.selfDeclarationTypeCode === type)
?.selfDeclarationDetails;
const selfDeclaration = selfDeclarations
.find(esd => esd.selfDeclarationTypeCode === type);
const adapted = {
[sd]: (selfDeclarationDetails) ? true : defaultValue,
[sd]: selfDeclaration ? (selfDeclarationDetails) ? true : defaultValue : null,
[`${sd}Details`]: (selfDeclarationDetails) ? selfDeclarationDetails : null
};
return { ...sds, ...adapted };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AbstractOverview } from '@lib/classes/abstract-overview.class';

import { PaperEnrolmentRoutes } from '@paper-enrolment/paper-enrolment.routes';
import { RegulatoryForm } from './regulatory-form.model';
import { EnrolleeDeviceProvider } from '@shared/models/enrollee-device-provider.model';

@Component({
selector: 'app-regulatory-overview',
Expand All @@ -23,17 +24,17 @@ import { RegulatoryForm } from './regulatory-form.model';

<app-enrollee-property title="User Role"
[makeBold]="true">
{{ regulatory?.enrolleeDeviceProviders[0].deviceProviderRoleCode | configCode: 'deviecProviderRoles' | default }}
{{ deviceProviderUseRoleCode | configCode: 'deviecProviderRoles' | default }}
</app-enrollee-property>

<app-enrollee-property title="Device Provider ID"
[makeBold]="true">
{{ regulatory?.enrolleeDeviceProviders[0].deviceProviderId | default }}
{{ deviceProviderId | default }}
</app-enrollee-property>

<app-enrollee-property title="Certificate Number"
[makeBold]="true">
{{ regulatory?.enrolleeDeviceProviders[0].certificationNumber | default }}
{{ certificationNumber | default }}
</app-enrollee-property>
<button mat-flat-button
color="primary"
Expand Down Expand Up @@ -149,6 +150,21 @@ export class RegulatoryOverviewComponent extends AbstractOverview {
@Input() public regulatory: RegulatoryForm;
public PaperEnrolmentRoutes = PaperEnrolmentRoutes;

public get deviceProviderUseRoleCode(): string {
return this.regulatory?.enrolleeDeviceProviders ?
this.regulatory?.enrolleeDeviceProviders[0].deviceProviderRoleCode : "";
}

public get deviceProviderId(): string {
return this.regulatory?.enrolleeDeviceProviders ?
this.regulatory?.enrolleeDeviceProviders[0].deviceProviderId : "";
}

public get certificationNumber(): string {
return this.regulatory?.enrolleeDeviceProviders ?
this.regulatory?.enrolleeDeviceProviders[0].certificationNumber : "";
}

constructor(
route: ActivatedRoute,
router: Router
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,20 @@
</app-page-subheader>

<app-enrollee-property title="User Role"
[hasError]="enrolmentErrors?.deviceProvider"
errorMessage="Must have device provider information"
[makeBold]="true">
{{ enrolleeDeviceProvider.deviceProviderRoleCode | configCode: 'deviceProviderRoles'| default }}
{{ enrolleeDeviceProvider?.deviceProviderRoleCode | configCode: 'deviceProviderRoles'| default }}
</app-enrollee-property>

<app-enrollee-property title="Device Provider ID"
[makeBold]="true">
{{ enrolleeDeviceProvider.deviceProviderId | default }}
{{ enrolleeDeviceProvider?.deviceProviderId | default }}
</app-enrollee-property>

<app-enrollee-property title="Certificate Number"
[makeBold]="true">
{{ enrolleeDeviceProvider.certificationNumber | default }}
{{ enrolleeDeviceProvider?.certificationNumber | default }}
</app-enrollee-property>

<button *ngIf="showEditRedirect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class EnrolleeReviewComponent {
}

public get hasDeviceProvider(): boolean {
return (this.enrolment && !!this.enrolment.enrolleeDeviceProviders?.length);
return (this.enrolment && (!!this.enrolment.enrolleeDeviceProviders.length || this.enrolment.careSettings.some(cs => cs.careSettingCode === 4)));
}

public get enrolleeDeviceProvider(): EnrolleeDeviceProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,46 @@
</ng-container>
</app-alert>

<app-alert *ngIf="requireUpdateIfChangedToDeviceProvider()"
type="danger"
icon="error">
<ng-container #alertContent
class="alert-content">
Please update Self-Declaration due to the care setting change.
</ng-container>
</app-alert>

<div *ngIf="this.showDescription && !this.enrolment.requireRedoSelfDeclaration"
class="mb-4">
<app-self-declaration-term></app-self-declaration-term>
</div>

<div *ngFor="let selfDeclarationComposite of selfDeclarationComposites"
class="mb-3">
<div *ngIf="selfDeclarationComposite.selfDeclarationQuestion">
<app-enrollee-property [safeTitle]="selfDeclarationComposite.selfDeclarationQuestion"
[makeBold]="false">
{{ selfDeclarationComposite.selfDeclaration?.answered | yesNo: true }}
</app-enrollee-property>

<app-enrollee-property [safeTitle]="selfDeclarationComposite.selfDeclarationQuestion"
[makeBold]="false">
{{ selfDeclarationComposite.selfDeclaration?.answered | yesNo: true }}
</app-enrollee-property>

<app-enrollee-property *ngIf="selfDeclarationComposite.selfDeclaration?.answered"
title="Description"
[makeBold]="false">
{{ selfDeclarationComposite.selfDeclaration.selfDeclarationDetails }}
</app-enrollee-property>

<div *ngIf="selfDeclarationComposite.selfDeclaration?.answered">
<button *ngFor="let selfDeclarationDocument of selfDeclarationComposite.selfDeclarationDocuments"
mat-stroked-button
color="primary"
class="pl-2 mb-2 mt-2"
(click)="downloadSelfDeclarationDocument(selfDeclarationDocument.id)">
<mat-icon class="mr-1">attachment</mat-icon>
{{ selfDeclarationDocument.filename }}
</button>
<app-enrollee-property *ngIf="selfDeclarationComposite.selfDeclaration?.answered"
title="Description"
[makeBold]="false">
{{ selfDeclarationComposite.selfDeclaration.selfDeclarationDetails }}
</app-enrollee-property>

<div *ngIf="selfDeclarationComposite.selfDeclaration?.answered">
<button *ngFor="let selfDeclarationDocument of selfDeclarationComposite.selfDeclarationDocuments"
mat-stroked-button
color="primary"
class="pl-2 mb-2 mt-2"
(click)="downloadSelfDeclarationDocument(selfDeclarationDocument.id)">
<mat-icon class="mr-1">attachment</mat-icon>
{{ selfDeclarationDocument.filename }}
</button>
</div>
</div>

</div>

<button *ngIf="showRedirect"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';

import { KeycloakService } from 'keycloak-angular';

import { MockConfigService } from 'test/mocks/mock-config.service';
import { MockAuthService } from 'test/mocks/mock-auth.service';
import { MockEnrolmentService } from 'test/mocks/mock-enrolment.service';

Expand All @@ -12,6 +14,7 @@ import { NgxMaterialModule } from '@lib/modules/ngx-material/ngx-material.module
import { AuthService } from '@auth/shared/services/auth.service';
import { EnrolmentService } from '@enrolment/shared/services/enrolment.service';
import { RouterTestingModule } from '@angular/router/testing';
import { ConfigService } from '@config/config.service';

import { EnrolleeSelfDeclarationsComponent } from './enrollee-self-declarations.component';

Expand All @@ -24,13 +27,18 @@ describe('EnrolleeSelfDeclarationsComponent', () => {
imports: [
RouterTestingModule,
HttpClientTestingModule,
NgxMaterialModule
NgxMaterialModule,
ReactiveFormsModule,
],
providers: [
{
provide: APP_CONFIG,
useValue: APP_DI_CONFIG
},
{
provide: ConfigService,
useClass: MockConfigService
},
{
provide: AuthService,
useValue: MockAuthService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SelfDeclarationDocument } from '@shared/models/self-declaration-documen
import { SelfDeclaration } from '@shared/models/self-declarations.model';
import { SelfDeclarationVersion } from '@shared/models/self-declaration-version.model';
import { CareSettingEnum } from '@shared/enums/care-setting.enum';
import { EnrolmentFormStateService } from '@enrolment/shared/services/enrolment-form-state.service';

interface SelfDeclarationComposite {
selfDeclarationTypeCode: SelfDeclarationTypeEnum;
Expand Down Expand Up @@ -54,12 +55,19 @@ export class EnrolleeSelfDeclarationsComponent implements OnChanges, OnInit {

constructor(
private enrolmentResource: EnrolmentResource,
private enrolmentFormStateService: EnrolmentFormStateService,
private utilsService: UtilsService,
private router: Router
) {
this.route = new EventEmitter<void>();
}

public requireUpdateIfChangedToDeviceProvider(): boolean {
//check if the care setting has been changed to Device Provider or from Device Provider to other care setting
return this.enrolmentFormStateService.json.careSettings.some(cs => cs.careSettingCode === CareSettingEnum.DEVICE_PROVIDER)
&& this.selfDeclarationComposites.some(sd => sd.selfDeclarationQuestion === undefined);
}

public isAdjudication(): boolean {
return this.router.url.includes('adjudication');
}
Expand All @@ -79,9 +87,9 @@ export class EnrolleeSelfDeclarationsComponent implements OnChanges, OnInit {
public ngOnInit(): void {
if (this.selfDeclarationQuestions.size === 0) {

const isDeviceProvider = this.enrolment.careSettings.some(cs => cs.careSettingCode === CareSettingEnum.DEVICE_PROVIDER);
let targetDate = this.enrolment.selfDeclarationCompletedDate ?
this.enrolment.selfDeclarationCompletedDate : this.enrolment.currentStatus.statusDate;
const isDeviceProvider = this.enrolment?.careSettings.some(cs => cs.careSettingCode === CareSettingEnum.DEVICE_PROVIDER);
let targetDate = this.enrolment?.selfDeclarationCompletedDate ?
this.enrolment?.selfDeclarationCompletedDate : this.enrolment.currentStatus.statusDate;
this.enrolmentResource.getSelfDeclarationVersion(moment(targetDate).utc().format(), isDeviceProvider).subscribe(
(versions) => {
versions.forEach(v => {
Expand Down
6 changes: 5 additions & 1 deletion prime-dotnet-webapi/Services/EnrolleeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Prime.Models.Api;
using Prime.Models.VerifiableCredentials;
using Prime.ViewModels;
using System.Security.Cryptography;

namespace Prime.Services
{
Expand Down Expand Up @@ -745,14 +746,17 @@ public async Task<IEnumerable<RemoteAccessSiteViewModel>> GetRemoteAccessSitesAs
/// <param name="enrolleeId"></param>
public async Task<IEnumerable<SelfDeclarationViewModel>> GetSelfDeclarationsAsync(int enrolleeId)
{
var enrolleeCareSetting = await GetCareSettingsAsync(enrolleeId);
var isDeviceProvider = enrolleeCareSetting.EnrolleeCareSettings.Any(cs => cs.CareSettingCode == (int)CareSettingType.DeviceProvider);

var answered = await _context.Set<SelfDeclaration>()
.Where(sd => sd.EnrolleeId == enrolleeId)
.ProjectTo<SelfDeclarationViewModel>(_mapper.ConfigurationProvider)
.ToListAsync();

var answeredCodes = answered.Select(a => a.SelfDeclarationTypeCode);
var unAnswered = await _context.Set<SelfDeclarationType>()
.Where(t => !answeredCodes.Contains(t.Code))
.Where(t => !answeredCodes.Contains(t.Code) && (isDeviceProvider || t.Code != (int)SelfDeclarationTypeCode.RegistrationSuspended_DeviceProvider))
.Select(t => new SelfDeclarationViewModel
{
EnrolleeId = enrolleeId,
Expand Down
Loading