Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
neophyte57 committed Jul 17, 2024
2 parents 8ebce60 + 9b5ee45 commit a0c029d
Show file tree
Hide file tree
Showing 24 changed files with 18,649 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<td mat-cell
class="pl-2"
*matCellDef="let row;">
{{ row.collegeLicenseGroupingCode ?
(row.collegeLicenseGroupingCode | configCode: 'collegeLicenseGroupings' | default) + ' - '
: ''}}
{{ row.licenseCode | configCode: 'licenses' | default }}
{{ row.discontinued ? " - *Discontinued*" : ""}}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class LicenseMaintenanceConfig implements IWeightedConfig {
validate?: boolean;
prescriberIdType?: PrescriberIdTypeEnum;
weight: number;
collegeLicenseGroupingCode: number;
}

@Component({
Expand Down Expand Up @@ -69,9 +70,10 @@ export class LicenseClassesMaintenancePageComponent implements OnInit {
collegeName: college.name,
licenseCode: collegeLicense.licenseCode,
discontinued: collegeLicense.discontinued,
collegeLicenseGroupingCode: collegeLicense.collegeLicenseGroupingCode,
...license
} as LicenseMaintenanceConfig;
}).sort(this.utilsService.sortByKey<LicenseMaintenanceConfig>('weight'))
})
: { collegeName: college.name } as LicenseMaintenanceConfig;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export class SiteRegistrationContainerComponent extends AbstractSiteAdminPage im
status,
businessLicence,
flagged,
isNew
isNew,
missingBusinessLicence
} = site;

return {
Expand All @@ -244,7 +245,8 @@ export class SiteRegistrationContainerComponent extends AbstractSiteAdminPage im
status,
businessLicence,
flagged,
isNew
isNew,
missingBusinessLicence
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
*matHeaderCellDef
scope="col"> Missing Business Licence </th>
<td mat-cell
*matCellDef="let row;"> {{ ((row.careSettingCode === CareSettingEnum.COMMUNITY_PHARMACIST)
? row.missingBusinessLicence : null) | yesNo | default: 'N/A' }} </td>
*matCellDef="let row;"> {{ displayMissingBusinessLicence(row) }} </td>
</ng-container>

<ng-container matColumnDef="actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ export class SiteRegistrationTableComponent implements OnInit, AfterViewInit {
}
}

public displayMissingBusinessLicence(row: SiteRegistrationListViewModel): string {
if (row.careSettingCode === CareSettingEnum.COMMUNITY_PHARMACIST) {
if (row.missingBusinessLicence === undefined) {
row.missingBusinessLicence = row.businessLicence === null ||
row.businessLicence.businessLicenceDocument === null
}
if (row.missingBusinessLicence) {
return "Yes"
} else {
return "No"
}
} else {
return "N/A";
}
}

public remoteUsers(siteRegistration: SiteRegistrationListViewModel): number | 'Yes' | 'No' | 'N/A' {
const count = siteRegistration.remoteUserCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,60 @@
</app-summary-card>

<hr class="divider">

<div class="add-site">
<button mat-button
type="button"
color="primary"
(click)="addSite()">
<mat-icon>add_business</mat-icon>
Add Site
</button>
<div class="row">
<div class="col-8">

<form [formGroup]="form"
novalidate>
<mat-form-field class="filter">
<mat-label>Vendor</mat-label>
<mat-select formControlName="vendorCode">
<mat-option value="all">All</mat-option>
<mat-option *ngFor="let vendor of vendors"
[value]="vendor.code">
{{ vendor.name }}
</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field class="filter">
<mat-label>Care Type</mat-label>
<mat-select formControlName="careTypeCode">
<mat-option value="all">All</mat-option>
<mat-option *ngFor="let careType of careTypes"
[value]="careType">
{{ careType }}
</mat-option>
</mat-select>
</mat-form-field>
</form>
</div>
<div class="col-4">
<div class="add-site">
<button mat-button
type="button"
color="primary"
(click)="addSite()">
<mat-icon>add_business</mat-icon>
Add Site
</button>
</div>
</div>
</div>

</ng-container>

<ng-container *ngFor="let healthAuthoritySite of healthAuthoritySites$ | async; trackBy: trackBySiteId">
<ng-container *ngFor="let healthAuthoritySite of healthAuthoritySites ; trackBy: trackBySiteId">

<app-summary-card icon="store"
title="Site Information"
[menu]="healthAuthoritySiteMenu"
[menuOutletContext]="{ healthAuthoritySite: healthAuthoritySite, healthAuthorityId: healthAuthorityId }"
[properties]="[
{ key: 'Site Name', value: healthAuthoritySite?.siteName },
{ key: 'Site ID', value: healthAuthoritySite?.pec },
{ key: 'Vendor', value: healthAuthoritySite?.healthAuthorityVendor?.vendorCode | configCode : 'vendors' },
{ key: 'Site Name', value: healthAuthoritySite?.siteName, _50: true },
{ key: 'Site ID', value: healthAuthoritySite?.pec, _50: true },
{ key: 'Care Type', value: healthAuthoritySite?.healthAuthorityCareType?.careType, _50: true },
{ key: 'Vendor', value: healthAuthoritySite?.healthAuthorityVendor?.vendorCode | configCode : 'vendors', _50: true },
{ key: healthAuthoritySite?.submittedDate ? 'Last Submitted by' : 'Last Updated by', value: getLastUpdatedUser(healthAuthoritySite?.authorizedUserName, healthAuthoritySite?.updatedTimeStamp)},
]">
<ng-container *ngIf="healthAuthoritySite.isIncomplete()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ div.add-site {
margin-left: -1rem;
padding-top: .2rem;
}

