11
2-
3- const patientBasePermissionsX = [
4- { id : 'profile' , name : 'Profile' } ,
5- { id : 'family' , name : 'Family' } ,
6- { id : 'fertility' , name : 'Fertility' } ,
7- { id : 'body-height' , name : 'Body height' } ,
8- { id : 'body-weight' , name : 'Body weight' } ,
9- ] ;
10-
11- const patientBasePermissionsB = [
12- { id : 'profile' , name : 'Profile' } ,
13- { id : 'fertility-cycles' , name : 'Fertility Cycles' } ,
14- { id : 'body-vulva' , name : 'Vulva' } ,
15- { id : 'body-weight' , name : 'Body weight' } ,
16- ]
17-
18-
19- const questionnaires = {
20- 'questionary-x' : {
21- title : 'Demo with Profile and TTC-TTA' ,
22- permissions : patientBasePermissionsX . map ( perm => ( {
23- streamId : perm . id ,
24- level : 'read' ,
25- name : perm . name ,
26- } ) ) ,
27- forms : {
28- profile : {
29- type : 'permanent' ,
30- key : 'profile-x' ,
31- name : 'Profile' ,
32- } ,
33- history : {
34- type : 'recurring' ,
35- key : 'recurring-x' ,
36- name : 'History' ,
37- }
38- }
39- } ,
40- 'questionnary-basic' : {
41- title : 'Basic Profile and Cycle Information' ,
42- permissions : patientBasePermissionsB . map ( perm => ( {
43- streamId : perm . id ,
44- level : 'read' ,
45- name : perm . name ,
46- } ) ) ,
47- forms : {
48- profile : {
49- type : 'permanent' ,
50- key : 'profile-b' ,
51- name : 'Profile'
52- } ,
53- history : {
54- type : 'recurring' ,
55- key : 'recurring-b' ,
56- name : 'History'
57- }
58- }
59- }
60- }
61-
2+ import { hdsModel } from './common-lib.js' ;
623const v2 = {
634 'questionary-x' : {
645 title : 'Demo with Profile and TTC-TTA' ,
6+ permissionsPreRequest : [
7+ { streamId : 'profile' } ,
8+ { streamId : 'fertility' } ,
9+ ] ,
6510 forms : {
6611 profile : {
6712 type : 'permanent' ,
@@ -88,6 +33,9 @@ const v2 = {
8833 } ,
8934 'questionnary-basic' : {
9035 title : 'Basic Profile and Cycle Information' ,
36+ permissionsPreRequest : [
37+ { streamId : 'profile' }
38+ ] ,
9139 forms : {
9240 profile : {
9341 type : 'permanent' ,
@@ -116,6 +64,15 @@ const v2 = {
11664 }
11765}
11866
67+
68+ function utilGetPermissions ( questionaryId ) {
69+ const preRequest = v2 [ questionaryId ] . permissionsPreRequest || [ ] ;
70+ const itemKeys = utilGetAllItemKeys ( questionaryId ) ;
71+ const permissions = hdsModel ( ) . authorizationForItemKeys ( itemKeys , { preRequest } ) ;
72+ return permissions
73+ }
74+
75+
11976/**
12077 * get all itemKeys of a questionnary
12178 * @param {* } questionaryId
@@ -131,7 +88,7 @@ function utilGetAllItemKeys (questionaryId) {
13188
13289export const dataDefs = {
13390 appId : 'demo-dr-forms' ,
134- questionnaires,
13591 v2questionnaires : v2 ,
136- utilGetAllItemKeys
92+ utilGetAllItemKeys,
93+ utilGetPermissions
13794} ;
0 commit comments