Skip to content

Commit

Permalink
Added date-offset UI elements to cohort builder. (#2880)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisknoll authored Aug 15, 2023
1 parent fccb8dc commit b789cd9
Show file tree
Hide file tree
Showing 36 changed files with 338 additions and 34 deletions.
3 changes: 2 additions & 1 deletion js/components/cohortbuilder/CriteriaTypes/Criteria.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['require', 'knockout', '../InputTypes/Range','conceptpicker/InputTypes/Concept', '../InputTypes/Text', '../CriteriaGroup'], function (require, ko, Range, Concept, Text) {
define(['require', 'knockout', '../InputTypes/Range','conceptpicker/InputTypes/Concept', '../InputTypes/Text', '../InputTypes/DateAdjustment', '../CriteriaGroup'], function (require, ko, Range, Concept, Text, DateAdjustment) {

function Criteria (data, conceptSets) {
var self = this;
Expand All @@ -7,6 +7,7 @@ define(['require', 'knockout', '../InputTypes/Range','conceptpicker/InputTypes/C
var CriteriaGroup = require('../CriteriaGroup');

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

}

Expand Down
17 changes: 17 additions & 0 deletions js/components/cohortbuilder/InputTypes/DateAdjustment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
define(['knockout'], function (ko) {
var debug = false;
function DateAdjustment(data) {
var self = this;
data = data || {};

self.StartWith = ko.observable(data.StartWith || DateAdjustment.START_DATE);
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";
DateAdjustment.END_DATE = "END_DATE";

return DateAdjustment;
});
3 changes: 3 additions & 0 deletions js/components/cohortbuilder/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ define(function (require, exports) {
var dateRange = require('./components/DateRange');
ko.components.register('date-range', dateRange);

var dateAdjustment = require('./components/DateAdjustment');
ko.components.register('date-adjustment', dateAdjustment);

var windowInput = require('./components/WindowInput');
ko.components.register('window-input',windowInput);

Expand Down
10 changes: 9 additions & 1 deletion js/components/cohortbuilder/components/ConditionEra.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ define([
"../options",
"../utils",
"../InputTypes/Range",
"../InputTypes/DateAdjustment",
"../CriteriaGroup",
"text!./ConditionEraTemplate.html",
"../const",
], function (ko, options, utils, Range, CriteriaGroup, template, constants) {
], function (ko, options, utils, Range, DateAdjustment, CriteriaGroup, template, constants) {
function ConditionEraViewModel(params) {
var self = this;
self.expression = ko.utils.unwrapObservable(params.expression);
Expand Down Expand Up @@ -80,6 +81,13 @@ define([
);
},
},
{
...constants.eraAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.eraAttributes.addConditonCount,
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionEra.attributeText_10', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: First() != null, visible: First() != null">
<td><i data-bind="click: function() { $component.removeCriterion('First') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
9 changes: 9 additions & 0 deletions js/components/cohortbuilder/components/ConditionOccurrence.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
"../utils",
"../InputTypes/Range",
"../InputTypes/Text",
"../InputTypes/DateAdjustment",
"../CriteriaGroup",
"text!./ConditionOccurrenceTemplate.html",
"../const",
Expand All @@ -14,6 +15,7 @@ define([
utils,
Range,
Text,
DateAdjustment,
CriteriaGroup,
template,
constants
Expand Down Expand Up @@ -90,6 +92,13 @@ define([
);
},
},
{
...constants.occurrenceAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.occurrenceAttributes.addType,
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionOccurrence.conditionOccurrenceText_14', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: First() != null, visible: First() != null">
<td><i data-bind="click: function() { $component.removeCriterion('First') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
27 changes: 27 additions & 0 deletions js/components/cohortbuilder/components/DateAdjustment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
define(["knockout", "text!./DateAdjustmentTemplate.html", "../InputTypes/DateAdjustment"], function (
ko,
componentTemplate,
DateAdjustment
) {
function DateAdjustmentViewModel(params) {
var self = this;
self.DateAdjustment = params.DateAdjustment;
self.dateOptions = [
{
id: DateAdjustment.START_DATE,
name: ko.i18n('options.startDate', 'start date'),
},
{
id: DateAdjustment.END_DATE,
name: ko.i18n('options.endDate', 'end date'),
}
];
}

// return compoonent definition
return {
viewModel: DateAdjustmentViewModel,
template: componentTemplate,
};
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
starting with <select
data-bind="options: $component.dateOptions, optionsText: 'name', optionsValue: 'id', value: DateAdjustment().StartWith"></select>
+ <input class="numericInputField" style="width:25px"
data-bind="value: DateAdjustment().StartOffset.numeric(), autoGrowInput: {comfortZone: 8}"></input> days
and ending with <select
data-bind="options: $component.dateOptions, optionsText: 'name', optionsValue: 'id', value: DateAdjustment().EndWith"></select>
+ <input class="numericInputField" style="width:25px"
data-bind="value: DateAdjustment().EndOffset.numeric(), autoGrowInput: {comfortZone: 8}"></input> days
11 changes: 9 additions & 2 deletions js/components/cohortbuilder/components/Death.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ define([
"../options",
"../utils",
"../InputTypes/Range",
"../InputTypes/Text",
"../InputTypes/DateAdjustment",
"../CriteriaGroup",
"text!./DeathTemplate.html",
"../const",
Expand All @@ -12,7 +12,7 @@ define([
options,
utils,
Range,
Text,
DateAdjustment,
CriteriaGroup,
template,
constants
Expand Down Expand Up @@ -48,6 +48,13 @@ define([
);
},
},
{
...constants.deathAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.deathAttributes.addType,
selected: false,
Expand Down
7 changes: 7 additions & 0 deletions js/components/cohortbuilder/components/DeathTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionDeath.attributeText_7', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: OccurrenceStartDate() != null, visible: OccurrenceStartDate() != null">
<td><i data-bind="click: function() { $component.removeCriterion('OccurrenceStartDate') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
9 changes: 9 additions & 0 deletions js/components/cohortbuilder/components/DeviceExposure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
"../utils",
"../InputTypes/Range",
"../InputTypes/Text",
"../InputTypes/DateAdjustment",
"../CriteriaGroup",
"text!./DeviceExposureTemplate.html",
"../const",
Expand All @@ -13,6 +14,7 @@ define([
utils,
Range,
Text,
DateAdjustment,
CriteriaGroup,
template,
constants
Expand Down Expand Up @@ -78,6 +80,13 @@ define([
);
},
},
{
...constants.deviceAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.deviceAttributes.addType,
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionDevice.attributeText_15', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: First() != null, visible: First() != null">
<td><i data-bind="click: function() { $component.removeCriterion('First') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
10 changes: 9 additions & 1 deletion js/components/cohortbuilder/components/DoseEra.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ define([
"../options",
"../utils",
"../InputTypes/Range",
"../InputTypes/DateAdjustment",
"../CriteriaGroup",
"text!./DoseEraTemplate.html",
"../const",
], function (ko, options, utils, Range, CriteriaGroup, template, constants) {
], function (ko, options, utils, Range, DateAdjustment, CriteriaGroup, template, constants) {
function DoseEraViewModel(params) {
var self = this;
self.expression = ko.utils.unwrapObservable(params.expression);
Expand Down Expand Up @@ -68,6 +69,13 @@ define([
);
},
},
{
...constants.doseAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.doseAttributes.addUnit,
selected: false,
Expand Down
7 changes: 7 additions & 0 deletions js/components/cohortbuilder/components/DoseEraTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionDose.attributeText_13', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: First() != null, visible: First() != null">
<td><i data-bind="click: function() { $component.removeCriterion('First') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
10 changes: 9 additions & 1 deletion js/components/cohortbuilder/components/DrugEra.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ define([
"../options",
"../utils",
"../InputTypes/Range",
"../InputTypes/DateAdjustment",
"../CriteriaGroup",
"text!./DrugEraTemplate.html",
"../const",
], function (ko, options, utils, Range, CriteriaGroup, template, constants) {
], function (ko, options, utils, Range, DateAdjustment, CriteriaGroup, template, constants) {
function DrugEraViewModel(params) {
var self = this;
self.expression = ko.utils.unwrapObservable(params.expression);
Expand Down Expand Up @@ -68,6 +69,13 @@ define([
);
},
},
{
...constants.eraAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.drugAttributes.addLength,
selected: false,
Expand Down
7 changes: 7 additions & 0 deletions js/components/cohortbuilder/components/DrugEraTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionDrug.conditionDrugText_13', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: First() != null, visible: First() != null">
<td><i data-bind="click: function() { $component.removeCriterion('First') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
9 changes: 9 additions & 0 deletions js/components/cohortbuilder/components/DrugExposure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ define([
"../options",
"../utils",
"../InputTypes/Range",
"../InputTypes/DateAdjustment",
"../InputTypes/Text",
"../CriteriaGroup",
"text!./DrugExposureTemplate.html",
Expand All @@ -12,6 +13,7 @@ define([
options,
utils,
Range,
DateAdjustment,
Text,
CriteriaGroup,
template,
Expand Down Expand Up @@ -77,6 +79,13 @@ define([
);
},
},
{
...constants.drugexposureAttributes.addDateAdjustment,
selected: false,
action: function () {
if (self.Criteria.DateAdjustment() == null) self.Criteria.DateAdjustment(new DateAdjustment());
},
},
{
...constants.drugexposureAttributes.addType,
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
<col style="width:20px" />
<col />
</colgroup>
<tr data-bind="if: DateAdjustment() != null, visible: DateAdjustment() != null">
<td><i data-bind="click: function() { $component.removeCriterion('DateAdjustment') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
<span data-bind="text: ko.i18n('components.conditionDrugExposure.conditionDrugExposureText_23', 'with date adjustment:')"></span>
<date-adjustment params="DateAdjustment: DateAdjustment"></date-adjustment>
</td>
</tr>
<tr data-bind="if: First() != null, visible: First() != null">
<td><i data-bind="click: function() { $component.removeCriterion('First') }, title: ko.i18n('common.remove', 'Remove')" class="fa fa-times" /></td>
<td>
Expand Down
Loading

0 comments on commit b789cd9

Please sign in to comment.