Skip to content
Merged
8 changes: 7 additions & 1 deletion js/components/cohortbuilder/CriteriaTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define(function (require, exports) {
var ProcedureOccurrence = require("./CriteriaTypes/ProcedureOccurrence");
var Specimen = require("./CriteriaTypes/Specimen");
var VisitOccurrence = require("./CriteriaTypes/VisitOccurrence");
var VisitDetail = require("./CriteriaTypes/VisitDetail");
var DeviceExposure = require("./CriteriaTypes/DeviceExposure");
var Measurement = require("./CriteriaTypes/Measurement");
var ObservationPeriod = require("./CriteriaTypes/ObservationPeriod");
Expand Down Expand Up @@ -56,7 +57,11 @@ define(function (require, exports) {
} else if (data.hasOwnProperty("VisitOccurrence")) {
return {
VisitOccurrence: new exports.VisitOccurrence(data.VisitOccurrence, conceptSets)
};
};
} else if (data.hasOwnProperty("VisitDetail")) {
return {
VisitDetail: new exports.VisitDetail(data.VisitDetail, conceptSets)
};
} else if (data.hasOwnProperty("DeviceExposure")) {
return {
DeviceExposure: new exports.DeviceExposure(data.DeviceExposure, conceptSets)
Expand Down Expand Up @@ -97,6 +102,7 @@ define(function (require, exports) {
exports.Specimen = Specimen;
exports.ProcedureOccurrence = ProcedureOccurrence;
exports.VisitOccurrence = VisitOccurrence;
exports.VisitDetail = VisitDetail;
exports.DeviceExposure = DeviceExposure;
exports.Measurement = Measurement;
exports.ObservationPeriod = ObservationPeriod;
Expand Down
74 changes: 74 additions & 0 deletions js/components/cohortbuilder/CriteriaTypes/VisitDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
define(['knockout', './Criteria', '../InputTypes/Range', '../InputTypes/ConceptSetSelection','conceptpicker/InputTypes/Concept', '../InputTypes/Text'], function (ko, Criteria, Range, ConceptSetSelection, Concept, Text) {

function VisitDetail(data, conceptSets) {
var self = this;
data = data || {};

Criteria.call(this, data, conceptSets);
// set up subscription to update CodesetId and VisitSourceConcept if the item is removed from conceptSets
conceptSets.subscribe(function (changes) {
changes.forEach(function(change) {
if (change.status === 'deleted') {
if (ko.utils.unwrapObservable(self.CodesetId) == change.value.id) {
self.CodesetId(null);
}
if (ko.utils.unwrapObservable(self.VisitDetailSourceConcept()) == change.value.id) {
self.VisitSourceConcept()(null);
}
if (ko.utils.unwrapObservable(self.VisitDetailTypeCS()?.CodesetId) == change.value.id) {
self.VisitDetailTypeCS(new ConceptSetSelection());
}
if (ko.utils.unwrapObservable(self.GenderCS()?.CodesetId) == change.value.id) {
self.GenderCS(new ConceptSetSelection());
}
if (ko.utils.unwrapObservable(self.ProviderSpecialtyCS()?.CodesetId) == change.value.id) {
self.ProviderSpecialtyCS(new ConceptSetSelection());
}
if (ko.utils.unwrapObservable(self.PlaceOfServiceCS()?.CodesetId) == change.value.id) {
self.PlaceOfServiceCS(new ConceptSetSelection());
}

}
});
}, null, "arrayChange");

// General Condition Occurence Criteria

// Verbatim fields
self.CodesetId = ko.observable(data.CodesetId);

self.VisitDetailStartDate = ko.observable(data.VisitDetailStartDate && new Range(data.VisitDetailStartDate));
self.VisitDetailEndDate = ko.observable(data.VisitDetailEndDate && new Range(data.VisitDetailEndDate));
self.VisitDetailTypeCS = ko.observable(data.VisitDetailTypeCS && new ConceptSetSelection(data.VisitDetailTypeCS));
self.VisitDetailTypeExclude = ko.observable(data.VisitDetailTypeExclude || null);
self.VisitDetailSourceConcept = ko.observable(data.VisitDetailSourceConcept != null ? ko.observable(data.VisitDetailSourceConcept) : null);
self.VisitDetailLength = ko.observable(data.VisitDetailLength && new Range(data.VisitDetailLength));

// Derived Fields
self.First = ko.observable(data.First || null);
self.Age = ko.observable(data.Age && new Range(data.Age));

// Linked Fields
self.GenderCS = ko.observable(data.GenderCS && new ConceptSetSelection(data.GenderCS));

/* Do we still need prior enroll days inside the individual criteria?
self.PriorEnrollDays = ko.observable((typeof data.PriorEnrollDays == "number") ? data.PriorEnrollDays : null);
self.AfterEnrollDays = ko.observable((typeof data.AfterEnrollDays == "number") ? data.AfterEnrollDays : null);
*/
self.ProviderSpecialtyCS = ko.observable(data.ProviderSpecialtyCS && new ConceptSetSelection(data.ProviderSpecialtyCS));

self.PlaceOfServiceCS = ko.observable(data.PlaceOfServiceCS && new ConceptSetSelection(data.PlaceOfServiceCS));

self.PlaceOfServiceLocation = ko.observable(data.PlaceOfServiceLocation != null ? ko.observable(data.PlaceOfServiceLocation) : null);
self.PlaceOfServiceDistance = ko.observable(data.PlaceOfServiceDistance && new Range(data.PlaceOfServiceDistance));
}

VisitDetail.prototype = new Criteria();
VisitDetail.prototype.constructor = VisitDetail;
VisitDetail.prototype.toJSON = function () {
return this;
};

return VisitDetail;

});
12 changes: 12 additions & 0 deletions js/components/cohortbuilder/InputTypes/ConceptSetSelection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define(['knockout'], function (ko) {

function ConceptSetSelection(data) {
var self = this;
data = data || {};

self.IsExclusion = ko.observable(data.IsExclusion ? true : data.IsExclusion || null);
self.CodesetId = ko.observable(data.CodesetId ? data.CodesetId : null);
}

return ConceptSetSelection;
});
3 changes: 3 additions & 0 deletions js/components/cohortbuilder/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ define(function (require, exports) {

var visitOccurrence = require('./components/VisitOccurrence');
ko.components.register('visit-occurrence-criteria', visitOccurrence);

var visitDetail = require('./components/VisitDetail');
ko.components.register('visit-detail-criteria', visitDetail);

var deviceExposure = require('./components/DeviceExposure');
ko.components.register('device-exposure-criteria', deviceExposure);
Expand Down
15 changes: 15 additions & 0 deletions js/components/cohortbuilder/components/CensoringCriteriaEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ define([
});
},
},
{
...constants.censoringEventList.addVisitDetail,
selected: false,
action: function () {
var unwrappedExpression = ko.utils.unwrapObservable(self.expression);
unwrappedExpression.CensoringCriteria.push({
VisitDetail: new criteriaTypes.VisitDetail(
null,
unwrappedExpression.ConceptSets
),
});
},
},
{
...constants.censoringEventList.fromReusable,
selected: false,
Expand Down Expand Up @@ -222,6 +235,8 @@ define([
return "observation-criteria";
else if (data.hasOwnProperty("VisitOccurrence"))
return "visit-occurrence-criteria";
else if (data.hasOwnProperty("VisitDetail"))
return "visit-detail-criteria";
else if (data.hasOwnProperty("DeviceExposure"))
return "device-exposure-criteria";
else if (data.hasOwnProperty("Measurement"))
Expand Down
52 changes: 0 additions & 52 deletions js/components/cohortbuilder/components/CohortExpressionEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,58 +91,6 @@ define([
self.selectedInclusionRule(copiedRule);
};

self.addPrimaryCriteriaOptions = {
selectText: ko.i18n('components.cohortExpressionEditor.addInitialEvent', 'Add Initial Event...'),
width: 250,
height: 300,
actionOptions: self.primaryCriteriaOptions,
onAction: function (data) {
data.selectedData.action();
},
};

self.addCensorCriteriaOptions = {
selectText: ko.i18n('components.cohortExpressionEditor.addCensoringEvent', 'Add Censoring Event...'),
width: 250,
height: 300,
actionOptions: self.censorCriteriaOptions,
onAction: function (data) {
data.selectedData.action();
},
};

self.getCriteriaIndexComponent = function (data) {
data = ko.utils.unwrapObservable(data);

if (data.hasOwnProperty("ConditionOccurrence"))
return "condition-occurrence-criteria";
else if (data.hasOwnProperty("ConditionEra"))
return "condition-era-criteria";
else if (data.hasOwnProperty("DrugExposure"))
return "drug-exposure-criteria";
else if (data.hasOwnProperty("DrugEra")) return "drug-era-criteria";
else if (data.hasOwnProperty("DoseEra")) return "dose-era-criteria";
else if (data.hasOwnProperty("ProcedureOccurrence"))
return "procedure-occurrence-criteria";
else if (data.hasOwnProperty("Observation"))
return "observation-criteria";
else if (data.hasOwnProperty("VisitOccurrence"))
return "visit-occurrence-criteria";
else if (data.hasOwnProperty("DeviceExposure"))
return "device-exposure-criteria";
else if (data.hasOwnProperty("Measurement"))
return "measurement-criteria";
else if (data.hasOwnProperty("Specimen")) return "specimen-criteria";
else if (data.hasOwnProperty("ObservationPeriod"))
return "observation-period-criteria";
else if (data.hasOwnProperty("PayerPlanPeriod"))
return "payer-plan-period-criteria";
else if (data.hasOwnProperty("Death")) return "death-criteria";
else if (data.hasOwnProperty("LocationRegion"))
return "location-region-criteria";
else return "unknownCriteriaType";
};

self.getExpressionJSON = function () {
return ko.toJSON(
self.expression(),
Expand Down
12 changes: 12 additions & 0 deletions js/components/cohortbuilder/components/CriteriaGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ define([
}, unwrappedExpression.ConceptSets));
}
},
{
...constants.groupAttributes.addVisitDetail,
selected: false,
action: function () {
var unwrappedExpression = ko.utils.unwrapObservable(self.expression);
self.group().CriteriaList.push(new AdditionalCriteria({
Criteria: {
VisitDetail: {}
}
}, unwrappedExpression.ConceptSets));
}
},
{
...constants.groupAttributes.addGroup,
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ define([
};

self.strategyComponentName = ko.pureComputed(function () {
console.log(params.strategy);

var strategy = ko.utils.unwrapObservable(params.strategy);
if (strategy.hasOwnProperty("DateOffset"))
return "date-offset-strategy";
Expand Down
17 changes: 17 additions & 0 deletions js/components/cohortbuilder/components/InitialCriteriaEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ define([
});
},
},
{
...constants.initialEventList.addVisitDetail,
selected: false,
action: function () {
var unwrappedExpression = ko.utils.unwrapObservable(self.expression);
unwrappedExpression
.PrimaryCriteria()
.CriteriaList.push({
VisitDetail: new criteriaTypes.VisitDetail(
null,
unwrappedExpression.ConceptSets
),
});
},
},
{
...constants.initialEventList.fromReusable,
selected: false,
Expand Down Expand Up @@ -265,6 +280,8 @@ define([
return "observation-criteria";
else if (data.hasOwnProperty("VisitOccurrence"))
return "visit-occurrence-criteria";
else if (data.hasOwnProperty("VisitDetail"))
return "visit-detail-criteria";
else if (data.hasOwnProperty("DeviceExposure"))
return "device-exposure-criteria";
else if (data.hasOwnProperty("Measurement"))
Expand Down
Loading