From cfca23a2db99a0287929417aa599f5a130df285e Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Thu, 27 Jun 2024 12:11:20 -0700 Subject: [PATCH 1/2] using metriport fhir converter fixes: https://github.com/fastenhealth/fasten-onprem/issues/472 fixes: https://github.com/fastenhealth/fasten-onprem/issues/291 --- README.md | 1 - .../medical-sources-connected.component.ts | 61 +++++++++--------- .../medical-sources.component.html | 10 ++- .../medical-sources.component.ts | 22 +++++-- frontend/src/app/services/platform.service.ts | 5 +- frontend/src/assets/images/metriport-logo.png | Bin 0 -> 14183 bytes frontend/src/lib/utils/error_extract.ts | 26 ++++++++ 7 files changed, 84 insertions(+), 41 deletions(-) create mode 100644 frontend/src/assets/images/metriport-logo.png create mode 100644 frontend/src/lib/utils/error_extract.ts diff --git a/README.md b/README.md index d30a8a90e..ff226fcbb 100644 --- a/README.md +++ b/README.md @@ -171,5 +171,4 @@ I'd also like to thank the following Corporate Sponsors: - diff --git a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts index ec7d24e5d..9df8aac4b 100644 --- a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts +++ b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.ts @@ -15,6 +15,7 @@ import {SourceState} from '../../models/fasten/source-state'; import {PatientAccessBrand} from '../../models/patient-access-brands'; import {environment} from '../../../environments/environment'; import {BackgroundJobSyncData} from '../../models/fasten/background-job'; +import {extractErrorFromResponse, replaceErrors} from '../../../lib/utils/error_extract'; @Component({ selector: 'app-medical-sources-connected', @@ -217,7 +218,7 @@ export class MedicalSourcesConnectedComponent implements OnInit { const toastNotification = new ToastNotification() toastNotification.type = ToastType.Error - toastNotification.message = `An error occurred while finalizing external data source and starting sync: '${this.extractErrorFromResponse(err)}'` + toastNotification.message = `An error occurred while finalizing external data source and starting sync: '${extractErrorFromResponse(err)}'` toastNotification.autohide = false toastNotification.link = { text: "View Details", @@ -233,7 +234,7 @@ export class MedicalSourcesConnectedComponent implements OnInit { const toastNotification = new ToastNotification() toastNotification.type = ToastType.Error - toastNotification.message = `An error occurred while initializing external data source connection: '${this.extractErrorFromResponse(err)}'` + toastNotification.message = `An error occurred while initializing external data source connection: '${extractErrorFromResponse(err)}'` toastNotification.autohide = false this.toastService.show(toastNotification) console.error(err) @@ -253,7 +254,7 @@ export class MedicalSourcesConnectedComponent implements OnInit { } errData.error_data = { summary: toastNotification.message, - error: JSON.stringify(err, this.replaceErrors), + error: JSON.stringify(err, replaceErrors), stack: err.stack } @@ -262,31 +263,31 @@ export class MedicalSourcesConnectedComponent implements OnInit { }) } - //https://stackoverflow.com/a/18391400/1157633 - extractErrorFromResponse(errResp: any): string { - let errMsg = "" - if(errResp.name == "HttpErrorResponse" && errResp.error && errResp.error?.error){ - errMsg = errResp.error.error - } else { - errMsg = JSON.stringify(errResp, this.replaceErrors) - } - return errMsg - } - - //stringify error objects - replaceErrors(key, value) { - if (value instanceof Error) { - var error = {}; - - Object.getOwnPropertyNames(value).forEach(function (propName) { - error[propName] = value[propName]; - }); - - return error; - } - - return value; - } + // //https://stackoverflow.com/a/18391400/1157633 + // extractErrorFromResponse(errResp: any): string { + // let errMsg = "" + // if(errResp.name == "HttpErrorResponse" && errResp.error && errResp.error?.error){ + // errMsg = errResp.error.error + // } else { + // errMsg = JSON.stringify(errResp, replaceErrors) + // } + // return errMsg + // } + + // //stringify error objects + // replaceErrors(key, value) { + // if (value instanceof Error) { + // var error = {}; + // + // Object.getOwnPropertyNames(value).forEach(function (propName) { + // error[propName] = value[propName]; + // }); + // + // return error; + // } + // + // return value; + // } /** * https://github.com/smart-on-fhir/client-js/blob/8f64b770dbcd0abd30646e239cd446dfa4d831f6/src/lib.ts#L311 @@ -382,7 +383,7 @@ export class MedicalSourcesConnectedComponent implements OnInit { const toastNotification = new ToastNotification() toastNotification.type = ToastType.Error - toastNotification.message = `An error occurred while updating source (${source.display}): ${this.extractErrorFromResponse(err)}` + toastNotification.message = `An error occurred while updating source (${source.display}): ${extractErrorFromResponse(err)}` this.toastService.show(toastNotification) console.log(err) @@ -425,7 +426,7 @@ export class MedicalSourcesConnectedComponent implements OnInit { const toastNotification = new ToastNotification() toastNotification.type = ToastType.Error - toastNotification.message = `An error occurred while deleting source (${sourceDisplayName}): ${this.extractErrorFromResponse(err)}` + toastNotification.message = `An error occurred while deleting source (${sourceDisplayName}): ${extractErrorFromResponse(err)}` this.toastService.show(toastNotification) console.log(err) }) diff --git a/frontend/src/app/pages/medical-sources/medical-sources.component.html b/frontend/src/app/pages/medical-sources/medical-sources.component.html index 748be90bd..c0e22b294 100644 --- a/frontend/src/app/pages/medical-sources/medical-sources.component.html +++ b/frontend/src/app/pages/medical-sources/medical-sources.component.html @@ -39,6 +39,10 @@

Medical Record Sources

{{ f.name }} ({{ f.type }}) + + @@ -155,15 +159,15 @@