diff --git a/angular/src/app/patients/patient-record/patient-record.component.ts b/angular/src/app/patients/patient-record/patient-record.component.ts
index 49358ae..b3ee512 100644
--- a/angular/src/app/patients/patient-record/patient-record.component.ts
+++ b/angular/src/app/patients/patient-record/patient-record.component.ts
@@ -8,6 +8,7 @@ import { PermissionService } from '@abp/ng.core';
import { ActivatedRoute, Router } from '@angular/router';
import { environment } from 'src/environments/environment';
import { Confirmation, ConfirmationService, ToasterService } from '@abp/ng.theme.shared';
+import { HttpClient, HttpEventType, HttpParams, HttpRequest } from '@angular/common/http';
@Component({
selector: 'app-patient-record',
@@ -40,18 +41,7 @@ export class PatientRecordComponent implements OnInit {
medicationHistoryUrlpath: string;
medicationUrlpath: string;
guid: string = '00000000-0000-0000-0000-000000000000';
- options: Partial
= {
- hideCancelBtn: false,
- hideYesBtn: false,
- dismissible: false,
- cancelText: 'Close',
- yesText: 'Confirm',
- messageLocalizationParams: ['Demo'],
- titleLocalizationParams: [],
- // You can customize icon
- // icon: 'fa fa-exclamation-triangle', // or
- // iconTemplate : '
'
- };
+ uploadProgress = 0;
constructor(
private patientService: PatientService,
@@ -59,7 +49,8 @@ export class PatientRecordComponent implements OnInit {
private permissionChecker: PermissionService,
private toaster: ToasterService,
private route: ActivatedRoute,
- private router: Router
+ private router: Router,
+ private http: HttpClient
) {}
ngOnInit() {
@@ -122,7 +113,6 @@ export class PatientRecordComponent implements OnInit {
});
this.patientService.getPatientRecordList(this.params, id).subscribe(data => {
this.patientrecords = data.items;
- // console.log(data.items);
this.totalRecords = data.totalCount;
this.loading = false;
});
@@ -201,50 +191,97 @@ export class PatientRecordComponent implements OnInit {
});
}
- handleLabReportUpload(event: Event): void {
+ handleUpload(event: Event, tag: string): void {
const input = event.target as HTMLInputElement;
- if (input && input.files) {
- const tag = 'Lab-Report';
+ if (input.files.length > 0) {
const formdata = new FormData();
formdata.append('file', input.files[0]);
this.UploadFileData(tag, formdata);
+ } else {
+ this.uploadProgress = 0;
+ return;
}
}
- handleMedicationsUpload(event: any): void {
- const input = event.target as HTMLInputElement;
- if (input && input.files) {
- const tag = 'Medication';
- const formdata = new FormData();
- formdata.append('file', input.files[0]);
- this.UploadFileData(tag, formdata);
- }
- }
+ // handleLabReportUpload(event: Event): void {
+ // const input = event.target as HTMLInputElement;
+ // if (input && input.files) {
+ // const tag = 'Lab-Report';
+ // const formdata = new FormData();
+ // formdata.append('file', input.files[0]);
+ // this.UploadFileData(tag, formdata);
+ // }
+ // }
- handleMedicationHistoryUpload(event: any): void {
- const input = event.target as HTMLInputElement;
- if (input && input.files) {
- const tag = 'Medication-History';
- const formdata = new FormData();
- formdata.append('file', input.files[0]);
- this.UploadFileData(tag, formdata);
- }
- }
+ // handleMedicationsUpload(event: any): void {
+ // const input = event.target as HTMLInputElement;
+ // if (input && input.files) {
+ // const tag = 'Medication';
+ // const formdata = new FormData();
+ // formdata.append('file', input.files[0]);
+ // this.UploadFileData(tag, formdata);
+ // }
+ // }
+
+ // handleMedicationHistoryUpload(event: any): void {
+ // const input = event.target as HTMLInputElement;
+ // if (input && input.files) {
+ // const tag = 'Medication-History';
+ // const formdata = new FormData();
+ // formdata.append('file', input.files[0]);
+ // this.UploadFileData(tag, formdata);
+ // }
+ // }
UploadFileData(tag: string, formdata: FormData) {
- this.patientService.uploadFile(tag, formdata).subscribe(result => {
- switch (tag) {
- case 'Lab-Report':
- this.selectedPatient.labReportUrlID = result;
- break;
- case 'Medication':
- this.selectedPatient.medicationUrlID = result;
- break;
- case 'Medication-History':
- this.selectedPatient.medicationHistoryUrlID = result;
- break;
+ // this.patientService.uploadFile(tag, formdata).subscribe(result => {
+ // switch (tag) {
+ // case 'Lab-Report':
+ // this.selectedPatient.labReportUrlID = result;
+ // break;
+ // case 'Medication':
+ // this.selectedPatient.medicationUrlID = result;
+ // break;
+ // case 'Medication-History':
+ // this.selectedPatient.medicationHistoryUrlID = result;
+ // break;
+ // }
+ // });
+ const req = new HttpRequest(
+ 'POST',
+ environment.apis.default.url + '/api/app/patient/upload-file',
+ formdata,
+ {
+ reportProgress: true,
+ responseType: 'text',
+ params: new HttpParams().set('tagName', tag),
}
- });
+ );
+ this.http.request(req).subscribe(
+ event => {
+ if (event.type === HttpEventType.UploadProgress) {
+ this.uploadProgress = Math.round((event.loaded / event.total!) * 100);
+ console.log(event.type, this.uploadProgress);
+ } else if (event.type === HttpEventType.Response) {
+ this.uploadProgress = 100;
+ switch (tag) {
+ case 'Lab-Report':
+ this.selectedPatient.labReportUrlID = event.body.toString();
+ break;
+ case 'Medication':
+ this.selectedPatient.medicationUrlID = event.body.toString();
+ break;
+ case 'Medication-History':
+ this.selectedPatient.medicationHistoryUrlID = event.body.toString();
+ break;
+ }
+ }
+ },
+ error => {
+ console.error('Upload failed', error);
+ this.uploadProgress = 0;
+ }
+ );
}
savePatient(form: NgForm) {