Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/866 #870

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/smart-forms-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"homepage": "https://github.com/aehrc/smart-forms#readme",
"dependencies": {
"@aehrc/sdc-assemble": "^1.2.0",
"@aehrc/sdc-populate": "^2.2.2",
"@aehrc/smart-forms-renderer": "^0.35.6",
"@aehrc/sdc-populate": "^2.2.3",
"@aehrc/smart-forms-renderer": "^0.35.7",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@fontsource/material-icons": "^5.0.16",
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/sdc-populate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aehrc/sdc-populate",
"version": "2.2.2",
"version": "2.2.3",
"description": "Performs the $populate operation from the HL7 FHIR SDC (Structured Data Capture) specification: http://hl7.org/fhir/uv/sdc",
"main": "lib/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,35 @@ import { checkIsDateTime, checkIsTime, convertDateTimeToDate } from './construct
export function parseItemInitialToAnswer(
initial: QuestionnaireItemInitial
): QuestionnaireResponseItemAnswer | null {
if (initial.valueBoolean) {
if (typeof initial.valueBoolean === 'boolean') {
return { valueBoolean: initial.valueBoolean };
}

if (initial.valueDecimal) {
if (typeof initial.valueDecimal === 'number') {
return { valueDecimal: initial.valueDecimal };
}

if (initial.valueInteger) {
if (typeof initial.valueInteger === 'number') {
return { valueInteger: initial.valueInteger };
}

if (initial.valueDate) {
if (typeof initial.valueDate === 'string') {
return { valueDate: initial.valueDate };
}

if (initial.valueDateTime) {
if (typeof initial.valueDateTime === 'string') {
return { valueDateTime: initial.valueDateTime };
}

if (initial.valueTime) {
if (typeof initial.valueTime === 'string') {
return { valueTime: initial.valueTime };
}

if (initial.valueString) {
if (typeof initial.valueString === 'string') {
return { valueString: initial.valueString };
}

if (initial.valueUri) {
if (typeof initial.valueUri === 'string') {
return { valueUri: initial.valueUri };
}

Expand Down
4 changes: 2 additions & 2 deletions packages/smart-forms-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aehrc/smart-forms-renderer",
"version": "0.35.6",
"version": "0.35.7",
"description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
"main": "lib/index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
},
"homepage": "https://github.com/aehrc/smart-forms#readme",
"dependencies": {
"@aehrc/sdc-populate": "^2.2.2",
"@aehrc/sdc-populate": "^2.2.3",
"@iconify/react": "^4.1.1",
"dayjs": "^1.11.10",
"deep-diff": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ function BooleanItem(props: BooleanItemProps) {

const readOnly = useReadOnly(qItem, parentIsReadOnly);

const valueBoolean = qrItem?.answer && qrItem.answer[0].valueBoolean;
let valueBoolean: boolean | undefined = undefined;
if (qrItem?.answer?.[0]?.valueBoolean !== undefined) {
valueBoolean = qrItem.answer[0].valueBoolean;
}

// Process calculated expressions
const { calcExpUpdated } = useBooleanCalculatedExpression({
Expand Down
54 changes: 27 additions & 27 deletions packages/smart-forms-renderer/src/utils/initialise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function getInitialValueAnswers(qItem: QuestionnaireItem): QuestionnaireResponse
}

return initialValues
.map((initialValue) => initialValueSwitcher(initialValue))
.map((initialValue) => parseItemInitialToAnswer(initialValue))
.filter((item): item is QuestionnaireResponseItemAnswer => item !== null);
}

Expand All @@ -231,55 +231,55 @@ function getInitialValueAnswersFromRepeatGroup(qItem: QuestionnaireItem) {
.filter((childQRItem) => childQRItem.answer && childQRItem.answer.length > 0);
}

function initialValueSwitcher(
initialValue: QuestionnaireItemInitial
export function parseItemInitialToAnswer(
initial: QuestionnaireItemInitial
): QuestionnaireResponseItemAnswer | null {
if (initialValue.valueBoolean) {
return { valueBoolean: initialValue.valueBoolean };
if (typeof initial.valueBoolean === 'boolean') {
return { valueBoolean: initial.valueBoolean };
}

if (initialValue.valueDecimal) {
return { valueDecimal: initialValue.valueDecimal };
if (typeof initial.valueDecimal === 'number') {
return { valueDecimal: initial.valueDecimal };
}

if (initialValue.valueInteger) {
return { valueInteger: initialValue.valueInteger };
if (typeof initial.valueInteger === 'number') {
return { valueInteger: initial.valueInteger };
}

if (initialValue.valueDate) {
return { valueDate: initialValue.valueDate };
if (typeof initial.valueDate === 'string') {
return { valueDate: initial.valueDate };
}

if (initialValue.valueDateTime) {
return { valueDateTime: initialValue.valueDateTime };
if (typeof initial.valueDateTime === 'string') {
return { valueDateTime: initial.valueDateTime };
}

if (initialValue.valueTime) {
return { valueTime: initialValue.valueTime };
if (typeof initial.valueTime === 'string') {
return { valueTime: initial.valueTime };
}

if (initialValue.valueString) {
return { valueString: initialValue.valueString };
if (typeof initial.valueString === 'string') {
return { valueString: initial.valueString };
}

if (initialValue.valueUri) {
return { valueUri: initialValue.valueUri };
if (typeof initial.valueUri === 'string') {
return { valueUri: initial.valueUri };
}

if (initialValue.valueAttachment) {
return { valueAttachment: initialValue.valueAttachment };
if (initial.valueAttachment) {
return { valueAttachment: initial.valueAttachment };
}

if (initialValue.valueCoding) {
return { valueCoding: initialValue.valueCoding };
if (initial.valueCoding) {
return { valueCoding: initial.valueCoding };
}

if (initialValue.valueQuantity) {
return { valueQuantity: initialValue.valueQuantity };
if (initial.valueQuantity) {
return { valueQuantity: initial.valueQuantity };
}

if (initialValue.valueReference) {
return { valueReference: initialValue.valueReference };
if (initial.valueReference) {
return { valueReference: initial.valueReference };
}

return null;
Expand Down
Loading