Skip to content

Commit 2f2bbec

Browse files
committed
using permissions from model helper
1 parent 9ae12d5 commit 2f2bbec

4 files changed

Lines changed: 28 additions & 64 deletions

File tree

common-data-defs.js

Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,12 @@
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';
623
const 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

13289
export const dataDefs = {
13390
appId: 'demo-dr-forms',
134-
questionnaires,
13591
v2questionnaires: v2,
136-
utilGetAllItemKeys
92+
utilGetAllItemKeys,
93+
utilGetPermissions
13794
};

dr-lib.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ async function getSharingToken(questionaryId) {
317317
feature: "selfRevoke",
318318
setting: "forbidden",
319319
},
320+
{
321+
// for "publicly shared access" always forbid the selfAudit feature
322+
feature: "selfAudit",
323+
setting: "forbidden",
324+
},
320325
],
321326
clientData: {
322327
[dataDefs.appId]: {

patient-home-controler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { patientLib } from './patient-lib.js';
22
import { patientHomeLib } from './patient-home-lib.js';
3+
import { dataDefs } from './common-data-defs.js';
34

45
/**
56
* UI management code.
@@ -110,7 +111,7 @@ async function showFormDetails(formInfo) {
110111
for (const permission of formDetails.permissions) {
111112
const row = tbody.insertRow(-1);
112113
const cellStream = row.insertCell(-1);
113-
cellStream.innerHTML = permission.name;
114+
cellStream.innerHTML = permission.defaultName;
114115
const cellLevel = row.insertCell(-1);
115116
cellLevel.innerHTML = permission.level;
116117
}

patient-home-lib.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ async function createsPatientAccountStreams (connection, streams) {
9494

9595
// ---- if first connection to the app create a sharing for the Dr and submit it ---- //
9696
async function grantAccess (formInfo, formDetails) {
97+
console.log('#FormDetails', {formInfo, formDetails});
9798
// create needed base streams
9899
const itemKeys = dataDefs.utilGetAllItemKeys(formInfo.questionaryId);
99100
const baseStreams = hdsModel().streamsGetNecessaryListForItemKeys(itemKeys);
@@ -210,7 +211,7 @@ async function getQuestionnaryDetails (formInfo) {
210211
const questionaryId = appInfos.questionaryId;
211212
console.log('## Questionnary ID', questionaryId);
212213

213-
details.permissions = dataDefs.questionnaires[questionaryId]?.permissions;
214+
details.permissions = dataDefs.utilGetPermissions(questionaryId);
214215
return details;
215216
}
216217

0 commit comments

Comments
 (0)