Skip to content

Commit 38a2775

Browse files
MarinaMarina
authored andcommitted
Fix conflict delete enable-when-options
2 parents add4d04 + 945d2b8 commit 38a2775

25 files changed

Lines changed: 502 additions & 173 deletions

.github/workflows/main.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Convert questionnaires and extract
2+
permissions:
3+
contents: write
4+
on:
5+
push:
6+
branches:
7+
- main
8+
jobs:
9+
Upload:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: oven-sh/setup-bun@v2
14+
- name: Prepare
15+
run: mkdir ./extract
16+
- name: Build bundle
17+
run: docker compose run --rm build-seeds
18+
- name: Extract questionnaires
19+
run: bun extract.js
20+
- name: Save extracted filed
21+
run: mkdir -p /tmp/extract && cp ./extract/* /tmp/extract
22+
- name: Switch to compiled
23+
uses: actions/checkout@v4
24+
with:
25+
ref: compiled
26+
- name: Prepare commit
27+
run: rm -rf bundle && mv /tmp/extract bundle
28+
- name: commit and push
29+
uses: EndBug/add-and-commit@v10
30+
with:
31+
add: ./bundle
32+
author_name: Github actions
33+
author_email: ilya+githubactions@beda.software
34+
push: true

compose.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
build-seeds:
3+
image: bedasoftware/fhirsnake:latest
4+
command:
5+
- export
6+
- --output
7+
- /app/bundle/initBundle.json
8+
- --external-questionnaire-fce-fhir-converter-url
9+
- http://questionnaire-fce-fhir-converter:3000/to-fhir
10+
depends_on:
11+
questionnaire-fce-fhir-converter:
12+
condition: service_healthy
13+
volumes:
14+
- ./resources:/app/resources
15+
- ./extract:/app/bundle
16+
17+
questionnaire-fce-fhir-converter:
18+
image: bedasoftware/questionnaire-fce-fhir-converter:latest
19+
healthcheck:
20+
test: curl --fail http://localhost:3000/health || exit 1
21+
interval: 5s
22+
timeout: 30s
23+
retries: 50

extract.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const file = Bun.file("extract/initBundle.json");
2+
const bundle = await file.json();
3+
for(const e of bundle.entry){
4+
const r = e.resource;
5+
await Bun.write(`extract/${r.id}.json`,JSON.stringify(r, undefined, 4));
6+
}

resources/Mapping/extract-vital-signs.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
resourceType: Questionnaire
2+
id: answer-option
3+
name: answer-option
4+
title: Questionnaire.item.answerOption
5+
status: active
6+
url: "http://example.org/fhir/Questionnaire/answer-option"
7+
meta:
8+
profile:
9+
- https://emr-core.beda.software/StructureDefinition/fhir-emr-questionnaire
10+
item:
11+
- linkId: instructions
12+
text: >-
13+
Instructions: Select one or more Reaction options from predefined answerOption values.
14+
type: display
15+
16+
- linkId: reaction
17+
text: Reaction
18+
type: choice
19+
answerOption:
20+
- valueCoding:
21+
code: "422587007"
22+
system: "http://snomed.info/sct"
23+
display: Nausea
24+
- valueCoding:
25+
code: "422400008"
26+
system: "http://snomed.info/sct"
27+
display: Vomiting
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
resourceType: Questionnaire
2+
id: answer-valueset
3+
name: answer-valueset
4+
title: Questionnaire.item.answerValueSet
5+
status: active
6+
url: "http://example.org/fhir/Questionnaire/answer-valueset"
7+
meta:
8+
profile:
9+
- https://emr-core.beda.software/StructureDefinition/fhir-emr-questionnaire
10+
item:
11+
- linkId: instructions
12+
text: >-
13+
Instructions: Open the choice field and verify values are loaded from answerValueSet.
14+
type: display
15+
16+
- linkId: condition-code
17+
text: Condition
18+
type: choice
19+
answerValueSet: "http://hl7.org/fhir/ValueSet/condition-code"
20+
preferredTerminologyServer: https://tx.ontoserver.csiro.au/fhir
21+

resources/Questionnaire/assemble.yaml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,30 @@ resourceType: Questionnaire
22
id: assemble
33
name: assemble
44
title: Assemble
5-
description: >-
6-
Demonstrates modular form composition via `subQuestionnaire`.
75
status: active
8-
subjectType:
9-
- Patient
106
url: "http://example.org/fhir/Questionnaire/assemble"
117
meta:
128
profile:
139
- https://emr-core.beda.software/StructureDefinition/fhir-emr-questionnaire
1410
item:
1511
- linkId: instructions
1612
text: >-
17-
Instructions: This form embeds two existing conference questionnaires via subQuestionnaire
18-
(nested-groups and read-only). Resolve each canonical id to the Questionnaire resource in your environment.
13+
Instructions: This form embeds short conference questionnaires via subQuestionnaire
14+
(required, repeats). Resolve each canonical id to the Questionnaire resource in your environment.
1915
type: display
2016

21-
- linkId: demo-nested-groups-group
22-
text: A. Nested groups (embedded)
17+
- linkId: required-group
18+
text: A. Required (embedded)
2319
type: group
2420
item:
25-
- linkId: demo-nested-groups-embed
21+
- linkId: required-embed
2622
type: display
27-
subQuestionnaire: nested-groups
23+
subQuestionnaire: required
2824

29-
- linkId: demo-read-only-group
30-
text: B. Read-only (embedded)
25+
- linkId: repeats-group
26+
text: B. Repeats (embedded)
3127
type: group
3228
item:
33-
- linkId: demo-read-only-embed
29+
- linkId: repeats-embed
3430
type: display
35-
subQuestionnaire: read-only
31+
subQuestionnaire: repeats

resources/Questionnaire/choice-initial-expression.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ resourceType: Questionnaire
22
id: choice-initial-expression
33
name: choice-initial-expression
44
title: Choice InitialExpression
5-
description: >-
6-
Demonstrates two choice initialization patterns:
7-
Preferred contact type uses local `answerOption` and chooses phone/email from Patient.telecom.
8-
Preferred language uses external `answerValueSet` and initializes from Patient.communication.
95
status: active
10-
subjectType:
11-
- Patient
126
url: "http://example.org/fhir/Questionnaire/choice-initial-expression"
137
meta:
148
profile:
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
resourceType: Questionnaire
2+
id: enable-when-options
3+
name: enable-when-options
4+
title: EnableWhen Options
5+
status: active
6+
url: "http://example.org/fhir/Questionnaire/enable-when-options"
7+
meta:
8+
profile:
9+
- https://emr-core.beda.software/StructureDefinition/fhir-emr-questionnaire
10+
item:
11+
- linkId: instructions
12+
text: >-
13+
Instructions: Set Any allergies? and Follow-up visit needed? to test classic
14+
enableWhen, enableWhenExpression, and enableBehavior (any / all).
15+
Then enter any text in Chief complaint to trigger the operator: exists example.
16+
type: display
17+
18+
- linkId: has-allergy
19+
text: Any allergies?
20+
type: choice
21+
answerOption:
22+
- valueCoding:
23+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
24+
code: "N"
25+
display: "No"
26+
- valueCoding:
27+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
28+
code: "Y"
29+
display: "Yes"
30+
31+
- linkId: follow-up-needed
32+
text: Follow-up visit needed?
33+
type: choice
34+
answerOption:
35+
- valueCoding:
36+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
37+
code: "N"
38+
display: "No"
39+
- valueCoding:
40+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
41+
code: "Y"
42+
display: "Yes"
43+
44+
# Standard FHIR Questionnaire.item.enableWhen (question + operator + answer*).
45+
- linkId: allergy-details-classic
46+
text: Allergy details (classic enableWhen)
47+
type: text
48+
enableWhen:
49+
- question: has-allergy
50+
operator: "="
51+
answerCoding:
52+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
53+
code: "Y"
54+
display: "Yes"
55+
56+
# Same visibility rule via SDC enableWhenExpression (FHIRPath on the client).
57+
# If both were on one item, sdc-qrf would prefer enableWhenExpression and ignore enableWhen.
58+
- linkId: allergy-details-expression
59+
text: Allergy details (enableWhenExpression)
60+
type: text
61+
enableWhenExpression:
62+
language: text/fhirpath
63+
# Do not use `code.first() = 'Y'`: empty answer yields empty collection, not false — sdc-qrf requires a boolean.
64+
expression: >-
65+
iif(
66+
%resource.repeat(item).where(linkId='has-allergy').answer.valueCoding.where(code='Y').exists(),
67+
true,
68+
false
69+
)
70+
71+
# enableBehavior any — at least one enableWhen rule must match (OR).
72+
- linkId: contact-preference-any
73+
text: Contact preference (shown if allergy Yes OR follow-up Yes)
74+
type: text
75+
enableBehavior: any
76+
enableWhen:
77+
- question: has-allergy
78+
operator: "="
79+
answerCoding:
80+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
81+
code: "Y"
82+
display: "Yes"
83+
- question: follow-up-needed
84+
operator: "="
85+
answerCoding:
86+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
87+
code: "Y"
88+
display: "Yes"
89+
90+
# enableBehavior all (default) — every enableWhen rule must match (AND).
91+
- linkId: schedule-deep-review-all
92+
text: Schedule deep review (only when allergy Yes AND follow-up Yes)
93+
type: text
94+
enableBehavior: all
95+
enableWhen:
96+
- question: has-allergy
97+
operator: "="
98+
answerCoding:
99+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
100+
code: "Y"
101+
display: "Yes"
102+
- question: follow-up-needed
103+
operator: "="
104+
answerCoding:
105+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
106+
code: "Y"
107+
display: "Yes"
108+
109+
# Whole group is toggled by classic enableWhen; children inherit visibility context.
110+
- linkId: allergy-extra-group
111+
text: Extra allergy block (group-level enableWhen)
112+
type: group
113+
enableWhen:
114+
- question: has-allergy
115+
operator: "="
116+
answerCoding:
117+
system: "http://terminology.hl7.org/CodeSystem/v2-0136"
118+
code: "Y"
119+
display: "Yes"
120+
item:
121+
- linkId: reaction-note
122+
text: Reaction / severity notes
123+
type: text
124+
- linkId: last-episode-date
125+
text: Last episode date
126+
type: date
127+
128+
# Parent variable reused in enableWhenExpression.
129+
- linkId: variable-group
130+
text: Expression using parent variable %AllergyYes
131+
type: group
132+
variable:
133+
- name: AllergyYes
134+
language: text/fhirpath
135+
expression: >-
136+
iif(
137+
%resource.repeat(item).where(linkId='has-allergy').answer.valueCoding.where(code='Y').exists(),
138+
true,
139+
false
140+
)
141+
item:
142+
- linkId: details-with-variable
143+
text: Enabled via %AllergyYes (same logic as allergy-details-expression)
144+
type: text
145+
enableWhenExpression:
146+
language: text/fhirpath
147+
expression: >-
148+
iif(%AllergyYes = true, true, false)
149+
150+
# operator exists — show when the referenced question has any answer (answerBoolean drives sense of exists).
151+
- linkId: chief-complaint-free
152+
text: Chief complaint (Enter any text here to show the Detail field below)
153+
type: string
154+
155+
# operator exists — show when the referenced question has any answer (answerBoolean drives sense of exists).
156+
- linkId: chief-complaint-detail-exists
157+
text: Detail (appears after you type something above)
158+
type: text
159+
enableWhen:
160+
- question: chief-complaint-free
161+
operator: exists
162+
answerBoolean: true

0 commit comments

Comments
 (0)