@@ -1801,6 +1801,15 @@ describe('getBranchItems', () => {
18011801 { linkId : 'dosage' , type : 'string' } ,
18021802 ] ,
18031803 } ,
1804+
1805+ {
1806+ linkId : 'medications-group-required' ,
1807+ type : 'group' ,
1808+ repeats : true ,
1809+ required : true ,
1810+ item : [ { linkId : 'medication-name-2' , type : 'string' } ] ,
1811+ } ,
1812+
18041813 {
18051814 linkId : 'conditions-group' ,
18061815 type : 'group' ,
@@ -1844,6 +1853,11 @@ describe('getBranchItems', () => {
18441853 { linkId : 'dosage' , answer : [ { valueString : '50mg' } ] } ,
18451854 ] ,
18461855 } ,
1856+ {
1857+ linkId : 'medications-group-required' ,
1858+ item : [ { linkId : 'medication-name-2' , answer : [ { valueString : 'Paracetamol' } ] } ] ,
1859+ } ,
1860+
18471861 {
18481862 linkId : 'known-allergies' ,
18491863 answer : [ { valueString : 'Peanuts' } , { valueString : 'Latex' } ] ,
@@ -1909,6 +1923,24 @@ describe('getBranchItems', () => {
19091923 } ,
19101924 ] ,
19111925 } ,
1926+ {
1927+ name : 'repeating required group (leaf = group instance)' ,
1928+ path : [ 'medications-group-required' ] ,
1929+ expectedQItem : {
1930+ linkId : 'medications-group-required' ,
1931+ type : 'group' ,
1932+ repeats : true ,
1933+ required : true ,
1934+ item : [ { linkId : 'medication-name-2' , type : 'string' } ] ,
1935+ } ,
1936+ expectedQRItems : [
1937+ {
1938+ linkId : 'medications-group-required' ,
1939+ item : [ { linkId : 'medication-name-2' , answer : [ { valueString : 'Paracetamol' } ] } ] ,
1940+ } ,
1941+ ] ,
1942+ } ,
1943+
19121944 {
19131945 name : 'repeating group → indexed instance → child question' ,
19141946 path : [ 'medications-group' , 'items' , '1' , 'medication-name' ] ,
@@ -1959,13 +1991,13 @@ describe('getBranchItems', () => {
19591991 name : 'non-repeating group → leaf question' ,
19601992 path : [ 'demographics-group' , 'items' , 'full-name' ] ,
19611993 expectedQItem : { linkId : 'full-name' , type : 'string' } ,
1962- expectedQRItems : [ ] ,
1994+ expectedQRItems : [ { linkId : 'full-name' } ] ,
19631995 } ,
19641996 {
19651997 name : 'non-repeating group → nested group → leaf question' ,
19661998 path : [ 'demographics-group' , 'items' , 'address-group' , 'items' , 'city' ] ,
19671999 expectedQItem : { linkId : 'city' , type : 'string' } ,
1968- expectedQRItems : [ ] ,
2000+ expectedQRItems : [ { linkId : 'city' } ] ,
19692001 } ,
19702002
19712003 {
@@ -1982,11 +2014,27 @@ describe('getBranchItems', () => {
19822014 } ,
19832015 expectedQRItems : [ ] ,
19842016 } ,
2017+ {
2018+ name : 'repeating required group (leaf = group instance)' ,
2019+ path : [ 'medications-group-required' ] ,
2020+ expectedQItem : {
2021+ linkId : 'medications-group-required' ,
2022+ type : 'group' ,
2023+ repeats : true ,
2024+ required : true ,
2025+ item : [ { linkId : 'medication-name-2' , type : 'string' } ] ,
2026+ } ,
2027+ expectedQRItems : [
2028+ {
2029+ linkId : 'medications-group-required' ,
2030+ } ,
2031+ ] ,
2032+ } ,
19852033 {
19862034 name : 'repeating group → indexed instance → child question' ,
19872035 path : [ 'medications-group' , 'items' , '0' , 'medication-name' ] ,
19882036 expectedQItem : { linkId : 'medication-name' , type : 'string' } ,
1989- expectedQRItems : [ ] ,
2037+ expectedQRItems : [ { linkId : 'medication-name' } ] ,
19902038 } ,
19912039 {
19922040 name : 'stand-alone repeating question' ,
@@ -1996,7 +2044,7 @@ describe('getBranchItems', () => {
19962044 type : 'string' ,
19972045 repeats : true ,
19982046 } ,
1999- expectedQRItems : [ ] ,
2047+ expectedQRItems : [ { linkId : 'known-allergies' } ] ,
20002048 } ,
20012049 ] ;
20022050
@@ -2065,16 +2113,6 @@ describe('calcContext', () => {
20652113 ] ;
20662114 const qItem = questionnaire . item ! [ 0 ] ! ;
20672115 const qrItem = questionnaireResponse . item ! [ 0 ] ! ;
2068- test ( 'without specified qr item' , ( ) => {
2069- expect ( calcContext ( initialContext , variables , qItem , undefined ) ) . toStrictEqual ( {
2070- resource : questionnaireResponse ,
2071- questionnaire,
2072- context : { linkId : qItem . linkId } ,
2073- qitem : qItem ,
2074- Name : [ 'Alice' ] ,
2075- City : [ ] ,
2076- } ) ;
2077- } ) ;
20782116
20792117 test ( 'with specified qr item' , ( ) => {
20802118 expect ( calcContext ( initialContext , variables , qItem , qrItem ) ) . toStrictEqual ( {
0 commit comments