Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba299f7
adjust filter cohort definitions with add more options of timer filter
jcnamendiOdysseus Jan 15, 2024
b07f987
adds TimeUnit attribute to Criteria
wivern Jan 19, 2024
b9204b9
set timeunit to minimal value of Start and End
wivern Jan 19, 2024
1df7504
remove console log
wivern Jan 19, 2024
90ea52e
Make filter cohort definitions dynamic by adding more options for tim…
jcnamendiOdysseus Jan 23, 2024
36efbe3
Remove restrict filter inclusion expression is the same unit inline
jcnamendiOdysseus Jan 23, 2024
b00be9e
Merge remote-tracking branch 'remotes/origin/fix-issue-filter-criteri…
Jan 23, 2024
c25d0ea
Revert logic for filtering only day for Drug Era, Dose Era, Condition…
jcnamendiOdysseus Jan 23, 2024
d393796
Revert logic for filtering only day for Drug Era, Dose Era, Condition…
jcnamendiOdysseus Jan 23, 2024
59eabdb
Merge remote-tracking branch 'origin/issues-2886' into issues-2886
wivern Jan 24, 2024
940e8df
add subscriptions to EndWindow
wivern Jan 25, 2024
e5c8756
Add timer filter logic into EndWindow
jcnamendiOdysseus Jan 29, 2024
3c9e811
Adds subscription on add action
Jan 30, 2024
02367e1
Fix can not adjust filter value to 0 in inclusion criteria
jcnamendiOdysseus Feb 1, 2024
946fc71
add useDateTime option
wivern Feb 2, 2024
13075e7
Merge remote-tracking branch 'origin/issues-2886' into issues-2886
wivern Feb 2, 2024
732da54
rename UseDatetime expression attribute
wivern Feb 2, 2024
862fa1e
issues-2886: Fix elder gohortdefinition import
Jun 6, 2024
07485c2
isseus-2886: Fix elder cohortdefinitions import
Jun 6, 2024
23546ff
issues-2886: correct timeUnitValue set
Jun 7, 2024
151f8dc
minor fix to avoid having undefined value for TimeUnit value on widge…
oleg-odysseus Jun 13, 2024
da3bdc8
issues-2886: Fix for days setting
Jun 27, 2024
6a6aba6
issues-2886: Save error fix
Jun 28, 2024
ee2d8d9
Merge remote-tracking branch 'remotes/origin/issues-2886'
Dec 9, 2024
ba37495
Changed datetime to chackbox
Aug 12, 2024
9a7f8ac
"proposed fix for non-reacting observable" by oleg-odysseus
Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion js/components/cohortbuilder/CohortExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,28 @@ define(function (require, exports) {
self.CensoringCriteria = ko.observableArray(data.CensoringCriteria && data.CensoringCriteria.map(function (criteria) {
return CriteriaTypes.GetCriteriaFromObject(criteria, self.ConceptSets);
}));
self.CollapseSettings = {CollapseType: ko.observable(data.CollapseSettings && data.CollapseSettings.CollapseType || "ERA"), EraPad: ko.observable(data.CollapseSettings && data.CollapseSettings.EraPad || 0 ) }
self.CollapseSettings = {
CollapseType: ko.observable(data.CollapseSettings && data.CollapseSettings.CollapseType || "ERA"),
EraPad: ko.observable(data.CollapseSettings && data.CollapseSettings.EraPad || 0 ),
EraPadUnitValue: ko.observable(data.CollapseSettings && data.CollapseSettings.EraPadUnitValue || data.CollapseSettings && data.CollapseSettings.EraPad || 0),
EraPadUnit: ko.observable(data.CollapseSettings && data.CollapseSettings.EraPadUnit || 'day')
}
self.CensorWindow = ko.observable(new Period(data.CensorWindow));

self.cdmVersionRange = data.cdmVersionRange || null;

self.CollapseSettings.EraPadUnitValue.subscribe(function (newValue){
const insertValue = newValue.toString().replace(/[\D\.]/g, '');
self.CollapseSettings.EraPadUnitValue(insertValue ? Number(insertValue) : 0);
self.CollapseSettings.EraPadUnit() === 'day' && self.CollapseSettings.EraPad(insertValue ? Number(insertValue) : 0);
})

self.CollapseSettings.EraPadUnit.subscribe(function (newValue){
self.CollapseSettings.EraPad(newValue === 'day' ? self.CollapseSettings.EraPadUnitValue() : 0);
})

self.UseDatetime = ko.observable(!!data.UseDatetime);

}
return CohortExpression;
});
2 changes: 1 addition & 1 deletion js/components/cohortbuilder/CriteriaTypes/Criteria.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define(['require', 'knockout', '../InputTypes/Range','conceptpicker/InputTypes/C

self.CorrelatedCriteria = ko.observable(data.CorrelatedCriteria && new CriteriaGroup(data.CorrelatedCriteria, conceptSets));
self.DateAdjustment = ko.observable(data.DateAdjustment && new DateAdjustment(data.DateAdjustment));

self.IntervalUnit = data.IntervalUnit;
}

return Criteria;
Expand Down
48 changes: 48 additions & 0 deletions js/components/cohortbuilder/EndStrategies/CustomEraStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ define(['knockout'], function (ko) {

self.DrugCodesetId = ko.observable(data.DrugCodesetId);
self.GapDays = ko.observable(data.GapDays || 0);
self.GapUnit = ko.observable(data.GapUnit || 'day');
self.GapUnitValue = ko.observable(data.GapUnitValue || 0);
self.Offset = ko.observable(data.Offset || 0);
self.OffsetUnitValue = ko.observable(data.OffsetUnitValue || 0);
self.OffsetUnit = ko.observable(data.OffsetUnit || 'day');
self.DaysSupplyOverride = ko.observable(data.DaysSupplyOverride);

// set up subscription to update DrugCodesetId if the item is removed from conceptSets
Expand All @@ -18,6 +22,50 @@ define(['knockout'], function (ko) {
}
});
}, null, "arrayChange");

