make sure the diagnostic report correctly embeds attachments.

Make sure that Binary resource types with fully qualified urls identifier are handled correctly (base64 encoded url is the ResourceID).
Update fasten-sources version.
This commit is contained in:
Jason Kulatunga 2023-08-17 16:09:05 -06:00
parent 2f292397f7
commit 43cc6b4559
5 changed files with 31 additions and 18 deletions

View File

@ -14,6 +14,10 @@
<div #collapse="ngbCollapse" [(ngbCollapse)]="isCollapsed" class="card-body">
<p class="az-content-text mg-b-20" *ngIf="!(resourceCode && resourceCodeSystem); else lookupCode">An action that is or was performed on or for a patient, practitioner, device, organization, or location. For example, this can be a physical intervention on a patient like an operation, or less invasive like long term services, counseling, or hypnotherapy.</p>
<fhir-ui-table [displayModel]="displayModel" [tableData]="tableData"></fhir-ui-table>
<div *ngIf="!showDetails">
<fhir-binary *ngFor="let attachmentModel of displayModel.presented_form" [attachmentModel]="attachmentModel" [attachmentSourceId]="displayModel?.source_id" ></fhir-binary>
</div>
</div>
<div *ngIf="showDetails" class="card-footer">
<a class="float-right" routerLink="/explore/{{displayModel?.source_id}}/resource/{{displayModel?.source_resource_id}}">details</a>

View File

@ -214,24 +214,28 @@ export class FastenApiService {
getBinaryModel(sourceId: string, attachmentModel: AttachmentModel): Observable<BinaryModel> {
if(attachmentModel.url && !attachmentModel.data){
//this attachment model is a refernce to a Binary model, we need to download it first.
let binaryResourceId = attachmentModel.url
let urnPrefix = "urn:uuid:";
let resourceType = "Binary"
let resourceId = ""
let binaryUrl = attachmentModel.url
//strip out the urn prefix (if this is an embedded id, eg. urn:uuid:2a35e080-c5f7-4dde-b0cf-8210505708f1)
let urnPrefix = "urn:uuid:";
if (binaryResourceId.startsWith(urnPrefix)) {
if (binaryUrl.startsWith(urnPrefix)) {
// PREFIX is exactly at the beginning
binaryResourceId = binaryResourceId.slice(urnPrefix.length);
resourceId = binaryUrl.slice(urnPrefix.length);
} else if(binaryUrl.startsWith("http://") || binaryUrl.startsWith("https://")){
//this is an absolute URL (which could be a FHIR url with Binary/xxx-xxx-xxx-xxx or a direct link to a file)
let urlParts = binaryUrl.split("Binary/");
if(urlParts.length > 1){
//this url has a Binary/xxx-xxx-xxx-xxx part, so we can use that as the resource id
resourceId = urlParts[urlParts.length - 1];
} else {
//this is a fully qualified url. we need to base64 encode the url and use that as the resource id
resourceId = btoa(binaryUrl)
}
}
//TODO: this is a naiive solution.
//assumes that this is a relative or absolutie url in the following format:
// 'Binary/xxx-xxx-xxx-xxx'
// 'https://www.example.com/R4/path/Binary/xxx-xx-x-xx'
let urlParts = binaryResourceId.split("Binary/");
binaryResourceId = urlParts[urlParts.length - 1];
return this.getResourceBySourceId(sourceId, binaryResourceId).pipe(
return this.getResourceBySourceId(sourceId, resourceId).pipe(
map((resourceFhir: ResourceFhir) => {
return new BinaryModel(resourceFhir.resource_raw)
})

View File

@ -5,6 +5,7 @@ import {ReferenceModel} from '../datatypes/reference-model';
import {CodingModel} from '../datatypes/coding-model';
import {FastenDisplayModel} from '../fasten/fasten-display-model';
import {FastenOptions} from '../fasten/fasten-options';
import {AttachmentModel} from '../datatypes/attachment-model';
export class DiagnosticReportModel extends FastenDisplayModel {
code: CodableConceptModel | undefined
@ -19,6 +20,7 @@ export class DiagnosticReportModel extends FastenDisplayModel {
conclusion: string | undefined
performer: ReferenceModel | undefined
issued: string | undefined
presented_form: AttachmentModel[] | undefined
constructor(fhirResource: any, fhirVersion?: fhirVersions, fastenOptions?: FastenOptions) {
super(fastenOptions)
@ -39,6 +41,7 @@ export class DiagnosticReportModel extends FastenDisplayModel {
this.has_category_coding = Array.isArray(this.category_coding);
this.conclusion = _.get(fhirResource, 'conclusion');
this.issued = _.get(fhirResource, 'issued');
};
dstu2DTO(fhirResource:any){
@ -58,6 +61,10 @@ export class DiagnosticReportModel extends FastenDisplayModel {
this.has_performer = !!this.performer;
this.category_coding = _.get(fhirResource, 'category.coding');
this.has_category_coding = Array.isArray(this.category_coding);
this.presented_form = _.get(fhirResource, 'presentedForm', []).map((attachment: any) => {
return new AttachmentModel(attachment);
})
};
resourceDTO(fhirResource:any, fhirVersion: fhirVersions){

6
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/dave/jennifer v1.6.1
github.com/dominikbraun/graph v0.15.0
github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3
github.com/fastenhealth/fasten-sources v0.2.7
github.com/fastenhealth/fasten-sources v0.2.9
github.com/fastenhealth/gofhir-models v0.0.5
github.com/gin-gonic/gin v1.9.0
github.com/glebarez/sqlite v1.5.0
@ -17,6 +17,7 @@ require (
github.com/iancoleman/strcase v0.2.0
github.com/lestrrat-go/jwx/v2 v2.0.11
github.com/philips-software/go-hsdp-api v0.81.0
github.com/samber/lo v1.35.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.4
@ -78,7 +79,6 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.35.0 // indirect
github.com/seborama/govcr v4.5.0+incompatible // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect
@ -107,4 +107,4 @@ require (
modernc.org/sqlite v1.19.1 // indirect
)
//replace github.com/fastenhealth/fasten-sources => ../fasten-sources
replace github.com/fastenhealth/fasten-sources => ../fasten-sources

2
go.sum
View File

@ -191,8 +191,6 @@ github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
github.com/fastenhealth/fasten-sources v0.2.7 h1:g4blrTMJK/QfJI5X6VjvDk6P475kxgx9EBxQWuXmkoc=
github.com/fastenhealth/fasten-sources v0.2.7/go.mod h1:B7pVQcwLuL+rgjSHwlu3p0CySyHN262BkfbYMKVKXTk=
github.com/fastenhealth/gofhir-models v0.0.5 h1:wU2Dz+/h9MzZCTRgkQzeq5l0EFuMI6C5xgCbKislFpg=
github.com/fastenhealth/gofhir-models v0.0.5/go.mod h1:xB8ikGxu3bUq2b1JYV+CZpHqBaLXpOizFR0eFBCunis=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=