Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljohanneskraft committed Dec 7, 2024
1 parent fb17937 commit a51089f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions functions/models/src/fhir/fhirQuestionnaireResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export interface FHIRQuestionnaireResponseItemValue
typeof fhirQuestionnaireResponseItemBaseConverter.value.schema
> {
item?:
<<<<<<< Updated upstream
| Array<z.input<typeof fhirQuestionnaireResponseItemConverter.value.schema>>
=======
| z.input<typeof fhirQuestionnaireResponseItemConverter.value.schema>[]
>>>>>>> Stashed changes
| null
| undefined
}
Expand Down Expand Up @@ -324,21 +328,35 @@ export class FHIRQuestionnaireResponse extends FHIRResource {
linkId: string,
item: FHIRQuestionnaireResponseItem,
): number | undefined {
<<<<<<< Updated upstream
for (const child of item.item ?? []) {
if (child.linkId === linkId) {
return this.numericSingleAnswerForItem(child, linkId)
}
=======
if (item.linkId === linkId) {
return this.numericSingleAnswerForItem(linkId, item)
}
for (const child of item.item ?? []) {
>>>>>>> Stashed changes
const childAnswer = this.numericSingleAnswerForLinkItem(linkId, child)
if (childAnswer !== undefined) return childAnswer
}
return undefined
}

private numericSingleAnswerForItem(
<<<<<<< Updated upstream
item: FHIRQuestionnaireResponseItem,
linkId: string,
): number {
const answers = item.answer ?? []
=======
linkId: string,
item: FHIRQuestionnaireResponseItem,
): number {
const answers = item?.answer ?? []
>>>>>>> Stashed changes
if (answers.length !== 1)
throw new Error(`Zero or multiple answers found for linkId ${linkId}.`)
const code = answers[0].valueCoding?.code
Expand Down

0 comments on commit a51089f

Please sign in to comment.