Skip to content

Commit

Permalink
adding support for terminiology server.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Mar 6, 2023
1 parent f5b0fb5 commit 0fa4e78
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum NlmSearchType {
Procedure = 'Procedure',
Vaccine = 'Vaccine',

Countries = 'Countries',
PrePopulated = 'PrePopulated'

}
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ <h4 class="modal-title" id="modal-practitioner">New Practitioner</h4>
</div><!-- col -->
<div class="col-6 mg-t-10 mg-lg-t-0">
<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 -->
</ng-container>
</ng-container>
Expand Down Expand Up @@ -531,7 +531,7 @@ <h4 class="modal-title" id="modal-location">New Location</h4>
</div><!-- col -->
<div class="col-6 mg-t-10 mg-lg-t-0">
<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 -->
</ng-container>
</ng-container>
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/app/services/nlm-clinical-table-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,29 @@ export class NlmClinicalTableSearchService {
return of(result)
}

searchCountries(searchTerm: string): Observable<NlmSearchResults[]> {

//https://tx.fhir.org/r4/ValueSet/$expand?_format=json&filter=Canada&url=http:https://hl7.org/fhir/ValueSet/iso3166-1-2
let queryParams = {
'_format': 'json',
'filter':searchTerm,
'url': 'http:https://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[]> {
let queryParams = {
Expand Down

0 comments on commit 0fa4e78

Please sign in to comment.