Skip to content

Commit

Permalink
Complete scenario 3 for radiology POC
Browse files Browse the repository at this point in the history
  • Loading branch information
fongsean committed Jun 17, 2024
1 parent 2b1d654 commit 0701a4d
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 96 deletions.
29 changes: 20 additions & 9 deletions packages/smart-forms-renderer/src/hooks/useValueSetCodings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ function useValueSetCodings(
}, [cachedValueSetCodings, processedValueSetCodings, valueSetUrl]);

// Attempt to get codings from answer expression
const answerExpression = getAnswerExpression(qItem)?.expression;
const qItemAnswerExpression = getAnswerExpression(qItem)?.expression;
initialCodings = useMemo(() => {
if (initialCodings.length === 0 && answerExpression) {
const variable = answerExpression.substring(
answerExpression.indexOf('%') + 1,
answerExpression.indexOf('.')
if (initialCodings.length === 0 && qItemAnswerExpression) {
const variable = qItemAnswerExpression.substring(
qItemAnswerExpression.indexOf('%') + 1,
qItemAnswerExpression.indexOf('.')
);
const contextMap: Record<string, FhirResource> = {};

Expand All @@ -104,7 +104,7 @@ function useValueSetCodings(
try {
const evaluated: any[] = fhirpath.evaluate(
{},
answerExpression,
qItemAnswerExpression,
contextMap,
fhirpath_r4_model
);
Expand All @@ -124,7 +124,7 @@ function useValueSetCodings(

return initialCodings;
}, [
answerExpression,
qItemAnswerExpression,
encounter,
initialCodings,
launchContexts,
Expand All @@ -137,6 +137,7 @@ function useValueSetCodings(
const [loading, setLoading] = useState<boolean>(false);
const [serverError, setServerError] = useState<Error | null>(null);

// Use dynamic valueSet via embeddings in contained ValueSet
let dynamicValueSet: DynamicValueSet | null = null;
if (cleanValueSetUrl) {
dynamicValueSet = dynamicValueSets[cleanValueSetUrl];
Expand All @@ -146,8 +147,6 @@ function useValueSetCodings(
return;
}

// Get ValueSet resource from dynamic value set

// dynamicValueSet is not complete
if (!dynamicValueSet.isComplete || !dynamicValueSet.completeResource) {
setCodings([]);
Expand Down Expand Up @@ -197,6 +196,18 @@ function useValueSetCodings(
}
}, [qItem, dynamicValueSet?.version]);

// Instead of using dynamic answerValueSets, use answerExpressions
// useEffect(() => {
// const answerExpression = answerExpressions[qItem.linkId];
//
// if (!answerExpression) {
// return;
// }
//
// console.log('answerExpression____');
// console.log(answerExpression);
// }, [answerExpressions]);

// get options from answerValueSet on render
useEffect(() => {
const valueSetUrl = qItem.answerValueSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export async function evaluateFhirpathAsync(
}

// Evaluate the expression
logMessage(debugAsyncFhirpath, outcome, 'performing iteration: ', iterations);
try {
results = fhirpath.evaluate(fhirData, path, context, model, options);
} catch (err: any) {
Expand All @@ -198,7 +197,6 @@ export async function evaluateFhirpathAsync(
if (iterations > 1) {
logMessage(debugAsyncFhirpath, outcome, 'total iterations', iterations);
}
console.log(outcome);
return results;
}

Expand Down
Loading

0 comments on commit 0701a4d

Please sign in to comment.