Skip to content

Commit

Permalink
adding download button.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Oct 7, 2024
1 parent d3751d7 commit 568ccc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1>Loading...</h1>
<pre class="card" style="max-height:300px">
<code [languages]="['json', 'xml']" [highlight]="bundle"></code>
</pre>
<!-- <a [href]="generateBundleDownloadUrl" [download]="generateBundleDownloadFilename" class="btn btn-indigo btn-rounded">Download FHIR Bundle</a>-->
<a [href]="generateBundleDownloadUrl" [download]="generateBundleDownloadFilename" class="btn btn-indigo btn-rounded">Download FHIR JSON File</a>

</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {ToolboxService} from '../../services/toolbox.service';
import {DomSanitizer} from '@angular/platform-browser';

@Component({
selector: 'app-medical-records-export-callback',
Expand All @@ -20,9 +21,13 @@ export class MedicalRecordsExportCallbackComponent implements OnInit {
bundleSyncStart = ""
bundleSyncCurrent = ""

generateBundleDownloadUrl = null
generateBundleDownloadFilename = null

constructor(
private activatedRoute : ActivatedRoute,
private toolboxService: ToolboxService,
private sanitizer: DomSanitizer
) { }

ngOnInit(): void {
Expand Down Expand Up @@ -73,6 +78,12 @@ export class MedicalRecordsExportCallbackComponent implements OnInit {

this.hasBundle = true
this.bundle = res.content

let bundleJsonBlob = new Blob([JSON.stringify(this.bundle, null, 2)], { type: 'application/json' });
this.generateBundleDownloadUrl = this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(bundleJsonBlob));
this.generateBundleDownloadFilename = `fasten-${values['endpoint_id']}.bundle.jsonl`


} else if(res.status == 'failed') {
//if error present the error to the user
this.hasError = true
Expand Down Expand Up @@ -102,4 +113,6 @@ export class MedicalRecordsExportCallbackComponent implements OnInit {
})
}



}

0 comments on commit 568ccc3

Please sign in to comment.