Skip to content

Commit 5d88d5f

Browse files
committed
OHID-420 Upload additional document to HA
1 parent e8d8577 commit 5d88d5f

13 files changed

Lines changed: 21992 additions & 0 deletions

File tree

prime-angular-frontend/src/app/core/resources/health-authority-resource.service.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,30 @@ export class HealthAuthorityResource {
205205
);
206206
}
207207

208+
public addOrganizationAdditionalDocument(healthAuthorityId: number, documentGuid: string): Observable<BaseDocument> {
209+
const params = this.apiResourceUtilsService.makeHttpParams({ documentGuid });
210+
return this.apiResource.put<BaseDocument>(`health-authorities/${healthAuthorityId}/additional-agreement`, null, params)
211+
.pipe(
212+
map((response: ApiHttpResponse<BaseDocument>) => response.result),
213+
catchError((error: any) => {
214+
this.logger.error('[Core] HealthAuthorityResource::addOrganizationAdditionalDocument error has occurred: ', error);
215+
throw error;
216+
})
217+
);
218+
}
219+
220+
public deleteOrganizationAdditionalDocument(healthAuthorityId: number, documentGuid: string): Observable<BaseDocument> {
221+
const params = this.apiResourceUtilsService.makeHttpParams({ documentGuid });
222+
return this.apiResource.delete<NoContent>(`health-authorities/${healthAuthorityId}/additional-agreement`, null, params)
223+
.pipe(
224+
NoContentResponse,
225+
catchError((error: any) => {
226+
this.logger.error('[Core] HealthAuthorityResource::deleteOrganizationAdditionalDocument error has occurred: ', error);
227+
throw error;
228+
})
229+
);
230+
}
231+
208232
public getOrganizationAgreementDocumentToken(healthAuthorityId: number): Observable<string> {
209233
return this.apiResource.get<string>(`health-authorities/${healthAuthorityId}/organization-agreement/token`)
210234
.pipe(

prime-angular-frontend/src/app/modules/adjudication/pages/health-authorities/health-auth-org-info-page/health-auth-org-info-page.component.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,52 @@
208208
</div>
209209

210210
</ng-container>
211+
212+
<button *ngIf="!hasClickedAddDocument"
213+
mat-button
214+
type="button"
215+
color="primary"
216+
(click)="addOrgAgreement()">
217+
<mat-icon>add</mat-icon>
218+
Add organization document
219+
</button>
220+
221+
<ng-container *ngIf="hasClickedAddDocument">
222+
<div class="row">
223+
<div class="col">
224+
<app-document-upload #documentUpload
225+
componentName="organization-agreement"
226+
labelMessage="Drag and drop your organization agreement or browse"
227+
[multiple]="false"
228+
(completed)="onUpload($event)"
229+
(remove)="onRemoveDocument($event)"></app-document-upload>
230+
</div>
231+
</div>
232+
233+
<div class="row justify-content-between">
234+
<div class="col">
235+
<button mat-flat-button
236+
class="align-self-start"
237+
type="button"
238+
color="secondary"
239+
(click)="cancelUpload()">
240+
Cancel
241+
</button>
242+
</div>
243+
<div class="col text-right">
244+
<button mat-flat-button
245+
class="align-self-end"
246+
type="button"
247+
color="primary"
248+
[disabled]="!organizationAgreementDocument"
249+
(click)="updateOrganizationAgreement()">
250+
Upload Document
251+
</button>
252+
</div>
253+
</div>
254+
255+
</ng-container>
256+
211257
</app-page-section>
212258
</div>
213259
</div>

prime-angular-frontend/src/app/modules/adjudication/pages/health-authorities/health-auth-org-info-page/health-auth-org-info-page.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class HealthAuthOrgInfoPageComponent implements OnInit {
2727
*/
2828
public isInitial: boolean;
2929
public hasClickedAddAgreement: boolean;
30+
public hasClickedAddDocument: boolean;
3031

3132
public organizationAgreementDocument: BaseDocument;
3233

@@ -40,6 +41,7 @@ export class HealthAuthOrgInfoPageComponent implements OnInit {
4041
) {
4142
this.routeUtils = new RouteUtils(route, router, AdjudicationRoutes.routePath(AdjudicationRoutes.SITE_REGISTRATIONS));
4243
this.hasClickedAddAgreement = false;
44+
this.hasClickedAddDocument = false;
4345
}
4446

4547
public onRoute(routePath: string | (string | number)[]): void {

prime-angular-frontend/src/app/shared/components/document-upload/document-upload/document-upload.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export class BaseDocument {
2626
}
2727
}
2828

29+
export class HAAdditionalDocument extends BaseDocument {
30+
note: string;
31+
}
32+
2933
@Component({
3034
selector: 'app-document-upload',
3135
templateUrl: './document-upload.component.html',

prime-dotnet-webapi/ApiDbContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ IHttpContextAccessor context
111111
// Health Authorities
112112
public DbSet<HealthAuthoritySite> HealthAuthoritySites { get; set; }
113113
public DbSet<HealthAuthorityOrganization> HealthAuthorities { get; set; }
114+
public DbSet<HealthAuthorityOrganizationAdditionalDocument> HealthAuthorityOrganizationAdditionalDocuments { get; set; }
114115
public DbSet<HealthAuthorityCareType> HealthAuthorityCareTypes { get; set; }
115116
public DbSet<HealthAuthorityContact> HealthAuthorityContacts { get; set; }
116117
public DbSet<HealthAuthorityVendor> HealthAuthorityVendors { get; set; }

prime-dotnet-webapi/Controllers/HealthAuthoritiesController.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using Prime.Models;
1717
using Prime.Models.Api;
18+
using Microsoft.AspNetCore.Http.HttpResults;
1819

1920
namespace Prime.Controllers
2021
{
@@ -375,6 +376,58 @@ public async Task<ActionResult> CreateOrUpdateOgranizationAgreement(int healthAu
375376
return Ok(document); ;
376377
}
377378

379+
// PUT: api/health-authorities/1/additional-document
380+
/// <summary>
381+
/// Create or Update health auth organization agreement
382+
/// </summary>
383+
/// <param name="healthAuthorityId"></param>
384+
/// <param name="documentGuid"></param>
385+
[HttpPut("{healthAuthorityId}/additional-document", Name = nameof(CreateAdditionalDocument))]
386+
[Authorize(Roles = Roles.PrimeMaintenance)]
387+
[ProducesResponseType(typeof(ApiMessageResponse), StatusCodes.Status400BadRequest)]
388+
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
389+
[ProducesResponseType(StatusCodes.Status403Forbidden)]
390+
[ProducesResponseType(typeof(ApiMessageResponse), StatusCodes.Status404NotFound)]
391+
[ProducesResponseType(typeof(ApiResultResponse<HealthAuthorityOrganizationAgreementDocument>), StatusCodes.Status200OK)]
392+
public async Task<ActionResult> CreateAdditionalDocument(int healthAuthorityId, [FromQuery] Guid documentGuid)
393+
{
394+
if (!await _healthAuthorityService.HealthAuthorityExistsAsync(healthAuthorityId))
395+
{
396+
return NotFound($"Health Authority not found with id {healthAuthorityId}");
397+
}
398+
399+
var document = await _healthAuthorityService.CreateAdditionalDocumentAsync(healthAuthorityId, documentGuid);
400+
if (document == null)
401+
{
402+
return BadRequest("Additional Document could not be created; network error or upload is already submitted");
403+
}
404+
405+
return Ok(document);
406+
}
407+
408+
// DELETE: api/health-authorities/1/additional-document
409+
/// <summary>
410+
/// Create or Update health auth organization agreement
411+
/// </summary>
412+
/// <param name="healthAuthorityId"></param>
413+
/// <param name="documentGuid"></param>
414+
[HttpDelete("{healthAuthorityId}/additional-document", Name = nameof(DeleteAdditionalDocument))]
415+
[Authorize(Roles = Roles.PrimeMaintenance)]
416+
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
417+
[ProducesResponseType(StatusCodes.Status403Forbidden)]
418+
[ProducesResponseType(StatusCodes.Status204NoContent)]
419+
public async Task<ActionResult> DeleteAdditionalDocument(int healthAuthorityId, [FromQuery] Guid documentGuid)
420+
{
421+
if (!await _healthAuthorityService.HealthAuthorityExistsAsync(healthAuthorityId))
422+
{
423+
return NotFound($"Health Authority not found with id {healthAuthorityId}");
424+
}
425+
426+
await _healthAuthorityService.DeleteAdditionalDocumentAsync(healthAuthorityId, documentGuid);
427+
428+
return NoContent();
429+
}
430+
378431
// GET: api/health-authorities/1/organization-agreement/token
379432
/// <summary>
380433
/// Gets a download token for the latest organization agreement for a health authority.

0 commit comments

Comments
 (0)