diff --git a/src/services/aphp/callApi.ts b/src/services/aphp/callApi.ts index afb49b6c7..d6208e25d 100644 --- a/src/services/aphp/callApi.ts +++ b/src/services/aphp/callApi.ts @@ -80,7 +80,7 @@ type fetchPatientProps = { minBirthdate?: number maxBirthdate?: number searchBy?: string - _text?: string | string[] + _text?: string deceased?: boolean pivotFacet?: ('age-month_gender' | 'deceased_gender')[] _elements?: ('id' | 'gender' | 'name' | 'birthDate' | 'deceased' | 'identifier' | 'extension')[] @@ -117,14 +117,7 @@ export const fetchPatient = async (args: fetchPatientProps): FHIR_Bundle_Promise if (offset) options = [...options, `_offset=${offset}`] if (_sort) options = [...options, `_sort=${_sortDirection}${_sort}`] if (gender) options = [...options, `gender=${gender}`] - if (_text && _text.length > 0) { - if (Array.isArray(_text)) { - const searchInput = _text.map((text) => `${searchBy}=${encodeURIComponent(`"${text}"`)}`).join('&') - options = [...options, searchInput] - } else { - options = [...options, `${searchBy}=${_text}`] - } - } + if (_text) options = [...options, `${searchBy}=${_text}`] if (deceased !== undefined) options = [...options, `deceased=${deceased}`] if (minBirthdate) options = [...options, `${deidentified ? 'age-month' : 'age-day'}=ge${minBirthdate}`] if (maxBirthdate) options = [...options, `${deidentified ? 'age-month' : 'age-day'}=le${maxBirthdate}`] @@ -955,13 +948,9 @@ const getCodeList = async ( // if search is * then we fetch the roots of the valueSet if (search !== '*' && search !== undefined) { // if noStar is true then we search for the code, else we search for the display - searchParam = noStar - ? `&only-roots=false&code=${encodeURIComponent( - search.trim().replace(/[\[\]\/\{\}\(\)\*\?\.\\\^\$\|]/g, '\\$&') //eslint-disable-line - )}` - : `&only-roots=false&_text=${encodeURIComponent( - search.trim().replace(/[\[\]\/\{\}\(\)\*\?\.\\\^\$\|]/g, '\\$&') //eslint-disable-line - )}*` + searchParam = `&only-roots=false&${noStar ? 'code' : '_tag=text-search-rank&_text'}=${encodeURIComponent( + search.trim() + )}` } // TODO test if it returns all the codes without specifying the count const res = await apiFhir.get>(`/ValueSet?reference=${codeSystem}${searchParam}`, { diff --git a/src/services/aphp/cohortCreation/fetchObservation.ts b/src/services/aphp/cohortCreation/fetchObservation.ts index 3e797b5f3..3c537f9b9 100644 --- a/src/services/aphp/cohortCreation/fetchObservation.ts +++ b/src/services/aphp/cohortCreation/fetchObservation.ts @@ -26,16 +26,6 @@ export const fetchBiologySearch = async ( const res = await apiFhir.get>( `/ConceptMap?_count=2000&name=Maps%20to,Concept%20Fhir%20Maps%20To&source-system=${BIOLOGY_HIERARCHY_ITM_ANABIO}&target-system=${BIOLOGY_HIERARCHY_ITM_ANABIO},${BIOLOGY_HIERARCHY_ITM_LOINC}&_text=${encodeURIComponent( lowerCaseTrimmedSearchInput.replace(/[\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') // eslint-disable-line - )},${encodeURIComponent( - `/(.)*${lowerCaseTrimmedSearchInput.replace(/[/"]/g, function (m) { - switch (m) { - case '/': - return '\\/' - case '"': - return '\\"' - } - return m - })}(.)*/` )}` ) diff --git a/src/services/aphp/serviceCohorts.ts b/src/services/aphp/serviceCohorts.ts index e72c67057..960f275dd 100644 --- a/src/services/aphp/serviceCohorts.ts +++ b/src/services/aphp/serviceCohorts.ts @@ -331,16 +331,6 @@ const servicesCohorts: IServiceCohorts = { signal ) => { try { - let _searchInput: string | string[] = '' - _searchInput = searchInput - .trim() // Remove space before/after search - .split(' ') // Split by space (= ['mot1', 'mot2' ...]) - .filter((elem: string) => elem) // Filter if you have ['mot1', '', 'mot2'] (double space) - - if (searchBy === SearchByTypes.IDENTIFIER) { - _searchInput = _searchInput.join() - } - // convert birthdates into days or months depending of if it's a deidentified perimeter or not const birthdates: [string, string] = [ moment(substructAgeString(filters?.birthdatesRanges?.[0] || '')).format('MM/DD/YYYY'), @@ -359,7 +349,7 @@ const servicesCohorts: IServiceCohorts = { _list: groupId ? [groupId] : [], gender: filters && filters.genders.join(','), searchBy, - _text: _searchInput, + _text: searchInput.trim(), minBirthdate: minBirthdate, maxBirthdate: maxBirthdate, deceased: diff --git a/src/state/patient.ts b/src/state/patient.ts index 9fcfe0ef2..51e0fa3dc 100644 --- a/src/state/patient.ts +++ b/src/state/patient.ts @@ -115,7 +115,6 @@ const fetchPmsi = createAsyncThunk