sdc-qrf 0.2.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/lib/components.d.ts +3 -3
  2. package/lib/components.js +40 -22
  3. package/lib/components.js.map +1 -1
  4. package/lib/context.d.ts +0 -1
  5. package/lib/converter/extensions.d.ts +36 -0
  6. package/lib/converter/extensions.js +132 -0
  7. package/lib/converter/extensions.js.map +1 -0
  8. package/lib/converter/fceToFhir/index.d.ts +4 -0
  9. package/lib/converter/fceToFhir/index.js +15 -0
  10. package/lib/converter/fceToFhir/index.js.map +1 -0
  11. package/lib/converter/fceToFhir/questionnaire/index.d.ts +3 -0
  12. package/lib/converter/fceToFhir/questionnaire/index.js +17 -0
  13. package/lib/converter/fceToFhir/questionnaire/index.js.map +1 -0
  14. package/lib/converter/fceToFhir/questionnaire/processExtensions.d.ts +3 -0
  15. package/lib/converter/fceToFhir/questionnaire/processExtensions.js +61 -0
  16. package/lib/converter/fceToFhir/questionnaire/processExtensions.js.map +1 -0
  17. package/lib/converter/fceToFhir/questionnaire/processItems.d.ts +3 -0
  18. package/lib/converter/fceToFhir/questionnaire/processItems.js +144 -0
  19. package/lib/converter/fceToFhir/questionnaire/processItems.js.map +1 -0
  20. package/lib/converter/fceToFhir/questionnaire/processMeta.d.ts +3 -0
  21. package/lib/converter/fceToFhir/questionnaire/processMeta.js +20 -0
  22. package/lib/converter/fceToFhir/questionnaire/processMeta.js.map +1 -0
  23. package/lib/converter/fceToFhir/questionnaireResponse/index.d.ts +3 -0
  24. package/lib/converter/fceToFhir/questionnaireResponse/index.js +20 -0
  25. package/lib/converter/fceToFhir/questionnaireResponse/index.js.map +1 -0
  26. package/lib/converter/fceToFhir/questionnaireResponse/processAnswers.d.ts +2 -0
  27. package/lib/converter/fceToFhir/questionnaireResponse/processAnswers.js +48 -0
  28. package/lib/converter/fceToFhir/questionnaireResponse/processAnswers.js.map +1 -0
  29. package/lib/converter/fceToFhir/questionnaireResponse/processMeta.d.ts +3 -0
  30. package/lib/converter/fceToFhir/questionnaireResponse/processMeta.js +18 -0
  31. package/lib/converter/fceToFhir/questionnaireResponse/processMeta.js.map +1 -0
  32. package/lib/converter/fceToFhir/questionnaireResponse/processReference.d.ts +3 -0
  33. package/lib/converter/fceToFhir/questionnaireResponse/processReference.js +19 -0
  34. package/lib/converter/fceToFhir/questionnaireResponse/processReference.js.map +1 -0
  35. package/lib/converter/fhirToFce/index.d.ts +4 -0
  36. package/lib/converter/fhirToFce/index.js +15 -0
  37. package/lib/converter/fhirToFce/index.js.map +1 -0
  38. package/lib/converter/fhirToFce/questionnaire/index.d.ts +3 -0
  39. package/lib/converter/fhirToFce/questionnaire/index.js +21 -0
  40. package/lib/converter/fhirToFce/questionnaire/index.js.map +1 -0
  41. package/lib/converter/fhirToFce/questionnaire/processExtensions.d.ts +8 -0
  42. package/lib/converter/fhirToFce/questionnaire/processExtensions.js +89 -0
  43. package/lib/converter/fhirToFce/questionnaire/processExtensions.js.map +1 -0
  44. package/lib/converter/fhirToFce/questionnaire/processItems.d.ts +3 -0
  45. package/lib/converter/fhirToFce/questionnaire/processItems.js +131 -0
  46. package/lib/converter/fhirToFce/questionnaire/processItems.js.map +1 -0
  47. package/lib/converter/fhirToFce/questionnaire/processMeta.d.ts +32 -0
  48. package/lib/converter/fhirToFce/questionnaire/processMeta.js +14 -0
  49. package/lib/converter/fhirToFce/questionnaire/processMeta.js.map +1 -0
  50. package/lib/converter/fhirToFce/questionnaireResponse/index.d.ts +3 -0
  51. package/lib/converter/fhirToFce/questionnaireResponse/index.js +20 -0
  52. package/lib/converter/fhirToFce/questionnaireResponse/index.js.map +1 -0
  53. package/lib/converter/fhirToFce/questionnaireResponse/processAnswers.d.ts +2 -0
  54. package/lib/converter/fhirToFce/questionnaireResponse/processAnswers.js +46 -0
  55. package/lib/converter/fhirToFce/questionnaireResponse/processAnswers.js.map +1 -0
  56. package/lib/converter/fhirToFce/questionnaireResponse/processMeta.d.ts +3 -0
  57. package/lib/converter/fhirToFce/questionnaireResponse/processMeta.js +15 -0
  58. package/lib/converter/fhirToFce/questionnaireResponse/processMeta.js.map +1 -0
  59. package/lib/converter/fhirToFce/questionnaireResponse/processReference.d.ts +3 -0
  60. package/lib/converter/fhirToFce/questionnaireResponse/processReference.js +18 -0
  61. package/lib/converter/fhirToFce/questionnaireResponse/processReference.js.map +1 -0
  62. package/lib/converter/fhirToFce/utils.d.ts +3 -0
  63. package/lib/converter/fhirToFce/utils.js +37 -0
  64. package/lib/converter/fhirToFce/utils.js.map +1 -0
  65. package/lib/converter/index.d.ts +12 -0
  66. package/lib/converter/index.js +84 -0
  67. package/lib/converter/index.js.map +1 -0
  68. package/lib/index.d.ts +1 -0
  69. package/lib/index.js +1 -0
  70. package/lib/index.js.map +1 -1
  71. package/lib/setupTests.d.ts +1 -0
  72. package/lib/setupTests.js +4 -0
  73. package/lib/setupTests.js.map +1 -0
  74. package/lib/types.d.ts +10 -10
  75. package/lib/utils.d.ts +4 -1
  76. package/lib/utils.js +24 -11
  77. package/lib/utils.js.map +1 -1
  78. package/package.json +4 -5
  79. package/src/components.tsx +67 -29
  80. package/src/converter/__tests__/fce.test.ts +224 -0
  81. package/src/converter/__tests__/resources/questionnaire_fce/allergies.json +405 -0
  82. package/src/converter/__tests__/resources/questionnaire_fce/beverages.json +72 -0
  83. package/src/converter/__tests__/resources/questionnaire_fce/choice_answer_option.json +53 -0
  84. package/src/converter/__tests__/resources/questionnaire_fce/consent.json +86 -0
  85. package/src/converter/__tests__/resources/questionnaire_fce/enable_when.json +103 -0
  86. package/src/converter/__tests__/resources/questionnaire_fce/encounter_create.json +126 -0
  87. package/src/converter/__tests__/resources/questionnaire_fce/gad_7.json +459 -0
  88. package/src/converter/__tests__/resources/questionnaire_fce/immunization.json +182 -0
  89. package/src/converter/__tests__/resources/questionnaire_fce/medication.json +189 -0
  90. package/src/converter/__tests__/resources/questionnaire_fce/multiple_type_launch_context.json +406 -0
  91. package/src/converter/__tests__/resources/questionnaire_fce/patient_create.json +84 -0
  92. package/src/converter/__tests__/resources/questionnaire_fce/patient_edit.json +125 -0
  93. package/src/converter/__tests__/resources/questionnaire_fce/phq_2_phq_9.json +552 -0
  94. package/src/converter/__tests__/resources/questionnaire_fce/physicalexam.json +385 -0
  95. package/src/converter/__tests__/resources/questionnaire_fce/practitioner_create.json +90 -0
  96. package/src/converter/__tests__/resources/questionnaire_fce/practitioner_create_structure_map.json +91 -0
  97. package/src/converter/__tests__/resources/questionnaire_fce/practitioner_edit.json +144 -0
  98. package/src/converter/__tests__/resources/questionnaire_fce/practitioner_role_create.json +37 -0
  99. package/src/converter/__tests__/resources/questionnaire_fce/public_appointment.json +91 -0
  100. package/src/converter/__tests__/resources/questionnaire_fce/review_of_systems.json +389 -0
  101. package/src/converter/__tests__/resources/questionnaire_fce/source_queries.json +34 -0
  102. package/src/converter/__tests__/resources/questionnaire_fce/vitals.json +234 -0
  103. package/src/converter/__tests__/resources/questionnaire_fhir/allergies.json +433 -0
  104. package/src/converter/__tests__/resources/questionnaire_fhir/beverages.json +99 -0
  105. package/src/converter/__tests__/resources/questionnaire_fhir/choice_answer_option.json +49 -0
  106. package/src/converter/__tests__/resources/questionnaire_fhir/consent.json +119 -0
  107. package/src/converter/__tests__/resources/questionnaire_fhir/enable_when.json +87 -0
  108. package/src/converter/__tests__/resources/questionnaire_fhir/encounter_create.json +171 -0
  109. package/src/converter/__tests__/resources/questionnaire_fhir/gad_7.json +489 -0
  110. package/src/converter/__tests__/resources/questionnaire_fhir/immunization.json +215 -0
  111. package/src/converter/__tests__/resources/questionnaire_fhir/medication.json +226 -0
  112. package/src/converter/__tests__/resources/questionnaire_fhir/multiple_type_launch_context.json +416 -0
  113. package/src/converter/__tests__/resources/questionnaire_fhir/patient_create.json +97 -0
  114. package/src/converter/__tests__/resources/questionnaire_fhir/patient_edit.json +183 -0
  115. package/src/converter/__tests__/resources/questionnaire_fhir/phq_2_phq_9.json +580 -0
  116. package/src/converter/__tests__/resources/questionnaire_fhir/physicalexam.json +544 -0
  117. package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_create.json +87 -0
  118. package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_create_structure_map.json +91 -0
  119. package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_edit.json +193 -0
  120. package/src/converter/__tests__/resources/questionnaire_fhir/practitioner_role_create.json +44 -0
  121. package/src/converter/__tests__/resources/questionnaire_fhir/public_appointment.json +116 -0
  122. package/src/converter/__tests__/resources/questionnaire_fhir/review_of_systems.json +368 -0
  123. package/src/converter/__tests__/resources/questionnaire_fhir/source_queries.json +37 -0
  124. package/src/converter/__tests__/resources/questionnaire_fhir/vitals.json +317 -0
  125. package/src/converter/__tests__/resources/questionnaire_response_fce/allergies_inprogress.json +78 -0
  126. package/src/converter/__tests__/resources/questionnaire_response_fce/cardiology.json +96 -0
  127. package/src/converter/__tests__/resources/questionnaire_response_fce/few_answers.json +48 -0
  128. package/src/converter/__tests__/resources/questionnaire_response_fce/gad_7.json +165 -0
  129. package/src/converter/__tests__/resources/questionnaire_response_fce/immunization.json +86 -0
  130. package/src/converter/__tests__/resources/questionnaire_response_fce/medication.json +116 -0
  131. package/src/converter/__tests__/resources/questionnaire_response_fce/new_appointment.json +96 -0
  132. package/src/converter/__tests__/resources/questionnaire_response_fce/patient.json +87 -0
  133. package/src/converter/__tests__/resources/questionnaire_response_fce/phq_2_phq_9.json +193 -0
  134. package/src/converter/__tests__/resources/questionnaire_response_fce/physicalexam.json +187 -0
  135. package/src/converter/__tests__/resources/questionnaire_response_fce/practitioner.json +57 -0
  136. package/src/converter/__tests__/resources/questionnaire_response_fce/reference_answer_with_assoc.json +147 -0
  137. package/src/converter/__tests__/resources/questionnaire_response_fce/review_of_systems.json +129 -0
  138. package/src/converter/__tests__/resources/questionnaire_response_fce/vitals.json +168 -0
  139. package/src/converter/__tests__/resources/questionnaire_response_fhir/allergies_inprogress.json +73 -0
  140. package/src/converter/__tests__/resources/questionnaire_response_fhir/cardiology.json +87 -0
  141. package/src/converter/__tests__/resources/questionnaire_response_fhir/few_answers.json +46 -0
  142. package/src/converter/__tests__/resources/questionnaire_response_fhir/gad_7.json +146 -0
  143. package/src/converter/__tests__/resources/questionnaire_response_fhir/immunization.json +77 -0
  144. package/src/converter/__tests__/resources/questionnaire_response_fhir/medication.json +101 -0
  145. package/src/converter/__tests__/resources/questionnaire_response_fhir/new_appointment.json +86 -0
  146. package/src/converter/__tests__/resources/questionnaire_response_fhir/patient.json +78 -0
  147. package/src/converter/__tests__/resources/questionnaire_response_fhir/phq_2_phq_9.json +170 -0
  148. package/src/converter/__tests__/resources/questionnaire_response_fhir/physicalexam.json +158 -0
  149. package/src/converter/__tests__/resources/questionnaire_response_fhir/practitioner.json +54 -0
  150. package/src/converter/__tests__/resources/questionnaire_response_fhir/reference_answer_with_assoc.json +86 -0
  151. package/src/converter/__tests__/resources/questionnaire_response_fhir/review_of_systems.json +118 -0
  152. package/src/converter/__tests__/resources/questionnaire_response_fhir/vitals.json +145 -0
  153. package/src/converter/extensions.ts +153 -0
  154. package/src/converter/fceToFhir/index.ts +27 -0
  155. package/src/converter/fceToFhir/questionnaire/index.ts +15 -0
  156. package/src/converter/fceToFhir/questionnaire/processExtensions.ts +75 -0
  157. package/src/converter/fceToFhir/questionnaire/processItems.ts +194 -0
  158. package/src/converter/fceToFhir/questionnaire/processMeta.ts +19 -0
  159. package/src/converter/fceToFhir/questionnaireResponse/index.ts +21 -0
  160. package/src/converter/fceToFhir/questionnaireResponse/processAnswers.ts +53 -0
  161. package/src/converter/fceToFhir/questionnaireResponse/processMeta.ts +16 -0
  162. package/src/converter/fceToFhir/questionnaireResponse/processReference.ts +24 -0
  163. package/src/converter/fhirToFce/index.ts +27 -0
  164. package/src/converter/fhirToFce/questionnaire/index.ts +25 -0
  165. package/src/converter/fhirToFce/questionnaire/processExtensions.ts +113 -0
  166. package/src/converter/fhirToFce/questionnaire/processItems.ts +159 -0
  167. package/src/converter/fhirToFce/questionnaire/processMeta.ts +17 -0
  168. package/src/converter/fhirToFce/questionnaireResponse/index.ts +21 -0
  169. package/src/converter/fhirToFce/questionnaireResponse/processAnswers.ts +53 -0
  170. package/src/converter/fhirToFce/questionnaireResponse/processMeta.ts +14 -0
  171. package/src/converter/fhirToFce/questionnaireResponse/processReference.ts +20 -0
  172. package/src/converter/fhirToFce/utils.ts +36 -0
  173. package/src/converter/index.ts +106 -0
  174. package/src/index.ts +1 -0
  175. package/src/setupTests.ts +1 -0
  176. package/src/utils.ts +50 -25
