Skip to content

Commit 130a2ce

Browse files
committed
Export additional utils
1 parent 55c109a commit 130a2ce

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.0-beta-7
2+
3+
- Export additional utils
4+
15
## 1.0.0-beta.4
26

37
- Clean up empty questionnaire response items

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sdc-qrf",
33
"license": "MIT",
4-
"version": "1.0.0-beta.4",
4+
"version": "1.0.0-beta.7",
55
"scripts": {
66
"test": "vitest --watch=false",
77
"test:watch": "vitest --watch",

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export {
99
parseFhirQueryExpression,
1010
getChecker,
1111
toAnswerValue,
12+
getAnswerValues,
13+
getAnswerValueType,
14+
isAnswerValueEmpty,
1215
populateItemKey,
1316
removeItemKey,
1417
getItemKey,

src/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ export function compareValue(firstAnswerValue: AnswerValue, secondAnswerValue: A
463463
const secondValueType = getAnswerValueType(secondAnswerValue);
464464

465465
if (firstValueType !== secondValueType) {
466-
throw new Error('Enable when must be used for the same type');
466+
throw new Error(
467+
`Enable when must be used for the same type, first type is ${firstValueType}, second type is ${secondValueType}`,
468+
);
467469
}
468470
if (!_.includes(FHIRPrimitiveTypes, firstValueType)) {
469471
throw new Error('Impossible to compare non-primitive type');
@@ -488,7 +490,9 @@ export function isValueEqual(firstValue: AnswerValue, secondValue: AnswerValue)
488490
const secondValueType = getAnswerValueType(secondValue);
489491

490492
if (firstValueType !== secondValueType) {
491-
console.error('Enable when must be used for the same type');
493+
console.error(
494+
`Enable when must be used for the same type, first type is ${firstValueType}, second type is ${secondValueType}`,
495+
);
492496

493497
return false;
494498
}
@@ -863,7 +867,7 @@ export function getAnswerValues(answers: FormAnswerItems[]) {
863867
return _.reject(answers, ({ value }) => isAnswerValueEmpty(value)).map(({ value }) => value!);
864868
}
865869

866-
export function isAnswerValueEmpty(value: { [x: string]: any } | undefined | null) {
870+
export function isAnswerValueEmpty(value: AnswerValue | undefined | null) {
867871
return isValueEmpty(value) || _.every(_.mapValues(value, isValueEmpty));
868872
}
869873

0 commit comments

Comments
 (0)