self.OffsetUnitValue.subscribe(function (newValue){
const insertValue = newValue.toString().replace(/[\D\.]/g, '');
self.OffsetUnitValue(insertValue ? Number(insertValue) : 0);
self.OffsetUnit() === 'day' && self.Offset(insertValue ? Number(insertValue) : 0);
})

self.OffsetUnit.subscribe(function (newValue){
self.GapUnit(newValue);
self.Offset(newValue === 'day' ? self.OffsetUnitValue() : 0);
})

self.GapUnitValue.subscribe(function (newValue){
const insertValue = newValue.toString().replace(/[\D\.]/g, '');
self.GapUnitValue(insertValue ? Number(insertValue) : 0);
self.GapUnit() === 'day' && self.GapDays(insertValue ? Number(insertValue) : 0);
})

self.GapUnit.subscribe(function (newValue){
self.OffsetUnit(newValue);
self.GapDays(newValue === 'day' ? self.GapUnitValue() : 0);
})

self.OffsetUnitValue.subscribe(function (newValue){
const insertValue = newValue.toString().replace(/[\D\.]/g, '');
self.OffsetUnitValue(insertValue ? Number(insertValue) : 0);
self.OffsetUnit() === 'day' && self.Offset(insertValue ? Number(insertValue) : 0);
})

self.OffsetUnit.subscribe(function (newValue){
self.GapUnit(newValue);
self.Offset(newValue === 'day' ? self.OffsetUnitValue() : 0);
})

self.GapUnitValue.subscribe(function (newValue){
const insertValue = newValue.toString().replace(/[\D\.]/g, '');
self.GapUnitValue(insertValue ? Number(insertValue) : 0);
self.GapUnit() === 'day' && self.GapDays(insertValue ? Number(insertValue) : 0);
})

self.GapUnit.subscribe(function (newValue){
self.OffsetUnit(newValue);
self.GapDays(newValue === 'day' ? self.GapUnitValue() : 0);
})
}