@@ -0,0 +1,54 @@
1
+ {
2
+ "authored": "2023-04-05T06:09:09Z",
3
+ "id": "cedd0c3e-be1a-4c1b-92af-351ed76fe41e",
4
+ "item": [
5
+ {
6
+ "answer": [
7
+ {
8
+ "valueString": "Patel"
9
+ }
10
+ ],
11
+ "linkId": "last-name"
12
+ },
13
+ {
14
+ "answer": [
15
+ {
16
+ "valueString": "Sanjay"
17
+ }
18
+ ],
19
+ "linkId": "first-name"
20
+ },
21
+ {
22
+ "answer": [
23
+ {
24
+ "valueString": "Kumar"
25
+ }
26
+ ],
27
+ "linkId": "middle-name"
28
+ },
29
+ {
30
+ "answer": [
31
+ {
32
+ "valueCoding": {
33
+ "code": "394579002",
34
+ "display": "Cardiology",
35
+ "system": "http://snomed.info/sct"
36
+ }
37
+ }
38
+ ],
39
+ "linkId": "specialty"
40
+ }
41
+ ],
42
+ "meta": {
43
+ "extension": [
44
+ {
45
+ "url": "ex:createdAt",
46
+ "valueInstant": "2023-04-05T06:09:10.640955Z"
47
+ }
48
+ ],
49
+ "lastUpdated": "2023-04-05T06:09:10.640955Z",
50
+ "versionId": "20415"
51
+ },
52
+ "resourceType": "QuestionnaireResponse",
53
+ "status": "completed"
54
+ }
@@ -0,0 +1,86 @@
1
+ {
2
+ "authored": "2023-04-05T06:27:57Z",
3
+ "id": "cf6d9d4b-bfcd-463f-9d26-b6769c2a3fc3",
4
+ "item": [
5
+ {
6
+ "answer": [
7
+ {
8
+ "valueString": "683e382b-fed4-433e-9b6d-a847a7953bc0"
9
+ }
10
+ ],
11
+ "linkId": "patientId"
12
+ },
13
+ {
14
+ "answer": [
15
+ {
16
+ "valueString": "Emily Nguyen"
17
+ }
18
+ ],
19
+ "linkId": "patientName"
20
+ },
21
+ {
22
+ "answer": [
23
+ {
24
+ "valueReference": {
25
+ "display": "Sanjay Patel - Cardiology",
26
+ "reference": "PractitionerRole/429e6a55-8a64-4ede-ad12-1206522253eb"
27
+ }
28
+ }
29
+ ],
30
+ "linkId": "practitioner-role"
31
+ },
32
+ {
33
+ "answer": [
34
+ {
35
+ "valueCoding": {
36
+ "code": "consultation",
37
+ "display": "The first appointment",
38
+ "system": "http://fhir.org/guides/argonaut-scheduling/CodeSystem/visit-type"
39
+ }
40
+ }
41
+ ],
42
+ "linkId": "service"
43
+ },
44
+ {
45
+ "answer": [
46
+ {
47
+ "valueDate": "2023-04-26"
48
+ }
49
+ ],
50
+ "linkId": "date"
51
+ },
52
+ {
53
+ "item": [
54
+ {
55
+ "answer": [
56
+ {
57
+ "valueTime": "15:00:00"
58
+ }
59
+ ],
60
+ "linkId": "start-time"
61
+ },
62
+ {
63
+ "answer": [
64
+ {
65
+ "valueTime": "16:00:00"
66
+ }
67
+ ],
68
+ "linkId": "end-time"
69
+ }
70
+ ],
71
+ "linkId": "Time period"
72
+ }
73
+ ],
74
+ "meta": {
75
+ "extension": [
76
+ {
77
+ "url": "ex:createdAt",
78
+ "valueInstant": "2023-04-05T06:27:58.499391Z"
79
+ }
80
+ ],
81
+ "lastUpdated": "2023-04-05T06:27:58.499391Z",
82
+ "versionId": "20420"
83
+ },
84
+ "resourceType": "QuestionnaireResponse",
85
+ "status": "completed"
86
+ }
@@ -0,0 +1,118 @@
1
+ {
2
+ "authored": "2023-04-06T02:11:08Z",
3
+ "encounter": {
4
+ "reference": "Encounter/e133b999-9e91-4ebd-967e-450bad770682"
5
+ },
6
+ "id": "d575fe05-9db2-4df8-b131-48bb5d27509d",
7
+ "item": [
8
+ {
9
+ "answer": [
10
+ {
11
+ "valueBoolean": true
12
+ }
13
+ ],
14
+ "linkId": "provider-viewed-confirmation"
15
+ },
16
+ {
17
+ "item": [
18
+ {
19
+ "answer": [],
20
+ "linkId": "general"
21
+ },
22
+ {
23
+ "answer": [
24
+ {
25
+ "valueBoolean": true
26
+ }
27
+ ],
28
+ "linkId": "heent"
29
+ },
30
+ {
31
+ "answer": [
32
+ {
33
+ "valueString": "heent"
34
+ }
35
+ ],
36
+ "linkId": "heent-comment"
37
+ },
38
+ {
39
+ "answer": [],
40
+ "linkId": "cardiovascular"
41
+ },
42
+ {
43
+ "answer": [],
44
+ "linkId": "respiratory"
45
+ },
46
+ {
47
+ "answer": [
48
+ {
49
+ "valueBoolean": true
50
+ }
51
+ ],
52
+ "linkId": "gastrointestinal"
53
+ },
54
+ {
55
+ "answer": [
56
+ {
57
+ "valueString": "gastrointestinal"
58
+ }
59
+ ],
60
+ "linkId": "gastrointestinal-comment"
61
+ },
62
+ {
63
+ "answer": [],
64
+ "linkId": "genitourinary"
65
+ },
66
+ {
67
+ "answer": [],
68
+ "linkId": "musculoskeletal"
69
+ },
70
+ {
71
+ "answer": [],
72
+ "linkId": "neurologic"
73
+ },
74
+ {
75
+ "answer": [
76
+ {
77
+ "valueBoolean": true
78
+ }
79
+ ],
80
+ "linkId": "psychiatric"
81
+ },
82
+ {
83
+ "answer": [
84
+ {
85
+ "valueString": "psychiatric"
86
+ }
87
+ ],
88
+ "linkId": "psychiatric-comment"
89
+ },
90
+ {
91
+ "answer": [],
92
+ "linkId": "skin"
93
+ },
94
+ {
95
+ "answer": [],
96
+ "linkId": "other"
97
+ }
98
+ ],
99
+ "linkId": "abnormal-systems-group"
100
+ }
101
+ ],
102
+ "meta": {
103
+ "extension": [
104
+ {
105
+ "url": "ex:createdAt",
106
+ "valueInstant": "2023-04-06T02:10:37.718483Z"
107
+ }
108
+ ],
109
+ "lastUpdated": "2023-04-06T02:11:09.776717Z",
110
+ "versionId": "20480"
111
+ },
112
+ "questionnaire": "review-of-systems",
113
+ "resourceType": "QuestionnaireResponse",
114
+ "source": {
115
+ "reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
116
+ },
117
+ "status": "completed"
118
+ }
@@ -0,0 +1,145 @@
1
+ {
2
+ "questionnaire": "vitals",
3
+ "meta": {
4
+ "lastUpdated": "2023-04-06T02:20:25.903562Z",
5
+ "versionId": "20492",
6
+ "extension": [
7
+ {
8
+ "url": "ex:createdAt",
9
+ "valueInstant": "2023-04-06T02:19:51.712237Z"
10
+ }
11
+ ]
12
+ },
13
+ "encounter": {
14
+ "reference": "Encounter/e133b999-9e91-4ebd-967e-450bad770682"
15
+ },
16
+ "item": [
17
+ {
18
+ "answer": [
19
+ {
20
+ "valueString": "683e382b-fed4-433e-9b6d-a847a7953bc0"
21
+ }
22
+ ],
23
+ "linkId": "patientId"
24
+ },
25
+ {
26
+ "answer": [
27
+ {
28
+ "valueString": "Emily Nguyen"
29
+ }
30
+ ],
31
+ "linkId": "patientName"
32
+ },
33
+ {
34
+ "answer": [
35
+ {
36
+ "valueInteger": 180
37
+ }
38
+ ],
39
+ "linkId": "height"
40
+ },
41
+ {
42
+ "answer": [
43
+ {
44
+ "valueInteger": 80
45
+ }
46
+ ],
47
+ "linkId": "weight"
48
+ },
49
+ {
50
+ "answer": [
51
+ {
52
+ "valueInteger": 36
53
+ }
54
+ ],
55
+ "linkId": "temperature"
56
+ },
57
+ {
58
+ "answer": [
59
+ {
60
+ "valueInteger": 56
61
+ }
62
+ ],
63
+ "linkId": "oxygen-saturation"
64
+ },
65
+ {
66
+ "answer": [
67
+ {
68
+ "valueInteger": 100
69
+ }
70
+ ],
71
+ "linkId": "pulse-rate"
72
+ },
73
+ {
74
+ "answer": [
75
+ {
76
+ "valueInteger": 50
77
+ }
78
+ ],
79
+ "linkId": "respiratory-rate"
80
+ },
81
+ {
82
+ "item": [
83
+ {
84
+ "item": [
85
+ {
86
+ "answer": [
87
+ {
88
+ "valueInteger": 45
89
+ }
90
+ ],
91
+ "linkId": "blood-pressure-systolic"
92
+ },
93
+ {
94
+ "answer": [
95
+ {
96
+ "valueInteger": 67
97
+ }
98
+ ],
99
+ "linkId": "blood-pressure-diastolic"
100
+ }
101
+ ],
102
+ "linkId": "blood-pressure-systolic-diastolic"
103
+ },
104
+ {
105
+ "answer": [
106
+ {
107
+ "valueCoding": {
108
+ "code": "sitting",
109
+ "display": "Sitting"
110
+ }
111
+ }
112
+ ],
113
+ "linkId": "blood-pressure-positions"
114
+ },
115
+ {
116
+ "answer": [
117
+ {
118
+ "valueCoding": {
119
+ "code": "biceps-left",
120
+ "display": "Biceps left"
121
+ }
122
+ }
123
+ ],
124
+ "linkId": "blood-pressure-arm"
125
+ }
126
+ ],
127
+ "linkId": "blood-pressure"
128
+ },
129
+ {
130
+ "answer": [
131
+ {
132
+ "valueInteger": 24.69
133
+ }
134
+ ],
135
+ "linkId": "bmi"
136
+ }
137
+ ],
138
+ "resourceType": "QuestionnaireResponse",
139
+ "source": {
140
+ "reference": "Patient/683e382b-fed4-433e-9b6d-a847a7953bc0"
141
+ },
142
+ "status": "completed",
143
+ "id": "a583cc11-99c6-4719-acab-cb3fb72f5078",
144
+ "authored": "2023-04-06T02:20:25Z"
145
+ }
@@ -0,0 +1,153 @@
1
+ import { Extension as FHIRExtension } from 'fhir/r4b';
2
+
3
+ import { QuestionnaireItem as FCEQuestionnaireItem } from 'shared/src/contrib/aidbox';
4
+
5
+ export enum ExtensionIdentifier {
6
+ Hidden = 'http://hl7.org/fhir/StructureDefinition/questionnaire-hidden',
7
+ ItemControl = 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl',
8
+ SliderStepValue = 'http://hl7.org/fhir/StructureDefinition/questionnaire-sliderStepValue',
9
+ Unit = 'http://hl7.org/fhir/StructureDefinition/questionnaire-unit',
10
+ ReferenceResource = 'http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource',
11
+ CqfExpression = 'http://hl7.org/fhir/StructureDefinition/cqf-expression',
12
+
13
+ ItemPopulationContext = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext',
14
+ InitialExpression = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression',
15
+ ChoiceColumn = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-choiceColumn',
16
+ CalculatedExpression = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression',
17
+ EnableWhenExpression = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression',
18
+ AnswerExpression = 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-answerExpression',
19
+
20
+ AdjustLastToRight = 'https://beda.software/fhir-emr-questionnaire/adjust-last-to-right',
21
+ SliderStart = 'https://beda.software/fhir-emr-questionnaire/slider-start',
22
+ SliderStop = 'https://beda.software/fhir-emr-questionnaire/slider-stop',
23
+ HelpText = 'https://beda.software/fhir-emr-questionnaire/help-text',
24
+ StopLabel = 'https://beda.software/fhir-emr-questionnaire/slider-stop-label',
25
+ Macro = 'https://beda.software/fhir-emr-questionnaire/macro',
26
+ }
27
+
28
+ export type ExtensionTransformer = {
29
+ [key in ExtensionIdentifier]:
30
+ | {
31
+ transform: {
32
+ fromExtension: (
33
+ extension: FHIRExtension,
34
+ ) => Partial<FCEQuestionnaireItem> | undefined;
35
+ toExtension: (item: FCEQuestionnaireItem) => FHIRExtension | undefined;
36
+ };
37
+ }
38
+ | {
39
+ path: {
40
+ extension: keyof FHIRExtension;
41
+ questionnaire: keyof FCEQuestionnaireItem;
42
+ };
43
+ };
44
+ };
45
+
46
+ export const extensionTransformers: ExtensionTransformer = {
47
+ [ExtensionIdentifier.Hidden]: {
48
+ path: { extension: 'valueBoolean', questionnaire: 'hidden' },
49
+ },
50
+ [ExtensionIdentifier.ItemControl]: {
51
+ path: { extension: 'valueCodeableConcept', questionnaire: 'itemControl' },
52
+ },
53
+ [ExtensionIdentifier.SliderStepValue]: {
54
+ path: { extension: 'valueInteger', questionnaire: 'sliderStepValue' },
55
+ },
56
+ [ExtensionIdentifier.Unit]: {
57
+ path: { extension: 'valueCoding', questionnaire: 'unit' },
58
+ },
59
+ [ExtensionIdentifier.ReferenceResource]: {
60
+ transform: {
61
+ fromExtension: (extension) => {
62
+ if (extension.valueCode) {
63
+ return { referenceResource: [extension.valueCode] };
64
+ } else {
65
+ return {};
66
+ }
67
+ },
68
+ toExtension: (item) => {
69
+ if (item.referenceResource?.length) {
70
+ return {
71
+ url: ExtensionIdentifier.ReferenceResource,
72
+ valueCode: item.referenceResource[0],
73
+ };
74
+ }
75
+ },
76
+ },
77
+ },
78
+ [ExtensionIdentifier.CqfExpression]: {
79
+ path: { extension: 'valueExpression', questionnaire: 'cqfExpression' },
80
+ },
81
+
82
+ [ExtensionIdentifier.ItemPopulationContext]: {
83
+ path: { extension: 'valueExpression', questionnaire: 'itemPopulationContext' },
84
+ },
85
+ [ExtensionIdentifier.InitialExpression]: {
86
+ path: { extension: 'valueExpression', questionnaire: 'initialExpression' },
87
+ },
88
+ [ExtensionIdentifier.CalculatedExpression]: {
89
+ path: { extension: 'valueExpression', questionnaire: 'calculatedExpression' },
90
+ },
91
+ [ExtensionIdentifier.EnableWhenExpression]: {
92
+ path: { extension: 'valueExpression', questionnaire: 'enableWhenExpression' },
93
+ },
94
+ [ExtensionIdentifier.AnswerExpression]: {
95
+ path: { extension: 'valueExpression', questionnaire: 'answerExpression' },
96
+ },
97
+ [ExtensionIdentifier.ChoiceColumn]: {
98
+ transform: {
99
+ fromExtension: (extension) => {
100
+ const choiceColumnExtension = extension.extension;
101
+ if (choiceColumnExtension) {
102
+ return {
103
+ choiceColumn: [
104
+ {
105
+ forDisplay:
106
+ choiceColumnExtension.find((obj) => obj.url === 'forDisplay')
107
+ ?.valueBoolean ?? false,
108
+ path: choiceColumnExtension.find((obj) => obj.url === 'path')
109
+ ?.valueString,
110
+ },
111
+ ],
112
+ };
113
+ }
114
+ },
115
+ toExtension: (item) => {
116
+ if (item.choiceColumn) {
117
+ return {
118
+ url: ExtensionIdentifier.ChoiceColumn,
119
+ extension: [
120
+ {
121
+ url: 'forDisplay',
122
+ valueBoolean: item.choiceColumn[0]?.forDisplay,
123
+ },
124
+ {
125
+ url: 'path',
126
+ valueString: item.choiceColumn[0]?.path,
127
+ },
128
+ ],
129
+ };
130
+ }
131
+ },
132
+ },
133
+ },
134
+
135
+ [ExtensionIdentifier.AdjustLastToRight]: {
136
+ path: { extension: 'valueBoolean', questionnaire: 'adjustLastToRight' },
137
+ },
138
+ [ExtensionIdentifier.SliderStart]: {
139
+ path: { extension: 'valueInteger', questionnaire: 'start' },
140
+ },
141
+ [ExtensionIdentifier.SliderStop]: {
142
+ path: { extension: 'valueInteger', questionnaire: 'stop' },
143
+ },
144
+ [ExtensionIdentifier.HelpText]: {
145
+ path: { extension: 'valueString', questionnaire: 'helpText' },
146
+ },
147
+ [ExtensionIdentifier.StopLabel]: {
148
+ path: { extension: 'valueString', questionnaire: 'stopLabel' },
149
+ },
150
+ [ExtensionIdentifier.Macro]: {
151
+ path: { extension: 'valueString', questionnaire: 'macro' },
152
+ },
153
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ Questionnaire as FHIRQuestionnaire,
3
+ QuestionnaireResponse as FHIRQuestionnaireResponse,
4
+ } from 'fhir/r4b';
5
+
6
+ import {
7
+ Questionnaire as FCEQuestionnaire,
8
+ QuestionnaireResponse as FCEQuestionnaireResponse,
9
+ } from 'shared/src/contrib/aidbox';
10
+
11
+ import { convertQuestionnaire } from './questionnaire';
12
+ import { convertQuestionnaireResponse } from './questionnaireResponse';
13
+
14
+ export function fromFirstClassExtension(
15
+ fceQuestionnaireResponse: FCEQuestionnaireResponse,
16
+ ): FHIRQuestionnaireResponse;
17
+ export function fromFirstClassExtension(fceQuestionnaire: FCEQuestionnaire): FHIRQuestionnaire;
18
+ export function fromFirstClassExtension(
19
+ fceResource: FCEQuestionnaire | FCEQuestionnaireResponse,
20
+ ): FHIRQuestionnaireResponse | FHIRQuestionnaire {
21
+ switch (fceResource.resourceType) {
22
+ case 'Questionnaire':
23
+ return convertQuestionnaire(fceResource);
24
+ case 'QuestionnaireResponse':
25
+ return convertQuestionnaireResponse(fceResource);
26
+ }
27
+ }
@@ -0,0 +1,15 @@
1
+ import { Questionnaire as FHIRQuestionnaire } from 'fhir/r4b';
2
+ import cloneDeep from 'lodash/cloneDeep';
3
+
4
+ import { Questionnaire as FCEQuestionnaire } from 'shared/src/contrib/aidbox';
5
+
6
+ import { processExtensions } from './processExtensions';
7
+ import { processItems } from './processItems';
8
+ import { processMeta } from './processMeta';
9
+
10
+ export function convertQuestionnaire(questionnaire: FCEQuestionnaire): FHIRQuestionnaire {
11
+ questionnaire = cloneDeep(questionnaire);
12
+ questionnaire.meta = questionnaire.meta ? processMeta(questionnaire.meta) : questionnaire.meta;
13
+ questionnaire.item = processItems(questionnaire.item ?? []);
14
+ return processExtensions(questionnaire) as FHIRQuestionnaire;
15
+ }
@@ -0,0 +1,75 @@
1
+ import { Extension as FHIRExtension, Questionnaire as FHIRQuestionnaire } from 'fhir/r4b';
2
+
3
+ import { Questionnaire as FCEQuestionnaire } from 'shared/src/contrib/aidbox';
4
+
5
+ export function processExtensions(questionnaire: FCEQuestionnaire): FHIRQuestionnaire {
6
+ const { launchContext, mapping, sourceQueries, targetStructureMap, ...fhirQuestionnaire } =
7
+ questionnaire;
8
+
9
+ let extensions: FHIRExtension[] = [];
10
+
11
+ if (launchContext) {
12
+ for (const launchContextItem of launchContext) {
13
+ const name = launchContextItem.name;
14
+ const typeList = launchContextItem.type;
15
+ const description = launchContextItem.description;
16
+ const launchContextExtension: FHIRExtension[] = [
17
+ {
18
+ url: 'name',
19
+ valueCoding: name,
20
+ },
21
+ ];
22
+
23
+ for (const typeCode of typeList ?? []) {
24
+ launchContextExtension.push({ url: 'type', valueCode: typeCode });
25
+ }
26
+
27
+ if (description !== undefined) {
28
+ launchContextExtension.push({
29
+ url: 'description',
30
+ valueString: description,
31
+ });
32
+ }
33
+
34
+ extensions.push({
35
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext',
36
+ extension: launchContextExtension,
37
+ });
38
+ }
39
+ }
40
+
41
+ if (mapping) {
42
+ extensions = extensions.concat(
43
+ mapping.map((m) => ({
44
+ url: 'http://beda.software/fhir-extensions/questionnaire-mapper',
45
+ valueReference: {
46
+ reference: `Mapping/${m.id}`,
47
+ },
48
+ })),
49
+ );
50
+ }
51
+
52
+ if (sourceQueries) {
53
+ extensions = extensions.concat(
54
+ sourceQueries.map((item) => ({
55
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-sourceQueries',
56
+ valueReference: { reference: `#${item.localRef}` },
57
+ })),
58
+ );
59
+ }
60
+
61
+ if (targetStructureMap) {
62
+ extensions = extensions.concat(
63
+ targetStructureMap.map((targetStructureMapRef) => ({
64
+ url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-targetStructureMap',
65
+ valueCanonical: targetStructureMapRef,
66
+ })),
67
+ );
68
+ }
69
+
70
+ if (extensions.length) {
71
+ fhirQuestionnaire.extension = (fhirQuestionnaire.extension ?? []).concat(extensions);
72
+ }
73
+
74
+ return fhirQuestionnaire as FHIRQuestionnaire;
75
+ }