Skip to content

Commit

Permalink
fix: code cache fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang committed Dec 3, 2024
1 parent bc5834e commit d8fb2a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ const buildLabelObjectFilter = (

const unbuildLabelObjectFilterValue = (values: string | null, prevValues: LabelObject[] | null) => {
const valuesIds = values?.split(',') || []
const newArray = valuesIds?.map((value) => (value.includes('|*') ? { id: '*', label: '' } : { id: value, label: '' }))
const newArray = valuesIds?.map((value) => {
const valueElements = value.split('|')
if (valueElements.length > 1) {
return { id: valueElements[1], system: valueElements[0], label: '' }
}
return { id: valueElements[0], label: '' }
})
if (newArray) {
return [...(prevValues || []), ...newArray]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export const form: () => CriteriaForm<ObservationDataType> = () => ({
buildInfo: {
fhirKey: ObservationParamsKeys.ANABIO_LOINC,
buildMethodExtraArgs: [
{ type: 'string', value: getConfig().features.observation.valueSets.biologyHierarchyAnabio.url }
{ type: 'string', value: getConfig().features.observation.valueSets.biologyHierarchyAnabio.url },
{ type: 'boolean', value: true }
]
}
},
Expand Down
14 changes: 10 additions & 4 deletions src/utils/cohortCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,16 @@ export const fetchCriteriasCodes = async (
const codeSystem = code.system || defaultValueSet
const valueSetCodeCache = updatedCriteriaData[codeSystem] ?? []
if (!valueSetCodeCache.find((data) => data.id === code.id)) {
const fetchedCode = (await fetchValueSet(codeSystem, {
code: code.id || ''
})) as LabelObject[]
valueSetCodeCache.push(...fetchedCode)
try {
const fetchedCode = (await fetchValueSet(codeSystem, {
search: code.id || '',
noStar: true
})) as LabelObject[]
valueSetCodeCache.push(...fetchedCode)
} catch (e) {
// fail silently
console.error(`Error fetching code ${code.id} from system ${codeSystem}`, e)
}
}
updatedCriteriaData[codeSystem] = valueSetCodeCache
}
Expand Down

0 comments on commit d8fb2a8

Please sign in to comment.