Skip to content

Commit 18c7626

Browse files
committed
Supporting new Cycle
1 parent b1a572b commit 18c7626

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

common-data-defs.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ const patientBaseStreams = [
1313
// fertility
1414
{id: 'fertility', name: 'Fertility'},
1515
{id: 'fertility-miscarriages', name: 'Miscarriages', parentId: 'fertility'},
16-
{id: 'fertility-traings', name: 'Trainings', parentId: 'fertility'},
16+
{id: 'fertility-trainings', name: 'Trainings', parentId: 'fertility'},
1717
{id: 'fertility-cycles', name: 'Cycles', parentId: 'fertility'},
18+
{id: 'fertility-cycles-start', name: 'New Cycle', parentId: 'fertility-cycles'},
19+
{id: 'fertility-cycles-ovulation', name: 'Ovulation Day', parentId: 'fertility-cycles'},
1820
{id: 'fertility-cycles-charted-estimation', name: 'Cycles charted estimation', parentId: 'fertility-cycles'},
1921
{id: 'fertility-ttc-tta', name: 'Trying to conceive / Avoiding pregnancy', parentId: 'fertility'},
2022
// body
@@ -197,6 +199,12 @@ const formHistoricalContentB = [
197199
{ value: 1, label: 'Short' },
198200
{ value: 2, label: 'Long'}
199201
]
202+
},
203+
{
204+
streamId: 'fertility-cycles-start',
205+
eventType: 'activity/plain',
206+
type: 'checkbox',
207+
label: 'New Cycle'
200208
}
201209
]
202210

patient-history-controler.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ async function updateFormContent(formData) {
145145
fieldHTML += `</select>`;
146146
} else if (fieldType === "date") {
147147
fieldHTML += `<input type="date" id="${fieldId}" value="${fieldValue}" class="form-control"/>`;
148+
} else if (fieldType === "checkbox") {
149+
const checkedStr = fieldValue != '' ? 'checked' : '';
150+
fieldHTML += `<input type="checkbox" id="${fieldId}" class="form-control" ${checkedStr}/>`;
148151
}
149152

150153
document.getElementById("inputs-list").innerHTML += fieldHTML;
@@ -163,6 +166,8 @@ async function submitForm(formData, date) {
163166
// Store the value in the values object
164167
if (field.type === "date") {
165168
values[field.id] = formField.valueAsDate;
169+
} else if (field.type === "checkbox") {
170+
values[field.id] = formField.checked ? 'x' : '';
166171
} else {
167172
values[field.id] = formField.value.trim();
168173
}

patient-lib.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ async function getHistoricalContent(questionaryId, formKey) {
193193
}
194194

195195
function valueAndTxtForField (eventContent, field) {
196+
if (field.eventType === 'activity/plain' ) {
197+
console.log('>> activity plain')
198+
return { value: 'x', txt: 'X'};
199+
}
196200
if (field.type === 'date' && eventContent != null ) {
197201
// convert the date to a Date object
198202
const date = new Date(eventContent);
@@ -251,6 +255,11 @@ function parseValue (value, field) {
251255
relativeTo
252256
}
253257
}
258+
if (type === 'checkbox' && field.eventType === 'activity/plain') {
259+
console.log('>> checkbox', value);
260+
if (value === 'x') return null; // will be handled as a value
261+
return '';
262+
}
254263
return value;
255264
}
256265

0 commit comments

Comments
 (0)