.mat-card-content {
div {
color: theme-palette(blue, light);
Expand All @@ -48,6 +49,7 @@ div.add-site {
}
}
}

.mat-card-actions {
text-align: right;
}
Expand All @@ -64,3 +66,7 @@ div.add-site {
.green-icon {
color: theme-palette(green);
}

.filter {
margin-right: 10px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { CapitalizePipe } from '@shared/pipes/capitalize.pipe';
import { AuthorizedUserService } from '@health-auth/shared/services/authorized-user.service';
import { SiteManagementPageComponent } from './site-management-page.component';
import { AuthService } from '@auth/shared/services/auth.service';
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('SiteManagementPageComponent', () => {
let component: SiteManagementPageComponent;
Expand All @@ -23,9 +25,11 @@ describe('SiteManagementPageComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
ReactiveFormsModule,
HttpClientTestingModule,
RouterTestingModule,
NgxMaterialModule
NgxMaterialModule,
BrowserAnimationsModule
],
declarations: [
SiteManagementPageComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

import { Observable, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';

import { ArrayUtils } from '@lib/utils/array-utils.class';
import { RouteUtils } from '@lib/utils/route-utils.class';
Expand All @@ -16,6 +16,10 @@ import { HealthAuthoritySite } from '@health-auth/shared/models/health-authority
import { HealthAuthoritySiteList } from '@health-auth/shared/models/health-authority-site-list.model';
import { AuthorizedUserService } from '@health-auth/shared/services/authorized-user.service';
import { FormatDatePipe } from '@shared/pipes/format-date.pipe';
import { Config } from '@config/config.model';
import { ConfigService } from '@config/config.service';
import { CareSettingEnum } from '@shared/enums/care-setting.enum';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';

@Component({
selector: 'app-site-management-page',
Expand All @@ -27,20 +31,38 @@ export class SiteManagementPageComponent implements OnInit {
public busy: Subscription;
public title: string;
public healthAuthorityId: number;
public healthAuthoritySites$: Observable<HealthAuthoritySiteList[] | null>;
public healthAuthoritySites: HealthAuthoritySiteList[];
public routeUtils: RouteUtils;
public HealthAuthorityEnum = HealthAuthorityEnum;
public SiteStatusType = SiteStatusType;
public vendors: Config<number>[];
public careTypes: string[];
public form: FormGroup;

constructor(
private route: ActivatedRoute,
private fb: FormBuilder,
private router: Router,
private authorizedUserService: AuthorizedUserService,
private authorizedUserResource: AuthorizedUserResource,
private formatDatePipe: FormatDatePipe
private formatDatePipe: FormatDatePipe,
private configService: ConfigService,
) {
this.title = this.route.snapshot.data.title;
this.routeUtils = new RouteUtils(route, router, HealthAuthSiteRegRoutes.MODULE_PATH);

this.careTypes = ["All"];
this.vendors = this.configService.vendors
.filter(v => v.careSettingCode === CareSettingEnum.HEALTH_AUTHORITY)
.sort((a, b) => a.name.localeCompare(b.name));
}

public get vendorCode(): FormControl {
return this.form.get('vendorCode') as FormControl;
}

public get careTypeCode(): FormControl {
return this.form.get('careTypeCode') as FormControl;
}

public viewAuthorizedUser(healthAuthorityId: number): void {
Expand Down Expand Up @@ -82,11 +104,62 @@ export class SiteManagementPageComponent implements OnInit {
}

public ngOnInit(): void {
this.createFormInstance();
this.initForm();
const authorizedUser = this.authorizedUserService.authorizedUser;
this.healthAuthorityId = authorizedUser.healthAuthorityCode;
this.healthAuthoritySites$ = this.authorizedUserResource.getAuthorizedUserSites(authorizedUser.id);
this.authorizedUserResource.getAuthorizedUserSites(authorizedUser.id)
.subscribe((sites: HealthAuthoritySiteList[]) => {
this.healthAuthoritySites = sites.sort((a, b) => a.siteName && b.siteName ? a.siteName.toLocaleLowerCase().localeCompare(b.siteName.toLocaleLowerCase()) : 0)

const haVendors = this.healthAuthoritySites.map((s) => {
return s.healthAuthorityVendor.vendorCode;
});

const haCareTypes = this.healthAuthoritySites.map((s) => {
return s.healthAuthorityCareType.careType;
});

this.careTypes = [... new Set(haCareTypes)].sort((a, b) => a.localeCompare(b));
this.vendors = this.vendors.filter((v) => haVendors.some((hav) => hav === v.code)).sort((a, b) => a.name.localeCompare(b.name));
});
}

private createFormInstance() {
this.form = this.fb.group({
vendorCode: ['all', []],
careTypeCode: ['all', []],
});
}

private initForm() {
this.vendorCode.valueChanges.subscribe(() => {
this.filterSites();
});
this.careTypeCode.valueChanges.subscribe(() => {
this.filterSites();
})
}

public filterSites() {
const authorizedUser = this.authorizedUserService.authorizedUser;
this.authorizedUserResource.getAuthorizedUserSites(authorizedUser.id)
.subscribe((sites: HealthAuthoritySiteList[]) => {
this.healthAuthoritySites = sites.sort((a, b) => a.siteName && b.siteName ? a.siteName.toLocaleLowerCase().localeCompare(b.siteName.toLocaleLowerCase()) : 0);
if (this.careTypeCode.value !== "all") {
this.healthAuthoritySites = this.healthAuthoritySites.filter((s) => {
return s.healthAuthorityCareType.careType === this.careTypeCode.value;
})
}
if (this.vendorCode.value !== "all") {
this.healthAuthoritySites = this.healthAuthoritySites.filter((s) => {
return s.healthAuthorityVendor.vendorCode === this.vendorCode.value;
})
}
});
}


private redirectTo(healthAuthorityId: number, healthAuthoritySiteId: number, pagePath: string): void {
this.routeUtils.routeRelativeTo([
HealthAuthSiteRegRoutes.HEALTH_AUTHORITIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { SiteStatusType } from '@lib/enums/site-status.enum';

import { AbstractBaseHealthAuthoritySite } from '@health-auth/shared/models/abstract-base-health-authority-site.class';
import { BaseHealthAuthoritySite } from '@health-auth/shared/models/base-health-authority-site.model';
import { HealthAuthorityCareType } from './health-authority-care-type.model';

export interface HealthAuthoritySiteListDto extends BaseHealthAuthoritySite {
healthAuthorityVendor: HealthAuthorityVendor;
healthAuthorityCareType: HealthAuthorityCareType;
siteName: string;
pec: string;
updatedTimeStamp: string;
Expand All @@ -18,6 +20,7 @@ export class HealthAuthoritySiteList extends AbstractBaseHealthAuthoritySite imp
public id: number,
public healthAuthorityOrganizationId: HealthAuthorityEnum,
public healthAuthorityVendor: HealthAuthorityVendor,
public healthAuthorityCareType: HealthAuthorityCareType,
public siteName,
public pec: string,
public readonly completed: boolean,
Expand All @@ -30,6 +33,7 @@ export class HealthAuthoritySiteList extends AbstractBaseHealthAuthoritySite imp
super(id, healthAuthorityOrganizationId, completed, submittedDate, approvedDate, status);

this.healthAuthorityVendor = healthAuthorityVendor;
this.healthAuthorityCareType = healthAuthorityCareType;
this.siteName = siteName;
this.pec = pec;
this.updatedTimeStamp = updatedTimeStamp;
Expand All @@ -51,6 +55,7 @@ export class HealthAuthoritySiteList extends AbstractBaseHealthAuthoritySite imp
healthAuthoritySiteListDto.id,
healthAuthoritySiteListDto.healthAuthorityOrganizationId,
healthAuthoritySiteListDto.healthAuthorityVendor,
healthAuthoritySiteListDto.healthAuthorityCareType,
healthAuthoritySiteListDto.siteName,
healthAuthoritySiteListDto.pec,
healthAuthoritySiteListDto.completed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class Site {
activeBeforeRegistration: boolean;
isNew: boolean;
deviceProviderId: string;
missingBusinessLicence: boolean;

public static getExpiryDate(site: Site | SiteListViewModel): string | null {
if (!site) {
Expand All @@ -67,7 +68,7 @@ export class Site {
}
}

export interface SiteListViewModel extends Pick<Site, 'id' | 'physicalAddress' | 'doingBusinessAs' | 'submittedDate' | 'careSettingCode' | 'siteVendors' | 'completed' | 'pec' | 'mnemonic' | 'status' | 'businessLicence' | 'flagged' | 'approvedDate' | 'isNew'> {
export interface SiteListViewModel extends Pick<Site, 'id' | 'physicalAddress' | 'doingBusinessAs' | 'submittedDate' | 'careSettingCode' | 'siteVendors' | 'completed' | 'pec' | 'mnemonic' | 'status' | 'businessLicence' | 'flagged' | 'approvedDate' | 'isNew' | 'missingBusinessLicence'> {
adjudicatorIdir: string;
remoteUserCount: number;
flagged: boolean;
Expand Down
Loading

0 comments on commit a0c029d

Please sign in to comment.