adding support for terminiology server.

This commit is contained in:
Jason Kulatunga 2023-03-06 07:59:28 -08:00
parent f5b0fb59d7
commit 0fa4e78e06
No known key found for this signature in database
3 changed files with 46 additions and 5 deletions

View File

@ -21,6 +21,7 @@ export enum NlmSearchType {
Procedure = 'Procedure', Procedure = 'Procedure',
Vaccine = 'Vaccine', Vaccine = 'Vaccine',
Countries = 'Countries',
PrePopulated = 'PrePopulated' PrePopulated = 'PrePopulated'
} }
@ -44,8 +45,10 @@ export enum NlmSearchType {
}) })
export class NlmTypeaheadComponent implements ControlValueAccessor { export class NlmTypeaheadComponent implements ControlValueAccessor {
@Input() searchType: NlmSearchType = NlmSearchType.Condition; @Input() searchType: NlmSearchType = NlmSearchType.Condition;
@Input() debugMode: Boolean = false; @Input() debugMode: Boolean = false; //if true, will show the debug panel
@Input() openOnFocus: Boolean = false; @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[] = [] @Input() prePopulatedOptions: NlmSearchResults[] = []
@ViewChild('instance', { static: true }) instance: NgbTypeahead; @ViewChild('instance', { static: true }) instance: NgbTypeahead;
@ -79,6 +82,11 @@ export class NlmTypeaheadComponent implements ControlValueAccessor {
case NlmSearchType.Condition: case NlmSearchType.Condition:
searchOpFn = this.nlmClinicalTableSearchService.searchCondition searchOpFn = this.nlmClinicalTableSearchService.searchCondition
break break
case NlmSearchType.Countries:
searchOpFn = this.nlmClinicalTableSearchService.searchCountries
this.idResult = true
this.editable = false
break
case NlmSearchType.MedicalContactIndividualProfession: case NlmSearchType.MedicalContactIndividualProfession:
searchOpFn = this.nlmClinicalTableSearchService.searchMedicalContactIndividualProfession searchOpFn = this.nlmClinicalTableSearchService.searchMedicalContactIndividualProfession
this.openOnFocus = true this.openOnFocus = true
@ -151,13 +159,23 @@ export class NlmTypeaheadComponent implements ControlValueAccessor {
this.markAsTouched() this.markAsTouched()
console.log("bubbling modelChange event", event) console.log("bubbling modelChange event", event)
if(typeof event === 'string'){ if(typeof event === 'string'){
if(this.idResult){
this.onChange(null);
return
}
if (event.length === 0) { if (event.length === 0) {
this.onChange(null); this.onChange(null);
} else { } else {
this.onChange({text: event}); this.onChange({text: event});
} }
} else{ } else{
this.onChange(event); if(this.idResult){
this.onChange(event.id);
return
}
else {
this.onChange(event);
}
} }
} }

View File

@ -457,7 +457,7 @@
</div><!-- col --> </div><!-- col -->
<div class="col-6 mg-t-10 mg-lg-t-0"> <div class="col-6 mg-t-10 mg-lg-t-0">
<p class="mg-b-10">Country</p> <p class="mg-b-10">Country</p>
<input formControlName="country" class="form-control" placeholder="Country" type="text"> <app-nlm-typeahead formControlName="country" searchType="Countries" [debugMode]="debugMode"></app-nlm-typeahead>
</div><!-- col --> </div><!-- col -->
</ng-container> </ng-container>
</ng-container> </ng-container>
@ -531,7 +531,7 @@
</div><!-- col --> </div><!-- col -->
<div class="col-6 mg-t-10 mg-lg-t-0"> <div class="col-6 mg-t-10 mg-lg-t-0">
<p class="mg-b-10">Country</p> <p class="mg-b-10">Country</p>
<input formControlName="country" class="form-control" placeholder="Country" type="text"> <app-nlm-typeahead formControlName="country" searchType="Countries" [debugMode]="debugMode"></app-nlm-typeahead>
</div><!-- col --> </div><!-- col -->
</ng-container> </ng-container>
</ng-container> </ng-container>

View File

@ -1200,6 +1200,29 @@ export class NlmClinicalTableSearchService {
return of(result) return of(result)
} }
searchCountries(searchTerm: string): Observable<NlmSearchResults[]> {
//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<any>(`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<NlmSearchResults[]> { searchWikipediaType(searchTerm: string): Observable<NlmSearchResults[]> {
let queryParams = { let queryParams = {