diff --git a/angular/src/app/patients/all-patients/all-patients.component.html b/angular/src/app/patients/all-patients/all-patients.component.html index 64159d6..b79aacd 100644 --- a/angular/src/app/patients/all-patients/all-patients.component.html +++ b/angular/src/app/patients/all-patients/all-patients.component.html @@ -92,9 +92,14 @@
Uploading... {{ uploadProgress }}%
+ +
'
- };
+ uploadProgress = 0;
constructor(
private patientService: PatientService,
@@ -103,6 +93,7 @@ export class AllPatientsComponent implements OnInit {
this.imgpath = '';
this.selectedgender = 0;
this.selectedstatus = 0;
+ this.uploadProgress = 0;
}
loadPatient(event: any) {
@@ -174,14 +165,41 @@ export class AllPatientsComponent implements OnInit {
formdata.append('file', input.files[0]);
this.UploadFileData(tag, formdata);
} else {
+ this.uploadProgress = 0;
return;
}
}
+
UploadFileData(tag: string, formdata: FormData) {
- this.patientService.uploadFile(tag, formdata).subscribe(result => {
- this.selectedPatient.imageID = result;
- });
+ // this.patientService.uploadFile(tag, formdata).subscribe(result => {
+ // this.selectedPatient.imageID = result;
+ // });
+ 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;
+ this.selectedPatient.imageID = event.body.toString();
+ }
+ },
+ error => {
+ console.error('Upload failed', error);
+ this.uploadProgress = 0;
+ }
+ );
}
editPatient(Patient: any) {
diff --git a/angular/src/app/patients/patient-record/patient-record.component.html b/angular/src/app/patients/patient-record/patient-record.component.html
index 44ff19f..630f94b 100644
--- a/angular/src/app/patients/patient-record/patient-record.component.html
+++ b/angular/src/app/patients/patient-record/patient-record.component.html
@@ -83,8 +83,8 @@
Uploading... {{ uploadProgress }}%
+ +Uploading... {{ uploadProgress }}%
+ +Uploading... {{ uploadProgress }}%
+ +
'
- };
+ 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) {