Skip to content

Commit 4df0ab4

Browse files
committed
Multiple forms now supported
1 parent 47c0587 commit 4df0ab4

7 files changed

Lines changed: 268 additions & 220 deletions

File tree

CookieUtils.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ function set (cookieKey, value, expireInDays = 365, path) {
1616
expireInDays = expireInDays;
1717
const myDate = new Date();
1818
const hostName = window.location.hostname;
19-
const cookiePath = window.location.pathname;
19+
const cookiePath = path || window.location.pathname;
2020
myDate.setDate(myDate.getDate() + expireInDays);
2121
let cookieStr = encodeURIComponent(cookieKey) + '=' +
2222
encodeURIComponent(JSON.stringify(value)) +
23+
';path=' + cookiePath +
2324
';expires=' + myDate.toGMTString() +
24-
';domain=.' + hostName + ';path=' + cookiePath;
25+
';domain=' + hostName ;
2526
// do not add SameSite when removing a cookie
2627
if (expireInDays >= 0) cookieStr += ';SameSite=Strict';
2728
document.cookie = cookieStr;
@@ -46,6 +47,6 @@ function get (cookieKey) {
4647
* @memberof CookieUtils
4748
* @param cookieKey - The key
4849
*/
49-
function del (cookieKey) {
50-
set(cookieKey, { deleted: true }, -1);
50+
function del (cookieKey, path) {
51+
set(cookieKey, { deleted: true }, -1, path);
5152
}

common-data-defs.js

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,33 @@ const patientBaseStreams = [
1515
{id: 'fertility-miscarriages', name: 'Miscarriages', parentId: 'fertility'},
1616
{id: 'fertility-traings', name: 'Trainings', parentId: 'fertility'},
1717
{id: 'fertility-cycles', name: 'Cycles', parentId: 'fertility'},
18-
{id: 'fertility-cycles-charted-extimation', name: 'Cycles charted estimation', parentId: 'fertility'},
18+
{id: 'fertility-cycles-charted-extimation', name: 'Cycles charted estimation', parentId: 'fertility-cycles'},
1919
{id: 'fertility-ttc-tta', name: 'Trying to conceive / Avoiding pregnancy', parentId: 'fertility'},
2020
// body
2121
{id: 'body', name: 'Body'},
2222
{id: 'body-height', name: 'Body Height', parentId: 'body'},
2323
{id: 'body-weight', name: 'Body Weight', parentId: 'body'},
24+
// vulva
25+
{id: 'body-vulva', name: 'Vulva', parentId: 'body'},
26+
{id: 'body-vulva-wetness', name: 'Vulva Wetness', parentId: 'body-vulva'},
27+
{id: 'body-vulva-wetness-feeling', name: 'Vulva Wetness Feeling', parentId: 'body-vulva-wetness'}
2428
];
2529

26-
const patientBasePermissions = [
30+
const patientBasePermissionsX = [
2731
{id: 'profile', name: 'Profile'},
2832
{id: 'family', name: 'Family'},
2933
{id: 'fertility', name: 'Fertility'},
3034
{id: 'body-height', name: 'Body height'},
3135
{id: 'body-weight', name: 'Body weight'},
36+
];
37+
38+
const patientBasePermissionsB = [
39+
{id: 'profile', name: 'Profile'},
40+
{id: 'fertility-cycles', name: 'Fertility Cycles'},
41+
{id: 'body-vulva', name: 'Vulva'}
3242
]
3343

34-
const formProfileContent = [
44+
const formProfileContentBase = [
3545
{
3646
streamId: 'profile-name',
3747
eventType: 'contact/name',
@@ -44,6 +54,15 @@ const formProfileContent = [
4454
type: 'text',
4555
label: 'Surname',
4656
},
57+
{
58+
streamId: 'profile-date-of-birth',
59+
eventType: 'date/iso-8601',
60+
type: 'date',
61+
label: 'Date of Birth',
62+
}];
63+
64+
const formProfileContentX = [
65+
...formProfileContentBase,
4766
{
4867
streamId: 'profile-nationality',
4968
eventType: 'contact/nationality',
@@ -57,12 +76,6 @@ const formProfileContent = [
5776
options: [{ value: 'male', label: 'Male' }, { value: 'female', label: 'Female'}],
5877
label: 'Sex',
5978
},
60-
{
61-
streamId: 'profile-date-of-birth',
62-
eventType: 'date/iso-8601',
63-
type: 'date',
64-
label: 'Date of Birth',
65-
},
6679
{
6780
streamId: 'family-children',
6881
eventType: 'count/generic',
@@ -83,8 +96,7 @@ const formProfileContent = [
8396
}
8497
];
8598

86-
// -- fields lists -- //
87-
const formHistoricalContent = [
99+
const formHistoricalContentX = [
88100
{
89101
streamId: 'ttc-tta',
90102
eventType: 'fertility-intention/ttc-tta',
@@ -141,10 +153,16 @@ const formHistoricalContent = [
141153
}
142154
]
143155

156+
const formHistoricalContentB = [
157+
]
158+
159+
//
160+
161+
144162
const questionnaires = {
145-
'demo-dr-forms-questionary-x': {
163+
'questionary-x': {
146164
title: 'Demo with Profile and TTC-TTA',
147-
permissions: patientBasePermissions.map(perm => ({
165+
permissions: patientBasePermissionsX.map(perm => ({
148166
streamId: perm.id,
149167
level: 'read',
150168
name: perm.name,
@@ -155,18 +173,42 @@ const questionnaires = {
155173
type: 'permanent',
156174
key: 'profile-x',
157175
name: 'Profile',
158-
content: formProfileContent
176+
content: formProfileContentX
159177
},
160178
history: {
161179
type: 'recurring',
162180
key: 'recurring-x',
163181
name: 'History',
164-
content: formHistoricalContent
182+
content: formHistoricalContentX
183+
}
184+
}
185+
},
186+
'questionnary-basic': {
187+
title: 'Basic Profile and Cycle Information',
188+
permissions: patientBasePermissionsB.map(perm => ({
189+
streamId: perm.id,
190+
level: 'read',
191+
name: perm.name,
192+
})),
193+
patientBaseStreams,
194+
forms: {
195+
profile: {
196+
type: 'permanent',
197+
key: 'profile-b',
198+
name: 'Profile',
199+
content: formProfileContentBase
200+
},
201+
history: {
202+
type: 'recurring',
203+
key: 'recurring-b',
204+
name: 'History',
205+
content: formHistoricalContentB
165206
}
166207
}
167208
}
168209
}
169210

170211
export const dataDefs = {
171-
questionnaires
212+
appId: 'demo-dr-forms',
213+
questionnaires,
172214
};

dr-controler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ window.onload = (event) => {
1414
};
1515

1616
async function stateChange(state) {
17-
const questionaryId = 'demo-dr-forms-questionary-x';
1817
if (state === 'loggedIN') {
1918
document.getElementById('please-login').style.visibility = 'hidden';
2019
document.getElementById('data-view').style.visibility = 'visible';
@@ -52,6 +51,7 @@ async function setQuestionnaries() {
5251
}
5352

5453
async function showQuestionnary(questionaryId) {
54+
console.log('## showQuestionnary', questionaryId);
5555
if (questionaryId == null) {
5656
document.getElementById('questionnary-view').style.visibility = 'hidden';
5757
return;

0 commit comments

Comments
 (0)