From 0fa4e78e066440446a481275d3fa4ee5f33c6f5d Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Mon, 6 Mar 2023 07:59:28 -0800 Subject: [PATCH] adding support for terminiology server. --- .../nlm-typeahead/nlm-typeahead.component.ts | 24 ++++++++++++++++--- .../resource-creator.component.html | 4 ++-- .../nlm-clinical-table-search.service.ts | 23 ++++++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/nlm-typeahead/nlm-typeahead.component.ts b/frontend/src/app/components/nlm-typeahead/nlm-typeahead.component.ts index 3d4705ba..c1f56a30 100644 --- a/frontend/src/app/components/nlm-typeahead/nlm-typeahead.component.ts +++ b/frontend/src/app/components/nlm-typeahead/nlm-typeahead.component.ts @@ -21,6 +21,7 @@ export enum NlmSearchType { Procedure = 'Procedure', Vaccine = 'Vaccine', + Countries = 'Countries', PrePopulated = 'PrePopulated' } @@ -44,8 +45,10 @@ export enum NlmSearchType { }) export class NlmTypeaheadComponent implements ControlValueAccessor { @Input() searchType: NlmSearchType = NlmSearchType.Condition; - @Input() debugMode: Boolean = false; - @Input() openOnFocus: Boolean = false; + @Input() debugMode: Boolean = false; //if true, will show the debug panel + @Input() openOnFocus: Boolean = false; //if true, will display results on focus + @Input() idResult: Boolean = false; //if true, will return the id of the result instead of an object, implies editable = false + @Input() editable: Boolean = true; //if true, will allow the user to enter values not in the list @Input() prePopulatedOptions: NlmSearchResults[] = [] @ViewChild('instance', { static: true }) instance: NgbTypeahead; @@ -79,6 +82,11 @@ export class NlmTypeaheadComponent implements ControlValueAccessor { case NlmSearchType.Condition: searchOpFn = this.nlmClinicalTableSearchService.searchCondition break + case NlmSearchType.Countries: + searchOpFn = this.nlmClinicalTableSearchService.searchCountries + this.idResult = true + this.editable = false + break case NlmSearchType.MedicalContactIndividualProfession: searchOpFn = this.nlmClinicalTableSearchService.searchMedicalContactIndividualProfession this.openOnFocus = true @@ -151,13 +159,23 @@ export class NlmTypeaheadComponent implements ControlValueAccessor { this.markAsTouched() console.log("bubbling modelChange event", event) if(typeof event === 'string'){ + if(this.idResult){ + this.onChange(null); + return + } if (event.length === 0) { this.onChange(null); } else { this.onChange({text: event}); } } else{ - this.onChange(event); + if(this.idResult){ + this.onChange(event.id); + return + } + else { + this.onChange(event); + } } } diff --git a/frontend/src/app/pages/resource-creator/resource-creator.component.html b/frontend/src/app/pages/resource-creator/resource-creator.component.html index 6b3d2f51..c8c8c9d3 100644 --- a/frontend/src/app/pages/resource-creator/resource-creator.component.html +++ b/frontend/src/app/pages/resource-creator/resource-creator.component.html @@ -457,7 +457,7 @@

Country

- +
@@ -531,7 +531,7 @@

Country

- +
diff --git a/frontend/src/app/services/nlm-clinical-table-search.service.ts b/frontend/src/app/services/nlm-clinical-table-search.service.ts index 4a691f70..a7389486 100644 --- a/frontend/src/app/services/nlm-clinical-table-search.service.ts +++ b/frontend/src/app/services/nlm-clinical-table-search.service.ts @@ -1200,6 +1200,29 @@ export class NlmClinicalTableSearchService { return of(result) } + searchCountries(searchTerm: string): Observable { + + //https://tx.fhir.org/r4/ValueSet/$expand?_format=json&filter=Canada&url=http://hl7.org/fhir/ValueSet/iso3166-1-2 + let queryParams = { + '_format': 'json', + 'filter':searchTerm, + 'url': 'http://hl7.org/fhir/ValueSet/iso3166-1-2' + } + + return this._httpClient.get(`https://tx.fhir.org/r4/ValueSet/$expand`, {params: queryParams}) + .pipe( + map((response) => { + + return (response.expansion.contains || []).map((valueSetItem):NlmSearchResults => { + return { + id: valueSetItem.code, + identifier: [valueSetItem], + text: valueSetItem.display, + } + }) + }) + ) + } searchWikipediaType(searchTerm: string): Observable { let queryParams = {