CustomEraStrategy.prototype.toJSON = function () {
Expand Down
12 changes: 12 additions & 0 deletions js/components/cohortbuilder/EndStrategies/DateOffsetStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ define(['knockout'], function (ko) {

self.DateField = ko.observable(data.DateField || "StartDate");
self.Offset = ko.observable(data.Offset || 0);
self.OffsetUnitValue = ko.observable(data.OffsetUnitValue || 0);
self.OffsetUnit = ko.observable(data.OffsetUnit || 'day');

self.OffsetUnitValue.subscribe(function (newValue){
const insertValue = newValue.toString().replace(/[\D\.]/g, '');
self.OffsetUnitValue(insertValue ? Number(insertValue) : 0);
self.OffsetUnit() === 'day' && self.Offset(insertValue ? Number(insertValue) : 0);
})

self.OffsetUnit.subscribe(function (newValue){
self.Offset(newValue === 'day' ? self.OffsetUnitValue() : 0);
})
}

DateOffsetStrategy.prototype.toJSON = function () {
Expand Down
1 change: 1 addition & 0 deletions js/components/cohortbuilder/InputTypes/DateAdjustment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define(['knockout'], function (ko) {
self.StartOffset = ko.observable(data.StartOffset || 0);
self.EndWith = ko.observable(data.EndWith || DateAdjustment.END_DATE);
self.EndOffset = ko.observable(data.EndOffset || 0);

}

DateAdjustment.START_DATE = "START_DATE";
Expand Down
63 changes: 59 additions & 4 deletions js/components/cohortbuilder/InputTypes/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,74 @@ define(['knockout'], function (ko) {
data = data || {};

self.Start = {
Days: ko.observable((data.Start && data.Start.Days) === 0 ? 0 : (data.Start && data.Start.Days) || null),
Coeff: ko.observable((data.Start && data.Start.Coeff) === 0 ? 0 : (data.Start && data.Start.Coeff) || -1)
Days: ko.observable(setDays(data.Start)),
Coeff: ko.observable((data.Start && data.Start.Coeff) === 0 ? 0 : (data.Start && data.Start.Coeff) || -1),
TimeUnit: ko.observable((data.Start && data.Start.TimeUnit) || 'day'),
TimeUnitValue: ko.observable(setTimeUnitValue(data.Start))
};

self.End = {
Days: ko.observable((data.End && data.End.Days) === 0 ? 0 : (data.End && data.End.Days) || null),
Coeff: ko.observable((data.End && data.End.Coeff) === 0 ? 0 : (data.End && data.End.Coeff) || 1)
Days: ko.observable(setDays(data.End)),
Coeff: ko.observable((data.End && data.End.Coeff) === 0 ? 0 : (data.End && data.End.Coeff) || 1),
TimeUnit: ko.observable((data.End && data.End.TimeUnit) || 'day'),
TimeUnitValue: ko.observable(setTimeUnitValue(data.End))
};

self.UseIndexEnd = ko.observable(data.UseIndexEnd || false);
self.UseEventEnd = ko.observable(data.UseEventEnd || false);

self.Start.TimeUnitValue.subscribe(function (newValue){
const insertValue = newValue ? newValue.toString().replace(/[\D\.]/g, '') : newValue.toString().trim() === '0' ? 0 : null;
self.Start.TimeUnitValue(insertValue === null ? null : Number(insertValue));
self.Start.TimeUnit() === 'day' && self.Start.Days(insertValue === null ? null : Number(insertValue));
})

self.End.TimeUnitValue.subscribe(function (newValue){
const insertValue = newValue ? newValue.toString().replace(/[\D\.]/g, '') : newValue.toString().trim() === '0' ? 0 : null;
self.End.TimeUnitValue(insertValue === null ? null : Number(insertValue));
self.End.TimeUnit() === 'day' && self.End.Days(insertValue === null ? null : Number(insertValue));
})

self.Start.TimeUnit.subscribe(function (newValue){
self.End.TimeUnit(newValue);
self.Start.Days(newValue === 'day' ? (self.Start.TimeUnitValue() === 'All' ? null : self.Start.TimeUnitValue()) : null);
})

self.End.TimeUnit.subscribe(function (newValue){
self.End.Days(newValue === 'day' ? (self.End.TimeUnitValue() === 'All' ? null : self.End.TimeUnitValue()) : null);
})

}

function setDays(dateValue) {
if (dateValue) {
if (dateValue.Days === 0) {
return 0;
} else if (dateValue.Days) {
return dateValue.Days;
} else if (dateValue.TimeUnitValue === 0) {
return 0;
} else if (dateValue.TimeUnitValue && dateValue.TimeUnitValue !== 'All') {
return dateValue.TimeUnitValue;
}
}
return null;
}

function setTimeUnitValue(dateValue) {
if (dateValue) {
if (dateValue.TimeUnitValue === 0) {
return 0;
} else if (dateValue.TimeUnitValue && dateValue.TimeUnitValue !== 'All') {
return dateValue.TimeUnitValue;
} else if (dateValue.Days === 0) {
return 0;
} else if (dateValue.Days) {
return dateValue.Days;
}
}
return null;
}

return Window;
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ define([
self.expression = params.expression;
self.options = options;

self.useDateTime = ko.observable(self.expression().UseDatetime());
self.useDateTime.subscribe(function (newValue) {
self.expression().UseDatetime(newValue);
});

self.showCensorWindow = ko.observable(
self.expression().CensorWindow().StartDate() ||
self.expression().CensorWindow().EndDate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@
flex-grow: 1;
padding-left: 1rem;
}
}
}

.expression-editor {
&__options-label {
margin-left: 0.5rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
</div>
</atlas-modal>

<div class="panel panel-primary">
<div class="panel-heading">Options</div>
<div class="panel-body">
<div>
<input type="checkbox" data-bind="checked: useDateTime">
<span class="expression-editor__options-label" data-bind="text: 'Evaluate cohort start and end dates with date and time'"></span>
</div>
</div>
</div>

<div class="panel panel-primary cohort-definition-panel ui-front">
<div class="panel-heading">
<span
Expand Down Expand Up @@ -196,13 +206,19 @@
<span data-bind="text: ko.i18n('components.cohortExpressionEditor.cohortErasTitle', 'Cohort Eras')"></span>
</div>
<div class="panel-body">
<div data-bind="with: expression().CollapseSettings">
<li>
<span data-bind="text: ko.i18n('components.cohortExpressionEditor.cohortErasText_1', 'Specify era collapse gap size:')"></span>
<span contenteditable="true" class="numericInputField dropdown" data-bind="htmlValue: EraPadUnitValue, eventType: 'blur', ko_autocomplete: { value: EraPadUnitValue, source: $component.options.dayOptions, minLength: 0, maxShowItems: 10, scroll: true }" />
<select data-bind="options: $component.options.windowTimeOptions,
optionsText: function(item) { return item.name },
optionsValue: 'value',
value: EraPadUnit">
</select>
</li>
</div>
<div data-bind="with: expression">
<ul>
<li>
<span data-bind="text: ko.i18n('components.cohortExpressionEditor.cohortErasText_1', 'Specify era collapse gap size:')"></span>
<span contenteditable="true" class="numericInputField dropdown" data-bind="htmlValue: CollapseSettings.EraPad.numeric(), eventType: 'blur', ko_autocomplete: { value: CollapseSettings.EraPad, source: $component.options.dayOptions, minLength: 0, maxShowItems: 10, scroll: true }" />
<span data-bind="text: ko.i18n('components.cohortExpressionEditor.days', 'days')"></span>
</li>
<!-- ko if: $component.showCensorWindow -->
<li>
<span data-bind="text: ko.i18n('components.cohortExpressionEditor.cohortErasText_2', 'Left censor cohort start dates to')"></span>
Expand Down
Loading