From d6b9ceb58894e73323d7543f12969a97e873ee5f Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Thu, 17 Sep 2020 05:28:42 -0400 Subject: [PATCH 1/9] Changes to support Generate CCDA endpoint --- .../resources-table-container.component.html | 3 ++- .../resources-table-container.component.ts | 4 ++++ src/app/data/ccds-resources.ts | 6 ++++++ src/app/services/ccds-resource-helper.service.ts | 5 ++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.html b/src/app/components/resources/resources-table-container/resources-table-container.component.html index a4f3e12..698c1d6 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.html +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.html @@ -52,7 +52,8 @@

{{param.name}}

- + + \ No newline at end of file diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.ts b/src/app/components/resources/resources-table-container/resources-table-container.component.ts index c17bbf0..baa61a3 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.ts +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.ts @@ -72,6 +72,7 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { private _unsubscribe = new Subject(); private readonly _lastUpdatedParam = '_lastUpdated'; + private isBundle = true; constructor( private _helperService: HelperService, @@ -154,6 +155,9 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { this._zone.run(() => { this.isLoading = false; this.resources = response.data; + if(response.data.resourceType !== 'Bundle'){ + this.isBundle = false; + } if (!!environment.showCCDSResourceMenuInstead && !!response.data && !!response.data.total) { let responseDataCopy = this._helperService.clone(response.data) diff --git a/src/app/data/ccds-resources.ts b/src/app/data/ccds-resources.ts index bfb28b7..fb7a272 100644 --- a/src/app/data/ccds-resources.ts +++ b/src/app/data/ccds-resources.ts @@ -120,6 +120,12 @@ export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ FhirResource : "Condition", SearchQueryParameters : {}, SearchSetFilter : healthConcernFilter + }, + { + CCDSType : "Generate CCDA", + FhirResource : "$generate-ccda", + SearchQueryParameters : {"start" : "01-05-2020","end" : "10-09-2020","appid" : "d04d3191-8923-4fd3-8c25-e671b73c95fb"}, + SearchSetFilter : defaultFilter } ] diff --git a/src/app/services/ccds-resource-helper.service.ts b/src/app/services/ccds-resource-helper.service.ts index 89d6d51..1f371e5 100644 --- a/src/app/services/ccds-resource-helper.service.ts +++ b/src/app/services/ccds-resource-helper.service.ts @@ -19,9 +19,12 @@ export class CCDSResourceHelperService { */ public getSupportedCCDSResources(supportedResources: any[]){ return CCDS_RESOURCE_MAPPING.filter((ccdsMapping) => { + if (ccdsMapping.FhirResource.startsWith('$')) { + return true; + } return supportedResources.some((resource) => { return resource.toLowerCase() === ccdsMapping.FhirResource.toLowerCase(); - }) + }); }); } From 0433a607c48a9ff5f1ab38e225481edbcea2f15c Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Fri, 18 Sep 2020 04:45:52 -0400 Subject: [PATCH 2/9] Setting to hide date filter for ccds types --- .../resources-table-container.component.html | 4 ++-- .../resources-table-container.component.ts | 4 ++++ src/app/data/ccds-resources.ts | 11 +++++++---- src/app/models/ccds-resource.ts | 7 +++++++ src/app/models/resource-setting.ts | 9 +++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 src/app/models/resource-setting.ts diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.html b/src/app/components/resources/resources-table-container/resources-table-container.component.html index 698c1d6..4bec902 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.html +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.html @@ -34,7 +34,7 @@

{{param.name}}

-
+
@@ -46,7 +46,7 @@

{{param.name}}

- +
diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.ts b/src/app/components/resources/resources-table-container/resources-table-container.component.ts index baa61a3..5193e6f 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.ts +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.ts @@ -73,6 +73,7 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { private _unsubscribe = new Subject(); private readonly _lastUpdatedParam = '_lastUpdated'; private isBundle = true; + private hideDateFilter = false; constructor( private _helperService: HelperService, @@ -91,6 +92,9 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { this.resourceType = this._route.snapshot.paramMap.get('resourceType'); this.ccdsResourceType = this._CCDSResourceHelperService.getCCDSResourceFromName(this._route.snapshot.fragment); console.log(this.ccdsResourceType); + if (this.ccdsResourceType.ResourceSettings) { + this.hideDateFilter = this.ccdsResourceType.ResourceSettings.HideDateFilter; + } this._smartService.getClient() .takeUntil(this._unsubscribe) .subscribe(smartClient => { diff --git a/src/app/data/ccds-resources.ts b/src/app/data/ccds-resources.ts index fb7a272..e435c75 100644 --- a/src/app/data/ccds-resources.ts +++ b/src/app/data/ccds-resources.ts @@ -122,10 +122,13 @@ export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ SearchSetFilter : healthConcernFilter }, { - CCDSType : "Generate CCDA", - FhirResource : "$generate-ccda", - SearchQueryParameters : {"start" : "01-05-2020","end" : "10-09-2020","appid" : "d04d3191-8923-4fd3-8c25-e671b73c95fb"}, - SearchSetFilter : defaultFilter + CCDSType: "Generate CCDA", + FhirResource: "$generate-ccda", + SearchQueryParameters: { "start": "01-05-2020", "end": "10-09-2020", "appid": "d04d3191-8923-4fd3-8c25-e671b73c95fb" }, + SearchSetFilter: defaultFilter, + ResourceSettings: { + HideDateFilter: true + } } ] diff --git a/src/app/models/ccds-resource.ts b/src/app/models/ccds-resource.ts index f3f1c3a..260d245 100644 --- a/src/app/models/ccds-resource.ts +++ b/src/app/models/ccds-resource.ts @@ -1,3 +1,5 @@ +import { ResourceSettings } from "./resource-setting"; + /** * Object to hold mapping between a CCDS datatype and the equivalent FHIR resource */ @@ -17,6 +19,11 @@ export interface CCDSResourceMapping { */ SearchQueryParameters: {}; + /** + * Settings for the CCDS datatype. + */ + ResourceSettings?: ResourceSettings; + /** * If query parameters are not possbile, add filters that need to be applied to resource responses. */ diff --git a/src/app/models/resource-setting.ts b/src/app/models/resource-setting.ts new file mode 100644 index 0000000..1907d47 --- /dev/null +++ b/src/app/models/resource-setting.ts @@ -0,0 +1,9 @@ +/** + * Object to hold Settings of a CCDS resource. + */ +export interface ResourceSettings { + /** + * Flag to hide the Date Filter. + */ + HideDateFilter?: boolean; +} \ No newline at end of file From 8f5bcdc779c052b82d82ae0509681406ed682bc2 Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Fri, 18 Sep 2020 16:10:39 -0400 Subject: [PATCH 3/9] New generate-ccda component --- src/app/app.component.html | 1 + .../generate-ccda/generate-ccda.component.css | 0 .../generate-ccda.component.html | 36 +++++ .../generate-ccda.component.spec.ts | 25 ++++ .../generate-ccda/generate-ccda.component.ts | 131 ++++++++++++++++++ src/app/components/misc-pages/index.ts | 1 + .../misc-pages/misc-pages-routing.module.ts | 3 +- .../misc-pages/misc-pages.module.ts | 4 +- src/app/data/generate-ccda-settings.ts | 4 + 9 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 src/app/components/misc-pages/generate-ccda/generate-ccda.component.css create mode 100644 src/app/components/misc-pages/generate-ccda/generate-ccda.component.html create mode 100644 src/app/components/misc-pages/generate-ccda/generate-ccda.component.spec.ts create mode 100644 src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts create mode 100644 src/app/data/generate-ccda-settings.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index e83cebe..3f8f021 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -30,6 +30,7 @@

Server: {{connectedServer}}

Access Token User Profile + Generate CCDA diff --git a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.css b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html new file mode 100644 index 0000000..a71d4ee --- /dev/null +++ b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html @@ -0,0 +1,36 @@ + + + +
+
+ Generate-CCDA +
+
+
+
+
+ + + + + + Params + + + Specify the filter as JSON [ + Reference] + + + +
+ + + + +
+
+
+
+
+ + diff --git a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.spec.ts b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.spec.ts new file mode 100644 index 0000000..c54c152 --- /dev/null +++ b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GenerateCcdaComponent } from './generate-ccda.component'; + +describe('GenerateCcdaComponent', () => { + let component: GenerateCcdaComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GenerateCcdaComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GenerateCcdaComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts new file mode 100644 index 0000000..60fe994 --- /dev/null +++ b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts @@ -0,0 +1,131 @@ +import { Component, OnInit, NgZone, OnDestroy } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { Subject } from 'rxjs'; +import { GENERATE_CCDA_SETTINGS } from 'src/app/data/generate-ccda-settings'; +import { HelperService, SmartService } from 'src/app/services'; +import { CCDSResourceHelperService } from 'src/app/services/ccds-resource-helper.service'; + +@Component({ + selector: 'app-generate-ccda', + templateUrl: './generate-ccda.component.html', + styleUrls: ['./generate-ccda.component.css'] +}) +export class GenerateCcdaComponent implements OnInit, OnDestroy { + /** + * Query object passed to the SMART JS Client Search api. + */ + query: any; + + /** + * Error occured while trying to fetch the resource + */ + error: any; + + /** + * Flag to show that a request to fetch FHIR resources are in progress. Used by the Loading indicator. + */ + isLoading: boolean; + + /** + * Flag to show whether the json entered in the editor is a valid JSON or not. The save button is hidden based on this flag. + */ + invalidJson: boolean; + + /** + * Search Parameters supported by the FHIR Server for this particular FHIR Resource Type + */ + searchParams: any; + + /** + * List of resources fetched from the FHIR server based on the query object + */ + resources: any; + + private _unsubscribe = new Subject(); + + constructor( + private _smartService: SmartService, + private _helperService: HelperService, + private _route: ActivatedRoute, + private _zone: NgZone, + private _CCDSResourceHelperService: CCDSResourceHelperService + ) { } + + ngOnInit() { + this._setSupportedSearchParams(); + } + + /** + * Set the search parameters supported by the resource type in the filter + */ + private _setSupportedSearchParams() { + this.searchParams = GENERATE_CCDA_SETTINGS.SearchQueryParameters; + this.query = this.searchParams; + } + + /** + * Called by the Apply button, to apply the query object in the editor and perform the FHIR API Call + */ + submit() { + this._smartService.getClient() + .takeUntil(this._unsubscribe) + .subscribe(smartClient => { + this.generateCCDA(smartClient); + }); + } + + /** + * Called by the Reset button in the filter to clear the current query object and reset. + */ + reset() { + this._setSupportedSearchParams(); + } + + generateCCDA(smartClient: FHIR.SMART.SMARTClient) { + this.isLoading = true; + console.log(this.query); + const searchParams: FHIR.SMART.SearchParams = { + type: GENERATE_CCDA_SETTINGS.Endpoint, + query: this.query + }; + + // Makes use of the SMART on FHIR JS Client search api method + smartClient.api.search(searchParams).then(response => { + this._zone.run(() => { + this.isLoading = false; + this.resources = response.data; + this.error = null; + }); + }, error => { + this._zone.run(() => { + this.isLoading = false; + this.error = error; + }); + }); + } + + /** + * Setter method used by the Ace Editor to set the value of the query object + */ + set queryCode(v) { + try { + this.query = JSON.parse(v); + this.invalidJson = false; + } catch (e) { + this.invalidJson = true; + console.log('error occored while you were typing the JSON'); + } + } + + /** + * Getter method used by the Ace Editor to get the value of the query object + */ + get queryCode() { + return JSON.stringify(this.query, null, 2); + } + + ngOnDestroy() { + this._unsubscribe.next(); + this._unsubscribe.complete(); + } +} diff --git a/src/app/components/misc-pages/index.ts b/src/app/components/misc-pages/index.ts index a62f039..33f44db 100644 --- a/src/app/components/misc-pages/index.ts +++ b/src/app/components/misc-pages/index.ts @@ -6,3 +6,4 @@ export * from './launch/launch.component'; export * from './redirect/redirect.component'; export * from './state/state.component'; export * from './user-profile/user-profile.component'; +export * from './generate-ccda/generate-ccda.component'; diff --git a/src/app/components/misc-pages/misc-pages-routing.module.ts b/src/app/components/misc-pages/misc-pages-routing.module.ts index b36b11c..61c688c 100644 --- a/src/app/components/misc-pages/misc-pages-routing.module.ts +++ b/src/app/components/misc-pages/misc-pages-routing.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { IndexComponent, StateComponent, AccessTokenComponent, UserProfileComponent, - ConformanceComponent, ConnectComponent, LaunchComponent, RedirectComponent + ConformanceComponent, ConnectComponent, LaunchComponent, RedirectComponent, GenerateCcdaComponent } from '.'; import { AuthGaurd } from '../../misc/auth-guard'; import { Routes, RouterModule } from '@angular/router'; @@ -16,6 +16,7 @@ const routes: Routes = [ { path: 'connect/:uniqueName', component: ConnectComponent }, { path: 'launch/:uniqueName', component: LaunchComponent }, { path: 'redirect/:uniqueName', component: RedirectComponent }, + { path: 'generate-ccda', component: GenerateCcdaComponent }, ]; @NgModule({ diff --git a/src/app/components/misc-pages/misc-pages.module.ts b/src/app/components/misc-pages/misc-pages.module.ts index 2edc7b3..5c2580b 100644 --- a/src/app/components/misc-pages/misc-pages.module.ts +++ b/src/app/components/misc-pages/misc-pages.module.ts @@ -14,6 +14,7 @@ import { NgxJsonViewerModule } from 'ngx-json-viewer'; import { AceEditorModule } from 'ng2-ace-editor'; import { SmartCommonModule } from '../common/smart-common.module'; import { FormsModule } from '@angular/forms'; +import { GenerateCcdaComponent } from './generate-ccda/generate-ccda.component'; /** * Modules containing all the components which does not directly make FHIR API Calls except ConformanceComponent @@ -36,7 +37,8 @@ import { FormsModule } from '@angular/forms'; LaunchComponent, RedirectComponent, StateComponent, - UserProfileComponent + UserProfileComponent, + GenerateCcdaComponent ] }) export class MiscPagesModule { } diff --git a/src/app/data/generate-ccda-settings.ts b/src/app/data/generate-ccda-settings.ts new file mode 100644 index 0000000..e5b79d8 --- /dev/null +++ b/src/app/data/generate-ccda-settings.ts @@ -0,0 +1,4 @@ +export const GENERATE_CCDA_SETTINGS = { + Endpoint: '$generate-ccda', + SearchQueryParameters: { 'start': '01-05-2020', 'end': '10-09-2020', 'appid': 'd04d3191-8923-4fd3-8c25-e671b73c95fb' }, +}; From cba7d477e92dc91dc02ef8e600d6f4e534ed577d Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Sat, 19 Sep 2020 06:11:36 -0400 Subject: [PATCH 4/9] Download feature & own object viewer fro Generate-ccda component --- .../generate-ccda.component.html | 27 +++++++++++++++++-- .../generate-ccda/generate-ccda.component.ts | 24 +++++++++++++++++ src/app/data/generate-ccda-settings.ts | 1 + 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html index a71d4ee..2ec33b9 100644 --- a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html +++ b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.html @@ -3,7 +3,7 @@
- Generate-CCDA + Generate-CCDA
@@ -30,7 +30,30 @@
+
+ + + +
Resource type: {{resources.resourceType}}
+
Id: {{resources.id}}
+
Last updated: {{resources.meta.lastUpdated}}
+
Number of attachments: {{resources.content.length}}
+
+ +

Attachment title: {{content.attachment.title ? content.attachment.title : 'Untitled'}}

+ +
+
+
+
+ + + + + + +
+
- diff --git a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts index 60fe994..03f7ce0 100644 --- a/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts +++ b/src/app/components/misc-pages/generate-ccda/generate-ccda.component.ts @@ -104,6 +104,23 @@ export class GenerateCcdaComponent implements OnInit, OnDestroy { }); } + OnDownload(content) { + console.log(content); + let attachment = content.attachment; + let data = atob(`${attachment.data}`); + let blob = new Blob([data], { type: `${attachment.contentType}` }); + let url = URL.createObjectURL(blob); + let filename = GENERATE_CCDA_SETTINGS.DownloadFileName; + if (url) { + var a = document.createElement('a'); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } + } + /** * Setter method used by the Ace Editor to set the value of the query object */ @@ -124,6 +141,13 @@ export class GenerateCcdaComponent implements OnInit, OnDestroy { return JSON.stringify(this.query, null, 2); } + /** + * Getter method used by the Ace Editor to get the value of the resources object + */ + get resourcesCode() { + return JSON.stringify(this.resources, null, 2); + } + ngOnDestroy() { this._unsubscribe.next(); this._unsubscribe.complete(); diff --git a/src/app/data/generate-ccda-settings.ts b/src/app/data/generate-ccda-settings.ts index e5b79d8..56ed025 100644 --- a/src/app/data/generate-ccda-settings.ts +++ b/src/app/data/generate-ccda-settings.ts @@ -1,4 +1,5 @@ export const GENERATE_CCDA_SETTINGS = { Endpoint: '$generate-ccda', SearchQueryParameters: { 'start': '01-05-2020', 'end': '10-09-2020', 'appid': 'd04d3191-8923-4fd3-8c25-e671b73c95fb' }, + DownloadFileName: 'ClinicalDocument.xml' }; From b6af49e25e2c8e909d9ca402b29d99e37f86c1c3 Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Sat, 19 Sep 2020 06:16:30 -0400 Subject: [PATCH 5/9] Revert "Changes to support Generate CCDA endpoint" This reverts commit d6b9ceb58894e73323d7543f12969a97e873ee5f. --- .../resources-table-container.component.html | 7 +++---- .../resources-table-container.component.ts | 8 -------- src/app/data/ccds-resources.ts | 9 --------- src/app/models/ccds-resource.ts | 7 ------- src/app/models/resource-setting.ts | 9 --------- src/app/services/ccds-resource-helper.service.ts | 5 +---- 6 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 src/app/models/resource-setting.ts diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.html b/src/app/components/resources/resources-table-container/resources-table-container.component.html index 4bec902..a4f3e12 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.html +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.html @@ -34,7 +34,7 @@

{{param.name}}

-
+
@@ -46,14 +46,13 @@

{{param.name}}

- +
- + - \ No newline at end of file diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.ts b/src/app/components/resources/resources-table-container/resources-table-container.component.ts index 5193e6f..c17bbf0 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.ts +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.ts @@ -72,8 +72,6 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { private _unsubscribe = new Subject(); private readonly _lastUpdatedParam = '_lastUpdated'; - private isBundle = true; - private hideDateFilter = false; constructor( private _helperService: HelperService, @@ -92,9 +90,6 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { this.resourceType = this._route.snapshot.paramMap.get('resourceType'); this.ccdsResourceType = this._CCDSResourceHelperService.getCCDSResourceFromName(this._route.snapshot.fragment); console.log(this.ccdsResourceType); - if (this.ccdsResourceType.ResourceSettings) { - this.hideDateFilter = this.ccdsResourceType.ResourceSettings.HideDateFilter; - } this._smartService.getClient() .takeUntil(this._unsubscribe) .subscribe(smartClient => { @@ -159,9 +154,6 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { this._zone.run(() => { this.isLoading = false; this.resources = response.data; - if(response.data.resourceType !== 'Bundle'){ - this.isBundle = false; - } if (!!environment.showCCDSResourceMenuInstead && !!response.data && !!response.data.total) { let responseDataCopy = this._helperService.clone(response.data) diff --git a/src/app/data/ccds-resources.ts b/src/app/data/ccds-resources.ts index e435c75..bfb28b7 100644 --- a/src/app/data/ccds-resources.ts +++ b/src/app/data/ccds-resources.ts @@ -120,15 +120,6 @@ export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ FhirResource : "Condition", SearchQueryParameters : {}, SearchSetFilter : healthConcernFilter - }, - { - CCDSType: "Generate CCDA", - FhirResource: "$generate-ccda", - SearchQueryParameters: { "start": "01-05-2020", "end": "10-09-2020", "appid": "d04d3191-8923-4fd3-8c25-e671b73c95fb" }, - SearchSetFilter: defaultFilter, - ResourceSettings: { - HideDateFilter: true - } } ] diff --git a/src/app/models/ccds-resource.ts b/src/app/models/ccds-resource.ts index 260d245..f3f1c3a 100644 --- a/src/app/models/ccds-resource.ts +++ b/src/app/models/ccds-resource.ts @@ -1,5 +1,3 @@ -import { ResourceSettings } from "./resource-setting"; - /** * Object to hold mapping between a CCDS datatype and the equivalent FHIR resource */ @@ -19,11 +17,6 @@ export interface CCDSResourceMapping { */ SearchQueryParameters: {}; - /** - * Settings for the CCDS datatype. - */ - ResourceSettings?: ResourceSettings; - /** * If query parameters are not possbile, add filters that need to be applied to resource responses. */ diff --git a/src/app/models/resource-setting.ts b/src/app/models/resource-setting.ts deleted file mode 100644 index 1907d47..0000000 --- a/src/app/models/resource-setting.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Object to hold Settings of a CCDS resource. - */ -export interface ResourceSettings { - /** - * Flag to hide the Date Filter. - */ - HideDateFilter?: boolean; -} \ No newline at end of file diff --git a/src/app/services/ccds-resource-helper.service.ts b/src/app/services/ccds-resource-helper.service.ts index 1f371e5..89d6d51 100644 --- a/src/app/services/ccds-resource-helper.service.ts +++ b/src/app/services/ccds-resource-helper.service.ts @@ -19,12 +19,9 @@ export class CCDSResourceHelperService { */ public getSupportedCCDSResources(supportedResources: any[]){ return CCDS_RESOURCE_MAPPING.filter((ccdsMapping) => { - if (ccdsMapping.FhirResource.startsWith('$')) { - return true; - } return supportedResources.some((resource) => { return resource.toLowerCase() === ccdsMapping.FhirResource.toLowerCase(); - }); + }) }); } From 875d4259f6ba739cb9390de6f0c0ef1d0c97dc34 Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Tue, 29 Sep 2020 16:16:14 -0400 Subject: [PATCH 6/9] Filters modified to support multiple category codes --- .../resources-table-container.component.html | 6 +- .../resources-table-container.component.ts | 8 +- .../resources-table.component.html | 2 +- .../resources-table.component.ts | 7 +- src/app/data/ccds-resource-filters.ts | 91 ++++++++ src/app/data/ccds-resources.ts | 214 ++++++------------ src/app/models/ccds-resource-filter.ts | 7 + src/app/models/ccds-resource.ts | 8 +- 8 files changed, 188 insertions(+), 155 deletions(-) create mode 100644 src/app/data/ccds-resource-filters.ts create mode 100644 src/app/models/ccds-resource-filter.ts diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.html b/src/app/components/resources/resources-table-container/resources-table-container.component.html index a4f3e12..26b201c 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.html +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.html @@ -26,8 +26,8 @@ Search Parameters Supported -

{{param.name}}

-

{{param.type}}

+

Param name: {{param.name}}

+

Param type: {{param.type}}

{{param.documentation}}
@@ -52,7 +52,7 @@

{{param.name}}

- + \ No newline at end of file diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.ts b/src/app/components/resources/resources-table-container/resources-table-container.component.ts index c17bbf0..20a505a 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.ts +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.ts @@ -72,6 +72,7 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { private _unsubscribe = new Subject(); private readonly _lastUpdatedParam = '_lastUpdated'; + private note: string; constructor( private _helperService: HelperService, @@ -156,9 +157,12 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { this.resources = response.data; if (!!environment.showCCDSResourceMenuInstead && !!response.data && !!response.data.total) { - let responseDataCopy = this._helperService.clone(response.data) + let responseDataCopy = this._helperService.clone(response.data); // filter the results - responseDataCopy.entry = responseDataCopy.entry.filter(this.ccdsResourceType.SearchSetFilter); + if (this.ccdsResourceType.SearchSetFilter != null) { + this.note = this.ccdsResourceType.SearchSetFilter.FilterNote; + responseDataCopy.entry = responseDataCopy.entry.filter(this.ccdsResourceType.SearchSetFilter.Filter); + } this.resources = responseDataCopy; } this.error = null; diff --git a/src/app/components/resources/resources-table/resources-table.component.html b/src/app/components/resources/resources-table/resources-table.component.html index 69e6bc8..3f8d514 100644 --- a/src/app/components/resources/resources-table/resources-table.component.html +++ b/src/app/components/resources/resources-table/resources-table.component.html @@ -3,7 +3,7 @@
Total Number of resources on the Server:{{bundle.total}}
Number of resources returned by the Query:{{bundle.entry.length}}
-
The result set has been filtered to show items relevant to the selected CCDS type.
+
{{note}}
diff --git a/src/app/components/resources/resources-table/resources-table.component.ts b/src/app/components/resources/resources-table/resources-table.component.ts index 0c8e3ae..66162c5 100644 --- a/src/app/components/resources/resources-table/resources-table.component.ts +++ b/src/app/components/resources/resources-table/resources-table.component.ts @@ -18,11 +18,16 @@ export class ResourcesTableComponent implements OnInit { */ @Input() resourceType: string; + /** + * Note to display + */ + @Input() note: string; + /** * variable to hold the environment.showCCDSResourceMenuInstead value. */ - isCCDSResourceMenuEnabled: boolean + isCCDSResourceMenuEnabled: boolean; constructor() { } diff --git a/src/app/data/ccds-resource-filters.ts b/src/app/data/ccds-resource-filters.ts new file mode 100644 index 0000000..1f69eae --- /dev/null +++ b/src/app/data/ccds-resource-filters.ts @@ -0,0 +1,91 @@ +import { _getOptionScrollPosition } from '@angular/material'; +import { ResourceFilter } from '../models/ccds-resource-filter'; + +export class ProblemFilter implements ResourceFilter { + static filterOptions = [ + { + System: 'http://hl7.org/fhir/condition-clinical', + Code: 'problem', + }, + ]; + + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.'; + + Filter(singleResourceEntry: any): boolean { + let found = false; + ProblemFilter.filterOptions.forEach(filter => { + if (singleResourceEntry.resource.category.some((categoryEntry: any) => { + return ( + categoryEntry.coding[0].system.toLowerCase() === filter.System && + categoryEntry.coding[0].code.toLowerCase() === filter.Code + ); + })) { + found = true; + return true; + } + }); + return found; + } +} + +export class HealthConcernFilter implements ResourceFilter { + static filterOptions = [ + { + System: 'http://hl7.org/fhir/us/core/codesystem/condition-category', + Code: 'health-concern', + }, + ]; + + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.'; + + Filter(singleResourceEntry: any): boolean { + let found = false; + HealthConcernFilter.filterOptions.forEach(filter => { + if (singleResourceEntry.resource.category.some((categoryEntry: any) => { + return ( + categoryEntry.coding[0].system.toLowerCase() === filter.System && + categoryEntry.coding[0].code.toLowerCase() === filter.Code + ); + })) { + found = true; + return true; + } + }); + return found; + } +} + +export class MedicationAllergyFilter implements ResourceFilter { + static filterOptions = [ + { + Url: 'allergentype', + Value: 'med' + }, + ]; + + static urlAllergy = 'https://fhir.chbase.com/fhir/stu3/structureddefinition/allergy'; + + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.'; + + Filter(singleResourceEntry: any): boolean { + let found = false; + MedicationAllergyFilter.filterOptions.forEach(filter => { + if (singleResourceEntry.resource.extension.some((extension: any) => { + return ( + extension.url.toLowerCase() === MedicationAllergyFilter.urlAllergy && + extension.extension && + extension.extension.some((ext: any) => { + return ( + ext.url.toLowerCase() === filter.Url && + ext.valueString.toLowerCase() === filter.Value + ); + }) + ); + })) { + found = true; + return true; + } + }); + return found; + } +} diff --git a/src/app/data/ccds-resources.ts b/src/app/data/ccds-resources.ts index bfb28b7..18d1796 100644 --- a/src/app/data/ccds-resources.ts +++ b/src/app/data/ccds-resources.ts @@ -1,185 +1,109 @@ -import { CCDSResourceMapping } from "../models/ccds-resource"; +import { CCDSResourceMapping } from '../models/ccds-resource'; +import { HealthConcernFilter, MedicationAllergyFilter, ProblemFilter } from './ccds-resource-filters'; export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ { - CCDSType : "Patient Name", - FhirResource : "Patient", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Patient Name', + FhirResource: 'Patient', + SearchQueryParameters: {}, }, { - CCDSType : "Sex", - FhirResource : "Patient", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter - },{ - CCDSType : "Date of Birth", - FhirResource : "Patient", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Sex', + FhirResource: 'Patient', + SearchQueryParameters: {}, + }, { + CCDSType: 'Date of Birth', + FhirResource: 'Patient', + SearchQueryParameters: {}, }, { - CCDSType : "Race", - FhirResource : "Patient", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Race', + FhirResource: 'Patient', + SearchQueryParameters: {}, }, { - CCDSType : "Ethnicity", - FhirResource : "Patient", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Ethnicity', + FhirResource: 'Patient', + SearchQueryParameters: {}, }, { - CCDSType : "Preferred language", - FhirResource : "Patient", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Preferred language', + FhirResource: 'Patient', + SearchQueryParameters: {}, }, { - CCDSType : "Smoking Status", - FhirResource : "Observation", - SearchQueryParameters : {"code" : "http://loinc.org|72166-2"}, - SearchSetFilter : defaultFilter + CCDSType: 'Smoking Status', + FhirResource: 'Observation', + SearchQueryParameters: { 'code': 'http://loinc.org|72166-2' }, }, { - CCDSType : "Problems", - FhirResource : "Condition", - SearchQueryParameters : {}, - SearchSetFilter : problemFilter + CCDSType: 'Problems', + FhirResource: 'Condition', + SearchQueryParameters: {}, + SearchSetFilter: new ProblemFilter() }, { - CCDSType : "Medications", - FhirResource : "MedicationStatement", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Medications', + FhirResource: 'MedicationStatement', + SearchQueryParameters: {}, }, { - CCDSType : "Medication Allergies", - FhirResource : "AllergyIntolerance", - SearchQueryParameters : {}, - SearchSetFilter : medicationAllergyFilter + CCDSType: 'Medication Allergies', + FhirResource: 'AllergyIntolerance', + SearchQueryParameters: {}, + SearchSetFilter: new MedicationAllergyFilter() }, { - CCDSType : "Lab Tests", - FhirResource : "DiagnosticReport", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Lab Tests', + FhirResource: 'DiagnosticReport', + SearchQueryParameters: {}, }, { - CCDSType : "Lab Values/Results", - FhirResource : "DiagnosticReport", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Lab Values/Results', + FhirResource: 'DiagnosticReport', + SearchQueryParameters: {}, }, { - CCDSType : "Vital Signs", - FhirResource : "Observation", - SearchQueryParameters : { - "code" : "http://loinc.org|85353-1,http://loinc.org|8867-4,http://loinc.org|8302-2,http://loinc.org|8306-3,http://loinc.org|29463-7,http://loinc.org|85354-9,http://loinc.org|8480-6,http://loinc.org|8462-4"}, - SearchSetFilter : defaultFilter + CCDSType: 'Vital Signs', + FhirResource: 'Observation', + SearchQueryParameters: { + 'code': 'http://loinc.org|85353-1,http://loinc.org|8867-4,http://loinc.org|8302-2,http://loinc.org|8306-3,http://loinc.org|29463-7,http://loinc.org|85354-9,http://loinc.org|8480-6,http://loinc.org|8462-4' + }, }, { - CCDSType : "Procedures", - FhirResource : "Procedure", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Procedures', + FhirResource: 'Procedure', + SearchQueryParameters: {}, }, { - CCDSType : "Care team Members", - FhirResource : "CareTeam", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Care team Members', + FhirResource: 'CareTeam', + SearchQueryParameters: {}, }, { - CCDSType : "Immunizations", - FhirResource : "Immunization", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Immunizations', + FhirResource: 'Immunization', + SearchQueryParameters: {}, }, { - CCDSType : "Unique Device Identifiers", - FhirResource : "Device", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Unique Device Identifiers', + FhirResource: 'Device', + SearchQueryParameters: {}, }, { - CCDSType : "Assessment and Plan of Treatment", - FhirResource : "CarePlan", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Assessment and Plan of Treatment', + FhirResource: 'CarePlan', + SearchQueryParameters: {}, }, { - CCDSType : "Goals", - FhirResource : "Goal", - SearchQueryParameters : {}, - SearchSetFilter : defaultFilter + CCDSType: 'Goals', + FhirResource: 'Goal', + SearchQueryParameters: {}, }, { - CCDSType : "Health Concerns", - FhirResource : "Condition", - SearchQueryParameters : {}, - SearchSetFilter : healthConcernFilter + CCDSType: 'Health Concerns', + FhirResource: 'Condition', + SearchQueryParameters: {}, + SearchSetFilter: new HealthConcernFilter() } -] - -function defaultFilter(singleResourceEntry: any): boolean { - return true; - } - -function medicationAllergyFilter(singleResourceEntry: any): boolean { - if (!singleResourceEntry.resource.extension.some((extension: any) => { - return (extension.url.toLowerCase() === "https://fhir.chbase.com/fhir/stu3/structureddefinition/allergy" && - extension.extension[0].url.toLowerCase() === "allergentype" && - extension.extension[0].valueString.toLowerCase() === "med"); - })) - { - return false; - } - return true; -} - -function problemFilter(singleResourceEntry: any): boolean { - // "category": [ - // { - // "coding": [ - // { - // "system": "http://hl7.org/fhir/condition-clinical", - // "code": "problem", - // "display": "Problem" - // } - // ] - // } - // ], - if (!singleResourceEntry.resource.category.some((categoryEntry: any) => { - return (categoryEntry.coding[0].system.toLowerCase() === "http://hl7.org/fhir/condition-clinical" && - categoryEntry.coding[0].code.toLowerCase() === "problem" ); - })) - { - return false; - } - return true; -} - - -function healthConcernFilter(singleResourceEntry: any): boolean { - // "category": [ - // { - // "coding": [ - // { - // "system": "http://hl7.org/fhir/us/core/CodeSystem/condition-category", - // "code": "health-concern", - // "display": "Health Concern" - // } - // ] - // } - // ], - if (!singleResourceEntry.resource.category.some((categoryEntry: any) => { - return (categoryEntry.coding[0].system.toLowerCase() === "http://hl7.org/fhir/us/core/codesystem/condition-category" && - categoryEntry.coding[0].code.toLowerCase() === "health-concern" ); - })) - { - return false; - } - return true; -} \ No newline at end of file +]; diff --git a/src/app/models/ccds-resource-filter.ts b/src/app/models/ccds-resource-filter.ts new file mode 100644 index 0000000..558ad78 --- /dev/null +++ b/src/app/models/ccds-resource-filter.ts @@ -0,0 +1,7 @@ +export interface ResourceFilter { + + FilterNote?: string; + + Filter(singleResourceEntry: any): boolean; + +} diff --git a/src/app/models/ccds-resource.ts b/src/app/models/ccds-resource.ts index f3f1c3a..484752b 100644 --- a/src/app/models/ccds-resource.ts +++ b/src/app/models/ccds-resource.ts @@ -1,3 +1,5 @@ +import { ResourceFilter } from './ccds-resource-filter'; + /** * Object to hold mapping between a CCDS datatype and the equivalent FHIR resource */ @@ -6,7 +8,7 @@ export interface CCDSResourceMapping { * Name of the CCDS datatype. */ CCDSType: string; - + /** * FHIR Resource this CCDSType maps to. */ @@ -20,6 +22,6 @@ export interface CCDSResourceMapping { /** * If query parameters are not possbile, add filters that need to be applied to resource responses. */ - SearchSetFilter(singleResourceEntry: any): boolean; + SearchSetFilter?: ResourceFilter; -} \ No newline at end of file +} From 547fa9ea186221d4019e384f6aa49da5f5261f07 Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Mon, 5 Oct 2020 09:31:39 -0400 Subject: [PATCH 7/9] Filters modified for Problem & Health Concern - Filter warning specific to resource type --- .../resources-table-container.component.ts | 4 ++-- .../resources-table/resources-table.component.html | 2 +- src/app/data/ccds-resource-filters.ts | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/components/resources/resources-table-container/resources-table-container.component.ts b/src/app/components/resources/resources-table-container/resources-table-container.component.ts index 20a505a..7e50bf6 100644 --- a/src/app/components/resources/resources-table-container/resources-table-container.component.ts +++ b/src/app/components/resources/resources-table-container/resources-table-container.component.ts @@ -226,12 +226,12 @@ export class ResourcesTableContainerComponent implements OnInit, OnDestroy { if (!this.useSpecificDateParam && !!startDate) { if (!dateParams) dateParams = {}; - dateParams['$ge'] = startDate; + dateParams['$gt'] = startDate; } if (!this.useSpecificDateParam && !!endDate) { if (!dateParams) dateParams = {}; - dateParams['$le'] = endDate; + dateParams['$lt'] = endDate; } if (!!dateParams) diff --git a/src/app/components/resources/resources-table/resources-table.component.html b/src/app/components/resources/resources-table/resources-table.component.html index 3f8d514..03c26a7 100644 --- a/src/app/components/resources/resources-table/resources-table.component.html +++ b/src/app/components/resources/resources-table/resources-table.component.html @@ -3,7 +3,7 @@
Total Number of resources on the Server:{{bundle.total}}
Number of resources returned by the Query:{{bundle.entry.length}}
-
{{note}}
+
diff --git a/src/app/data/ccds-resource-filters.ts b/src/app/data/ccds-resource-filters.ts index 1f69eae..e6e4600 100644 --- a/src/app/data/ccds-resource-filters.ts +++ b/src/app/data/ccds-resource-filters.ts @@ -4,12 +4,13 @@ import { ResourceFilter } from '../models/ccds-resource-filter'; export class ProblemFilter implements ResourceFilter { static filterOptions = [ { - System: 'http://hl7.org/fhir/condition-clinical', - Code: 'problem', + System: 'http://hl7.org/fhir/condition-category', + Code: 'problem-list-item', }, ]; - FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.'; + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.
' + + 'Filter used: http://hl7.org/fhir/condition-category|problem-list-item'; Filter(singleResourceEntry: any): boolean { let found = false; @@ -36,7 +37,8 @@ export class HealthConcernFilter implements ResourceFilter { }, ]; - FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.'; + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.
' + + 'Filter used: http://hl7.org/fhir/us/core/codesystem/condition-category|health-concern'; Filter(singleResourceEntry: any): boolean { let found = false; @@ -65,7 +67,8 @@ export class MedicationAllergyFilter implements ResourceFilter { static urlAllergy = 'https://fhir.chbase.com/fhir/stu3/structureddefinition/allergy'; - FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.'; + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.
' + + 'Filter used: allergentype = "med"'; Filter(singleResourceEntry: any): boolean { let found = false; From 3f350f2a93830557e5281f7d6a84b78340f04d39 Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Wed, 7 Oct 2020 01:49:44 -0400 Subject: [PATCH 8/9] Filter modified for Medication allergy --- src/app/data/ccds-resource-filters.ts | 42 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/app/data/ccds-resource-filters.ts b/src/app/data/ccds-resource-filters.ts index e6e4600..8d4658c 100644 --- a/src/app/data/ccds-resource-filters.ts +++ b/src/app/data/ccds-resource-filters.ts @@ -59,6 +59,9 @@ export class HealthConcernFilter implements ResourceFilter { export class MedicationAllergyFilter implements ResourceFilter { static filterOptions = [ + { + Category: 'medication' + }, { Url: 'allergentype', Value: 'med' @@ -68,25 +71,34 @@ export class MedicationAllergyFilter implements ResourceFilter { static urlAllergy = 'https://fhir.chbase.com/fhir/stu3/structureddefinition/allergy'; FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.
' - + 'Filter used: allergentype = "med"'; + + 'Filter used: category = "medication" or allergentype = "med"'; Filter(singleResourceEntry: any): boolean { let found = false; MedicationAllergyFilter.filterOptions.forEach(filter => { - if (singleResourceEntry.resource.extension.some((extension: any) => { - return ( - extension.url.toLowerCase() === MedicationAllergyFilter.urlAllergy && - extension.extension && - extension.extension.some((ext: any) => { - return ( - ext.url.toLowerCase() === filter.Url && - ext.valueString.toLowerCase() === filter.Value - ); - }) - ); - })) { - found = true; - return true; + if (filter.Category) { + if (singleResourceEntry.resource.category && + singleResourceEntry.resource.category.includes(filter.Category)) { + found = true; + return; + } + } + if (filter.Url) { + if (singleResourceEntry.resource.extension.some((extension: any) => { + return ( + extension.url.toLowerCase() === MedicationAllergyFilter.urlAllergy && + extension.extension && + extension.extension.some((ext: any) => { + return ( + ext.url.toLowerCase() === filter.Url && + ext.valueString.toLowerCase() === filter.Value + ); + }) + ); + })) { + found = true; + return; + } } }); return found; From eecd33f3b1d1afdbf7afcc1d857a65cd94471fca Mon Sep 17 00:00:00 2001 From: Aswin V P Date: Mon, 2 Nov 2020 14:47:08 +0530 Subject: [PATCH 9/9] Add a new tab named "Encounter Diagnosis" to display that type of conditions SpO2 (59408-5) Included in Vital signs. CHBASE-3867,CHBASE-3868 --- src/app/data/ccds-resource-filters.ts | 28 +++++++++++++++++++++++++++ src/app/data/ccds-resources.ts | 10 ++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/app/data/ccds-resource-filters.ts b/src/app/data/ccds-resource-filters.ts index 8d4658c..a2d3d41 100644 --- a/src/app/data/ccds-resource-filters.ts +++ b/src/app/data/ccds-resource-filters.ts @@ -104,3 +104,31 @@ export class MedicationAllergyFilter implements ResourceFilter { return found; } } + +export class EncounterDiagnosisFilter implements ResourceFilter { + static filterOptions = [ + { + System: 'http://hl7.org/fhir/condition-category', + Code: 'encounter-diagnosis', + }, + ]; + + FilterNote = 'The result set has been filtered to show items relevant to the selected CCDS type.
' + + 'Filter used: http://hl7.org/fhir/condition-category|encounter-diagnosis'; + + Filter(singleResourceEntry: any): boolean { + let found = false; + EncounterDiagnosisFilter.filterOptions.forEach(filter => { + if (singleResourceEntry.resource.category.some((categoryEntry: any) => { + return ( + categoryEntry.coding[0].system.toLowerCase() === filter.System && + categoryEntry.coding[0].code.toLowerCase() === filter.Code + ); + })) { + found = true; + return true; + } + }); + return found; + } +} \ No newline at end of file diff --git a/src/app/data/ccds-resources.ts b/src/app/data/ccds-resources.ts index 18d1796..7a2ced4 100644 --- a/src/app/data/ccds-resources.ts +++ b/src/app/data/ccds-resources.ts @@ -1,5 +1,5 @@ import { CCDSResourceMapping } from '../models/ccds-resource'; -import { HealthConcernFilter, MedicationAllergyFilter, ProblemFilter } from './ccds-resource-filters'; +import { EncounterDiagnosisFilter, HealthConcernFilter, MedicationAllergyFilter, ProblemFilter } from './ccds-resource-filters'; export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ { @@ -67,7 +67,7 @@ export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ CCDSType: 'Vital Signs', FhirResource: 'Observation', SearchQueryParameters: { - 'code': 'http://loinc.org|85353-1,http://loinc.org|8867-4,http://loinc.org|8302-2,http://loinc.org|8306-3,http://loinc.org|29463-7,http://loinc.org|85354-9,http://loinc.org|8480-6,http://loinc.org|8462-4' + 'code': 'http://loinc.org|85353-1,http://loinc.org|8867-4,http://loinc.org|8302-2,http://loinc.org|8306-3,http://loinc.org|29463-7,http://loinc.org|85354-9,http://loinc.org|8480-6,http://loinc.org|8462-4,http://loinc.org|59408-5' }, }, { @@ -105,5 +105,11 @@ export const CCDS_RESOURCE_MAPPING: CCDSResourceMapping[] = [ FhirResource: 'Condition', SearchQueryParameters: {}, SearchSetFilter: new HealthConcernFilter() + }, + { + CCDSType: 'Encounter Diagnosis', + FhirResource: 'Condition', + SearchQueryParameters: {}, + SearchSetFilter: new EncounterDiagnosisFilter() } ];