-
Notifications
You must be signed in to change notification settings - Fork 11
PRIME-2735 Admin can edit HA Care Type Vendor mapping #2518
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
Open
bergomi02
wants to merge
15
commits into
develop
Choose a base branch
from
feature/prime-2735_ha_care_type_vendor_page
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18,804
−2
Open
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cf894f6
Initial commit
bergomi02 a9a59aa
attempt to fix code scan issue
bergomi02 8d88790
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 4a87e6b
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 8f0724b
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 7ca833c
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 a56b644
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 6c5cf1f
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 0ada333
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 3dbffe6
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 045be97
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 94a18cb
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
neophyte57 69ee020
bug fix
bergomi02 dc5d607
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 433798e
Merge branch 'develop' into feature/prime-2735_ha_care_type_vendor_page
bergomi02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
prime-angular-frontend/src/app/lib/models/ha-care-type-vendor.model.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export interface HaCareTypeVendor { | ||
| careType: string; | ||
| vendorCode: number; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ation/pages/health-authorities/care-type-vendor-page/care-type-vendor-page.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <app-page [busy]="busy"> | ||
| <app-page-header>PharmaNet Health Authority Information</app-page-header> | ||
| <app-progress-indicator [noContent]="true"></app-progress-indicator> | ||
|
|
||
| <form (ngSubmit)="onSubmit()" | ||
| [formGroup]="form" | ||
| novalidate> | ||
|
|
||
| <app-page-section> | ||
| <app-page-subheader> | ||
| <ng-container appPageSubheaderTitle>{{ title }}</ng-container> | ||
| <ng-container appPageSubheaderSummary> | ||
| Identify the Care Type Vendor associated with this Health Authority. | ||
| </ng-container> | ||
| </app-page-subheader> | ||
|
|
||
| <div class="row"> | ||
| <div class="col col-sm-10 py-3"> | ||
|
|
||
| <ng-container *ngFor="let careTypeVendor of careTypeVendors.controls; let careTypeIndex = index;"> | ||
|
|
||
| <div class="mb-3" | ||
| [ngClass]="{'mt-3':careTypeIndex > 0}"> | ||
| <strong>Care Type: </strong><span>{{careTypeVendor.get('careType').value}}</span> | ||
| </div> | ||
| <div class="text-danger mb-2" | ||
| *ngIf="hasDuplicate(careTypeIndex)"> | ||
| Duplicate vendors detected. Please remove duplicate vendor. | ||
| </div> | ||
| <ng-container *ngIf="careTypeVendor.get('vendorCodes').controls"> | ||
| <ng-container | ||
| *ngFor="let careTypeVendorCode of careTypeVendor.get('vendorCodes').controls; let vendorIndex = index;"> | ||
| <ng-container [formGroup]="careTypeVendorCode"> | ||
| <app-form-icon-group [show]="careTypeVendor.get('vendorCodes').length > 1" | ||
| (event)="removeVendor(careTypeIndex, vendorIndex)"> | ||
| <mat-form-field class="w-100"> | ||
| <mat-label>Vendor</mat-label> | ||
| <mat-select formControlName="vendorCode"> | ||
| <mat-option *ngFor="let vendor of availableVendors" | ||
| [value]="vendor.code"> | ||
| {{ vendor.name }} | ||
| </mat-option> | ||
| </mat-select> | ||
| <mat-error *ngIf="isRequired(careTypeIndex, vendorIndex)"> | ||
| Required | ||
| </mat-error> | ||
| </mat-form-field> | ||
| </app-form-icon-group> | ||
| </ng-container> | ||
| </ng-container> | ||
| <button mat-button | ||
| *ngIf="careTypeVendor.get('vendorCodes').length < availableVendors.length" | ||
| type="button" | ||
| color="primary" | ||
| (click)="addVendor(careTypeIndex)"> | ||
| <mat-icon>add</mat-icon> | ||
| Add Vendor | ||
| </button> | ||
| </ng-container> | ||
|
|
||
| </ng-container> | ||
| </div> | ||
| </div> | ||
| </app-page-section> | ||
| </form> | ||
|
|
||
| <app-page-footer [hasSecondaryAction]="true" | ||
| primaryActionLabel="Save and Continue" | ||
| (save)="onSubmit()" | ||
| (back)="onBack()"></app-page-footer> | ||
| </app-page> | ||
Empty file.
55 changes: 55 additions & 0 deletions
55
...on/pages/health-authorities/care-type-vendor-page/care-type-vendor-page.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
| import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
| import { RouterTestingModule } from '@angular/router/testing'; | ||
| import { ReactiveFormsModule } from '@angular/forms'; | ||
| import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
| import { MatSnackBarModule } from '@angular/material/snack-bar'; | ||
|
|
||
| import { MockConfigService } from 'test/mocks/mock-config.service'; | ||
|
|
||
| import { APP_CONFIG, APP_DI_CONFIG } from 'app/app-config.module'; | ||
| import { ConfigService } from '@config/config.service'; | ||
| import { CapitalizePipe } from '@shared/pipes/capitalize.pipe'; | ||
| import { CareTypeVendorPageComponent } from './care-type-vendor-page.component'; | ||
|
|
||
| describe('CareTypeVendorPageComponent', () => { | ||
| let component: CareTypeVendorPageComponent; | ||
| let fixture: ComponentFixture<CareTypeVendorPageComponent>; | ||
|
|
||
| beforeEach(waitForAsync(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [ | ||
| RouterTestingModule, | ||
| HttpClientTestingModule, | ||
| ReactiveFormsModule, | ||
| MatSnackBarModule | ||
| ], | ||
| declarations: [ | ||
| CareTypeVendorPageComponent | ||
| ], | ||
| providers: [ | ||
| { | ||
| provide: APP_CONFIG, | ||
| useValue: APP_DI_CONFIG | ||
| }, | ||
| { | ||
| provide: ConfigService, | ||
| useClass: MockConfigService | ||
| }, | ||
| CapitalizePipe | ||
| ], | ||
| schemas: [CUSTOM_ELEMENTS_SCHEMA] | ||
| }) | ||
| .compileComponents(); | ||
| })); | ||
|
|
||
| beforeEach(() => { | ||
| fixture = TestBed.createComponent(CareTypeVendorPageComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
156 changes: 156 additions & 0 deletions
156
...ication/pages/health-authorities/care-type-vendor-page/care-type-vendor-page.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
|
|
||
| import { AdjudicationRoutes } from '@adjudication/adjudication.routes'; | ||
| import { Component, OnInit } from '@angular/core'; | ||
| import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; | ||
| import { ActivatedRoute, Router } from '@angular/router'; | ||
| import { VendorConfig } from '@config/config.model'; | ||
| import { ConfigService } from '@config/config.service'; | ||
| import { HealthAuthorityResource } from '@core/resources/health-authority-resource.service'; | ||
| import { FormUtilsService } from '@core/services/form-utils.service'; | ||
| import { ToastService } from '@core/services/toast.service'; | ||
| import { HaCareTypeVendor } from '@lib/models/ha-care-type-vendor.model'; | ||
| import { RouteUtils } from '@lib/utils/route-utils.class'; | ||
| import { FormArrayValidators } from '@lib/validators/form-array.validators'; | ||
| import { HealthAuthority } from '@shared/models/health-authority.model'; | ||
| import { Subscription } from 'rxjs/internal/Subscription'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-care-type-vendor-page', | ||
| templateUrl: './care-type-vendor-page.component.html', | ||
| styleUrls: ['./care-type-vendor-page.component.scss'] | ||
| }) | ||
| export class CareTypeVendorPageComponent implements OnInit { | ||
| public busy: Subscription; | ||
| public title: string; | ||
| public form: FormGroup; | ||
| public isInitialEntry: boolean; | ||
| public availableVendors: VendorConfig[]; | ||
| public healthAuthority: HealthAuthority; | ||
|
|
||
| private routeUtils: RouteUtils; | ||
|
|
||
| constructor( | ||
| private fb: FormBuilder, | ||
| private healthAuthResource: HealthAuthorityResource, | ||
| private formUtilsService: FormUtilsService, | ||
| private configService: ConfigService, | ||
| private route: ActivatedRoute, | ||
| private toastService: ToastService, | ||
| router: Router | ||
| ) { | ||
| this.title = route.snapshot.data.title; | ||
| this.isInitialEntry = !!this.route.snapshot.queryParams.initial; | ||
| this.routeUtils = new RouteUtils(route, router, [ | ||
| AdjudicationRoutes.routePath(AdjudicationRoutes.SITE_REGISTRATIONS), | ||
| AdjudicationRoutes.SITE_REGISTRATIONS, | ||
| AdjudicationRoutes.HEALTH_AUTHORITIES, | ||
| this.route.snapshot.params.haid | ||
| ]); | ||
| } | ||
|
|
||
| public get careTypeVendors(): FormArray { | ||
| return this.form.get('careTypeVendors') as FormArray; | ||
| } | ||
|
|
||
| public onSubmit() { | ||
| if (this.formUtilsService.checkValidity(this.form) || this.form.disabled) { | ||
|
|
||
| let haCareTypeVendors: HaCareTypeVendor[]; | ||
|
|
||
| this.careTypeVendors.controls.forEach((c: FormControl) => { | ||
| let vendorCodeArray = c.get("vendorCodes") as FormArray; | ||
| let vendorCodes = vendorCodeArray.controls.map((v) => { | ||
| let haCareTypeVendor: HaCareTypeVendor = { | ||
| careType: c.get("careType").value, | ||
| vendorCode: v.get("vendorCode").value | ||
| } | ||
| return haCareTypeVendor; | ||
| }); | ||
| if (!haCareTypeVendors) { | ||
| haCareTypeVendors = vendorCodes; | ||
| } else { | ||
| haCareTypeVendors = haCareTypeVendors.concat(vendorCodes); | ||
| } | ||
| }); | ||
| this.busy = this.healthAuthResource.updateHealthAuthorityCareTypeVendor(this.route.snapshot.params.haid, haCareTypeVendors) | ||
| .subscribe(() => this.nextRouteAfterSubmit()); | ||
| } | ||
| } | ||
|
|
||
| public ngOnInit(): void { | ||
| this.createFormInstance(); | ||
| this.initForm(); | ||
| } | ||
|
|
||
| private createFormInstance() { | ||
| this.form = this.fb.group({ | ||
| careTypeVendors: this.fb.array([]) | ||
| }); | ||
| } | ||
|
|
||
| private createCareTypeFormControl() { | ||
| return this.fb.group({ | ||
| careType: [], | ||
| vendorCodes: this.fb.array([]), | ||
| }); | ||
| } | ||
|
|
||
| private initForm() { | ||
| this.busy = this.healthAuthResource.getHealthAuthorityById(this.route.snapshot.params.haid) | ||
| .subscribe((healthAuthority) => { | ||
| this.healthAuthority = healthAuthority; | ||
| this.availableVendors = this.configService.vendors.filter(v => healthAuthority.vendors.some(hav => hav.vendorCode === v.code)); | ||
|
|
||
| if (healthAuthority.careTypes?.length) { | ||
| healthAuthority.careTypes.forEach((careType) => { | ||
| let careTypeVendor = this.createCareTypeFormControl(); | ||
| careTypeVendor.get('careType').patchValue(careType.careType); | ||
| careType.vendors.forEach((vendor) => { | ||
| let vendorArray = careTypeVendor.get('vendorCodes') as FormArray; | ||
| vendorArray.addValidators(FormArrayValidators.noDuplicateValue('vendorCode')); | ||
| vendorArray.push(this.fb.group({ vendorCode: [vendor.vendorCode, [Validators.required]] })); | ||
| }); | ||
| this.careTypeVendors.push(careTypeVendor); | ||
| }) | ||
| } | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| public addVendor(caretypeIndex: number) { | ||
| var vendorArray = this.careTypeVendors.controls[caretypeIndex].get('vendorCodes') as FormArray; | ||
| vendorArray.push(this.fb.group({ vendorCode: [null, [Validators.required]] })); | ||
| } | ||
|
|
||
| public removeVendor(caretypeIndex: number, vendorIndex: number) { | ||
| var vendorArray = this.careTypeVendors.controls[caretypeIndex].get('vendorCodes') as FormArray; | ||
| vendorArray.removeAt(vendorIndex); | ||
| } | ||
|
|
||
| public onBack() { | ||
| this.routeTo(); | ||
| } | ||
|
|
||
| private nextRouteAfterSubmit() { | ||
| this.routeTo(AdjudicationRoutes.HEALTH_AUTH_CARE_TYPE_VENDOR); | ||
| } | ||
|
|
||
| private routeTo(routeSegment?: string) { | ||
| const routePath = (this.isInitialEntry && routeSegment) | ||
| ? routeSegment | ||
| : AdjudicationRoutes.ORGANIZATION_INFORMATION; | ||
| this.routeUtils.routeRelativeTo(routePath, { queryParamsHandling: 'preserve' }); | ||
| } | ||
|
|
||
| public isRequired(careTypeIndex: number, vendorIndex: number) { | ||
| var careTypeControl = this.careTypeVendors.controls[careTypeIndex]; | ||
| var vendorCodes = careTypeControl.get("vendorCodes") as FormArray; | ||
| return vendorCodes.controls[vendorIndex].get("vendorCode").hasError('required'); | ||
| } | ||
|
|
||
| public hasDuplicate(careTypeIndex: number) { | ||
| var careTypeControl = this.careTypeVendors.controls[careTypeIndex]; | ||
| var vendorCodes = careTypeControl.get("vendorCodes") as FormArray; | ||
| return vendorCodes.hasError('duplicate'); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest changing to "Identify the Vendor(s) associated with each Care Type."