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
6 changes: 5 additions & 1 deletion prime-angular-frontend/src/app/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Configuration {
vendors: VendorConfig[];
healthAuthorities: HAConfig[];
facilities: Config<number>[];
careTypes: Config<number>[];
careTypes: CareTypeConfig[];
securityGroups: Config<number>[];
collegeLicenseGroupings: CollegeLicenseGroupingConfig[];
deviceProviderRoles: DeviceProviderRoleConfig[];
Expand Down Expand Up @@ -78,6 +78,10 @@ export interface VendorConfig extends Config<number> {
careSettingCode: number;
}

export interface CareTypeConfig extends Config<number> {
pharmacyPhoneRequired: boolean;
}

export interface HAConfig extends Config<number> {
passcode: string;
}
Expand Down
7 changes: 4 additions & 3 deletions prime-angular-frontend/src/app/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { catchError, map } from 'rxjs/operators';
import {
Configuration, Config, PracticeConfig, CollegeConfig, ProvinceConfig,
LicenseConfig, VendorConfig, CollegeLicenseGroupingConfig, DeviceProviderRoleConfig,
HAConfig
HAConfig,
CareTypeConfig
} from '@config/config.model';
import { ApiHttpResponse } from '@core/models/api-http-response.model';
import { ApiResource } from '@core/resources/api-resource.service';
Expand Down Expand Up @@ -105,9 +106,9 @@ export class ConfigService implements IConfigService {
.sort(this.utilsService.sortByKey<CollegeLicenseGroupingConfig>('weight'));
}

public get careTypes(): Config<number>[] {
public get careTypes(): CareTypeConfig[] {
return [...this.configuration.careTypes]
.sort(this.utilsService.sortByKey<Config<number>>('name'));
.sort(this.utilsService.sortByKey<CareTypeConfig>('name'));
}

public get securityGroups(): Config<number>[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { ActivatedRoute } from '@angular/router';

import { debounceTime } from 'rxjs/operators';

import { Config } from '@config/config.model';
import { CareTypeConfig, Config } from '@config/config.model';
import { ConfigService } from '@config/config.service';
import { LocalStorageService } from '@core/services/local-storage.service';
import { SiteStatusType } from '@lib/enums/site-status.enum';
import { CareSettingEnum } from '@shared/enums/care-setting.enum';

@Component({
selector: 'app-search-ha-form',
templateUrl: './search-ha-form.component.html',
styleUrls: ['./search-ha-form.component.scss'],
standalone: false
selector: 'app-search-ha-form',
templateUrl: './search-ha-form.component.html',
styleUrls: ['./search-ha-form.component.scss'],
standalone: false
})
export class SearchHAFormComponent implements OnInit {

Expand All @@ -30,7 +30,7 @@ export class SearchHAFormComponent implements OnInit {

public siteStatuses: Config<number>[];
public vendors: Config<number>[];
public careTypes: Config<number>[];
public careTypes: CareTypeConfig[];

private textSearchKey: string = "ha-search-form-textSearch";
private siteStatusCodeKey: string = "ha-search-form-siteStatusCode";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ <h6 class="text-green text-italic">Submitted {{ submission?.submittedDate | form
{{ submission?.mnemonic | default }}
</app-enrollee-property>

<app-enrollee-property *ngIf="submission?.pharmacyPhone"
title="Pharmacy Phone Number">
{{ submission?.pharmacyPhone | default }}
</app-enrollee-property>


<app-enrollee-property *ngIf="submission?.deviceProviderId"
title="Device Provider ID">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UntypedFormBuilder, UntypedFormControl, Validators, UntypedFormGroup }
import { AbstractFormState } from '@lib/classes/abstract-form-state.class';
import { FormUtilsService } from '@core/services/form-utils.service';
import { SiteInformationForm } from './site-information-form.model';
import { FormControlValidators } from '@lib/validators/form-control.validators';

export class SiteInformationFormState extends AbstractFormState<SiteInformationForm> {
private siteId: number;
Expand All @@ -28,6 +29,10 @@ export class SiteInformationFormState extends AbstractFormState<SiteInformationF
return this.formInstance.get('pec') as UntypedFormControl;
}

public get pharmacyPhone(): UntypedFormControl {
return this.formInstance.get('pharmacyPhone') as UntypedFormControl;
}

public get securityGroupCode(): UntypedFormControl {
return this.formInstance.get('securityGroupCode') as UntypedFormControl;
}
Expand Down Expand Up @@ -58,6 +63,7 @@ export class SiteInformationFormState extends AbstractFormState<SiteInformationF
siteName: ['', [Validators.required]],
pec: [null, []],
mnemonic: [null, []],
pharmacyPhone: [null, [FormControlValidators.phone]],
securityGroupCode: [null, [Validators.required]],
physicalAddress: this.formUtilsService.buildAddressForm({
areRequired: ['street', 'city', 'provinceCode', 'countryCode', 'postal'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HealthAuthoritySite } from '@health-auth/shared/models/health-authority-site.model';
import { Address } from '@lib/models/address.model';

export interface SiteInformationForm extends Pick<HealthAuthoritySite, 'siteName' | 'pec' | 'securityGroupCode' | 'mnemonic' | 'physicalAddress'> { }
export interface SiteInformationForm extends Pick<HealthAuthoritySite, 'siteName' | 'pec' | 'pharmacyPhone' | 'securityGroupCode' | 'mnemonic' | 'physicalAddress'> { }
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { HealthAuthSiteRegRoutes } from '@health-auth/health-auth-site-reg.route
import { SiteInformationForm } from './site-information-form.model';

@Component({
selector: 'app-site-information-overview',
template: `
selector: 'app-site-information-overview',
template: `
<app-overview-section title="Site Details"
[showEditRedirect]="showEditRedirect"
[editRoute]="HealthAuthSiteRegRoutes.SITE_INFORMATION"
Expand All @@ -22,6 +22,10 @@ import { SiteInformationForm } from './site-information-form.model';
<app-enrollee-property title="Site Mnemonic">
{{ siteInformation?.mnemonic | default }}
</app-enrollee-property>
<app-enrollee-property *ngIf="siteInformation?.pharmacyPhone"
title="Pharmacy Phone Number">
{{ siteInformation?.pharmacyPhone | default }}
</app-enrollee-property>

<app-address-view title="Site Address"
[address]="siteInformation?.physicalAddress"
Expand All @@ -31,9 +35,9 @@ import { SiteInformationForm } from './site-information-form.model';
</app-address-view>
</app-overview-section>
`,
styles: ['mat-icon { font-size: 1.2em; }'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
styles: ['mat-icon { font-size: 1.2em; }'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
})
export class SiteInformationOverviewComponent extends AbstractOverview {
@Input() public siteInformation: SiteInformationForm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
</div>
</div>

<div class="row"
*ngIf="isPharmacyPhoneRequired()">
<div class="col">
<mat-form-field class="w-100">
<mat-label>Pharmacy Phone Number</mat-label>
<input matInput
[formControl]="formState.pharmacyPhone"
mask="(000) 000-0000">

Check warning on line 42 in prime-angular-frontend/src/app/modules/health-auth-site-reg/pages/site-information-page/site-information-page.component.html

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an "id" attribute to this input field and associate it with a label.

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ7NIjbX0vrcnkxNH3Eu&open=AZ7NIjbX0vrcnkxNH3Eu&pullRequest=2851
<mat-error *ngIf="formState.pharmacyPhone.hasError('phone')">Must be a valid phone number</mat-error>
</mat-form-field>
</div>
</div>

<div class="row">
<div class="col">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { RouteUtils } from '@lib/utils/route-utils.class';
import { Address, AddressLine } from '@lib/models/address.model';
import { Config } from '@config/config.model';
import { CareTypeConfig, Config } from '@config/config.model';
import { ConfigService } from '@config/config.service';
import { FormUtilsService } from '@core/services/form-utils.service';
import { HealthAuthoritySiteResource } from '@core/resources/health-authority-site-resource.service';
Expand All @@ -20,22 +20,25 @@
import { SiteResource } from '@core/resources/site-resource.service';
import { Observable, of } from 'rxjs';
import { asyncValidator } from '@lib/validators/form-async.validators';
import { HealthAuthoritySite } from '@health-auth/shared/models/health-authority-site.model';

@Component({
selector: 'app-site-information-page',
templateUrl: './site-information-page.component.html',
styleUrls: ['./site-information-page.component.scss'],
standalone: false
selector: 'app-site-information-page',
templateUrl: './site-information-page.component.html',
styleUrls: ['./site-information-page.component.scss'],
standalone: false
})
export class SiteInformationPageComponent extends AbstractHealthAuthoritySiteRegistrationPage implements OnInit {
public formState: SiteInformationFormState;
public title: string;
public routeUtils: RouteUtils;
public securityGroups: Config<number>[];
public careTypes: CareTypeConfig[];
public formControlNames: AddressLine[];
public isCompleted: boolean;
public isSubmitted: boolean;
public showAddressFields: boolean;
public site: HealthAuthoritySite;

constructor(
protected dialog: MatDialog,
Expand All @@ -55,6 +58,7 @@
this.routeUtils = new RouteUtils(route, router, HealthAuthSiteRegRoutes.MODULE_PATH);

this.securityGroups = this.configService.securityGroups;
this.careTypes = this.configService.careTypes;
this.formControlNames = [
'street',
'city',
Expand Down Expand Up @@ -90,19 +94,19 @@
throw new Error('No health authority site ID was provided');
}

const site = this.healthAuthoritySiteService.site;
if (Address.isNotEmpty(site.physicalAddress, ['countryCode', 'provinceCode'])) {
this.site = this.healthAuthoritySiteService.site;
if (Address.isNotEmpty(this.site.physicalAddress, ['countryCode', 'provinceCode'])) {
this.showAddressFields = true;
}
this.isCompleted = site?.completed;
this.isSubmitted = site?.submittedDate ? true : false;
this.healthAuthoritySiteFormStateService.setForm(site, !this.hasBeenSubmitted);
this.isCompleted = this.site?.completed;
this.isSubmitted = this.site?.submittedDate ? true : false;

Check warning on line 102 in prime-angular-frontend/src/app/modules/health-auth-site-reg/pages/site-information-page/site-information-page.component.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary use of boolean literals in conditional expression.

See more on https://sonarcloud.io/project/issues?id=bcgov_moh-prime&issues=AZ5Hz0h1IQnTQqJg4SsG&open=AZ5Hz0h1IQnTQqJg4SsG&pullRequest=2851
this.healthAuthoritySiteFormStateService.setForm(this.site, !this.hasBeenSubmitted);
}

public onToggleChange($event: MatSlideToggleChange) {
if (!$event.checked) {
this.formUtilsService.resetAndClearValidators(this.formState.pec);
this.formState.patchValue({ pec: null, siteName: this.formState.siteName.value, securityGroupCode: this.formState.securityGroupCode.value, mnemonic: this.formState.mnemonic.value, physicalAddress: this.formState.physicalAddress.value }, this.route.snapshot.params.sid);
this.formState.patchValue({ pec: null, pharmacyPhone: this.formState.pharmacyPhone.value, siteName: this.formState.siteName.value, securityGroupCode: this.formState.securityGroupCode.value, mnemonic: this.formState.mnemonic.value, physicalAddress: this.formState.physicalAddress.value }, this.route.snapshot.params.sid);
} else {
this.formUtilsService.setValidators(this.formState.pec, [Validators.required]);
}
Expand Down Expand Up @@ -132,4 +136,8 @@
private checkPecIsAssignable(): (value: string) => Observable<boolean> {
return (value: string) => value ? this.siteResource.pecAssignable(this.route.snapshot.params.sid, value) : of(true);
}

public isPharmacyPhoneRequired(): boolean {
return this.careTypes.find(ct => ct.name === this.site?.healthAuthorityCareType.careType)?.pharmacyPhoneRequired;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HealthAuthoritySite } from '@health-auth/shared/models/health-authority
export interface HealthAuthoritySiteUpdate extends Pick<HealthAuthoritySite,
'siteName' |
'pec' |
'pharmacyPhone' |
'mnemonic' |
'securityGroupCode' |
'physicalAddress' |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface HealthAuthoritySiteDto extends BaseHealthAuthoritySite {
siteName: string;
mnemonic: string;
pec: string;
pharmacyPhone: string;
securityGroupCode: number;
physicalAddress: Address;
businessHours: BusinessDay[];
Expand All @@ -35,6 +36,7 @@ export class HealthAuthoritySite extends AbstractBaseHealthAuthoritySite impleme
public siteName: string,
public mnemonic: string,
public pec: string,
public pharmacyPhone: string,
public securityGroupCode: number,
public physicalAddress: Address,
public businessHours: BusinessDay[],
Expand All @@ -52,6 +54,7 @@ export class HealthAuthoritySite extends AbstractBaseHealthAuthoritySite impleme
this.healthAuthorityCareType = healthAuthorityCareType;
this.siteName = siteName;
this.pec = pec;
this.pharmacyPhone = pharmacyPhone;
this.securityGroupCode = securityGroupCode;
this.physicalAddress = physicalAddress;
this.businessHours = businessHours;
Expand All @@ -78,6 +81,7 @@ export class HealthAuthoritySite extends AbstractBaseHealthAuthoritySite impleme
healthAuthoritySite.siteName,
healthAuthoritySite.mnemonic,
healthAuthoritySite.pec,
healthAuthoritySite.pharmacyPhone,
healthAuthoritySite.securityGroupCode,
healthAuthoritySite.physicalAddress,
healthAuthoritySite.businessHours,
Expand Down Expand Up @@ -123,6 +127,7 @@ export class HealthAuthoritySite extends AbstractBaseHealthAuthoritySite impleme
siteName: this.siteName,
pec: this.pec,
mnemonic: this.mnemonic,
pharmacyPhone: this.pharmacyPhone,
securityGroupCode: this.securityGroupCode,
physicalAddress: { ...this.physicalAddress },
businessHours: [...this.businessHours],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface HttpSite {
careSettingCode: number;
pec: string;
mnemonic: string;
pharmacyPhone: string;
doingBusinessAs: string;
submittedDate: string;
status: number;
Expand Down
6 changes: 4 additions & 2 deletions prime-angular-frontend/src/test/mocks/mock-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3024,11 +3024,13 @@ export class MockConfig {
'careTypes': [
{
'code': 1,
'name': 'Ambulatory Care'
'name': 'Ambulatory Care',
'pharmacyPhoneRequired': false,
},
{
'code': 2,
'name': 'Acute Care'
'name': 'Acute Care',
'pharmacyPhoneRequired': true,
}
],
'securityGroups': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MockHealthAuthoritySiteService {
},
siteName: faker.random.words(2),
pec: faker.random.number().toString(),
pharmacyPhone: faker.phone.phoneNumber(),
mnemonic: faker.random.words(5),
securityGroupCode: faker.random.number(),
physicalAddress: address,
Expand Down
Loading
Loading