Measurements collection is added for lesion table
This commit is contained in:
1 parent
dfb4f6a41c
commit
f5f10dea34
16 files changed
+774
-287
No files matched your search
@@ -1,13 +1,25 @@
|
||||
Template.lesionDialog.onRendered(function () {
|
||||
// Show Lesion Dialog
|
||||
$(document).on("ShowLesionDialog", function (e, eventData) {
|
||||
var dialogPointsOnPage = eventData.currentPoints.page;
|
||||
$("#modal-dialog-container").css({
|
||||
"top": dialogPointsOnPage.y,
|
||||
"left": dialogPointsOnPage.x
|
||||
});
|
||||
$(document).on("ShowLesionDialog", function (e, eventData, activeLesionMeasurementData) {
|
||||
|
||||
var locationUID = measurementManagerDAL.isLesionNumberAdded(activeLesionMeasurementData.lesionNumber);
|
||||
|
||||
if(locationUID != null) {
|
||||
|
||||
activeLesionMeasurementData.locationUID = locationUID;
|
||||
measurementManagerDAL.addLesionData(activeLesionMeasurementData);
|
||||
}else{
|
||||
|
||||
// Show Dialog
|
||||
var dialogPointsOnPage = eventData.currentPoints.page;
|
||||
$("#modal-dialog-container").css({
|
||||
"top": dialogPointsOnPage.y,
|
||||
"left": dialogPointsOnPage.x
|
||||
});
|
||||
|
||||
$("#lesionDialog").modal("show");
|
||||
}
|
||||
|
||||
$("#lesionDialog").modal("show");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var lastAddedLesionData;
|
||||
|
||||
//fill selectLesionLocation element
|
||||
var lesionLocationsArray = [
|
||||
{location:"Brain Brainstem",hasDescription:false, description:""},
|
||||
@@ -8,6 +10,7 @@ var lesionLocationsArray = [
|
||||
];
|
||||
|
||||
Template.lesionLocationDialog.onRendered(function () {
|
||||
console.log(this.data);
|
||||
|
||||
function fillSelectLesionLocation () {
|
||||
var el = $("#selectLesionLocation");
|
||||
@@ -19,11 +22,24 @@ Template.lesionLocationDialog.onRendered(function () {
|
||||
|
||||
// Fill dropdown
|
||||
fillSelectLesionLocation();
|
||||
|
||||
// Observe Measurements Collection Changes
|
||||
Measurements.find().observe({
|
||||
added: function (lesionData) {
|
||||
lastAddedLesionData = lesionData
|
||||
},
|
||||
changed: function(lesionData) {
|
||||
console.log("lesionData is changed!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.lesionLocationDialog.events({
|
||||
'click button#btnCloseLesionPopup': function (e) {
|
||||
$("#lesionDialog").modal("hide");
|
||||
// TODO: Remove lastAddedLesionData from canvas
|
||||
// TODO: Remove lastAddedLesionData from collection
|
||||
|
||||
},
|
||||
|
||||
'change select#selectLesionLocation': function (e) {
|
||||
@@ -31,8 +47,21 @@ Template.lesionLocationDialog.events({
|
||||
var selectedLocationIndex = el.val()
|
||||
if(selectedLocationIndex !== "-1"){
|
||||
|
||||
// Get selected location data
|
||||
var locationObj = lesionLocationsArray[selectedLocationIndex];
|
||||
|
||||
// Gets active lesion measurement data that is latest added data
|
||||
var activeLesionMeasurementData = Session.get("lesionMeasurementData");
|
||||
|
||||
// Adds location data to trialPatientLocations array and returns locationUID
|
||||
var locationUID = measurementManagerDAL.addNewLocation(locationObj);
|
||||
|
||||
// Linkk locationUID with activeLesionMeasurementData
|
||||
activeLesionMeasurementData.locationUID = locationUID;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
measurementManagerDAL.addLesionData(activeLesionMeasurementData);
|
||||
|
||||
// Trigger location selected event
|
||||
$(document).trigger("lesionLocationSelected",locationObj);
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
{{ #each measurement }}
|
||||
{{ >lesionTableRow }}
|
||||
{{ /each }}
|
||||
|
||||
|
||||
<!--Each measurement as row-->
|
||||
<!--Each time point as a column-->
|
||||
</tbody>
|
||||
|
||||
@@ -1,187 +1,52 @@
|
||||
measurements = new Meteor.Collection(null);
|
||||
|
||||
var test = {
|
||||
lesionNumber: 1,
|
||||
isTarget: true,
|
||||
location: 'Brain',
|
||||
timepoints: {
|
||||
"now": {
|
||||
imageId: "blah",
|
||||
timepointUid: "timepointX",
|
||||
date: 2010,
|
||||
isDirty: true,
|
||||
longestDiameter: 5
|
||||
},
|
||||
"earlier": {
|
||||
imageId: "blah2",
|
||||
timepointUid: "timepointy",
|
||||
date: 2010,
|
||||
isDirty: true,
|
||||
longestDiameter: 8
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
measurements.insert(test);
|
||||
Measurements = new Meteor.Collection(null);
|
||||
TimepointNames = new Meteor.Collection(null);
|
||||
|
||||
Template.lesionTable.helpers({
|
||||
'measurement': function() {
|
||||
return measurements.find();
|
||||
var contentId = Session.get("activeContentId");
|
||||
console.log(Measurements.find({contentId: contentId}));
|
||||
return Measurements.find({contentId: contentId});
|
||||
},
|
||||
'timepointNames': function() {
|
||||
return [
|
||||
{name: 'now'},
|
||||
{name: 'earlier'}
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
/*var lesionTableData;
|
||||
setLesionTableData = function (data) {
|
||||
lesionTableData = data;
|
||||
};
|
||||
|
||||
getLesionTableData = function () {
|
||||
return lesionTableData;
|
||||
};
|
||||
|
||||
lesionNumberIsAdded = function(data) {
|
||||
var tabId = data.tabId;
|
||||
var returnValue = {isFound: false, rowIndex : -1};
|
||||
$('#content'+tabId+' table tbody tr td.lesionNumber').each( function(){
|
||||
console.log($(this).text());
|
||||
var lesionNumber = parseInt($(this).text());
|
||||
|
||||
if(lesionNumber == data.lesionNumber) {
|
||||
var $tr = $(this).closest('tr');
|
||||
var rowIndex = $tr.index();
|
||||
returnValue.rowIndex = rowIndex;
|
||||
returnValue.isFound = true;
|
||||
}
|
||||
});
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
returnTblStr = function (obj) {
|
||||
// Get count of lds
|
||||
var tabId = obj.tabId;
|
||||
var lds = $("#content"+tabId).find(".lesionTable th.ld");
|
||||
|
||||
var rowStr = '<tr style="background-color: #b3b3b3;">' +
|
||||
'<td style="text-align:center;"><button type="button" class="btnRemove fa fa-times fa-lg" title="Remove"></button></td>' +
|
||||
'<td style="text-align:center;" class="lesionNumber">'+obj.lesionNumber+'</td>' +
|
||||
'<td style="text-align:center;">Y</td>';
|
||||
|
||||
// Add measurement to right column
|
||||
if(obj.totalViewportCount) {
|
||||
for(var i=0; i< lds.length; i++) {
|
||||
if(i === obj.viewportIndex) {
|
||||
rowStr += '<td>'+obj.lesionLocationObj.location+'</td><td id='+obj.lineIndex+' class="lesion" style="text-align: left;">'+obj.lesions+'</td>';
|
||||
|
||||
}else{
|
||||
rowStr += '<td>'+obj.lesionLocationObj.location+'</td><td class="lesion" style="text-align: left;"></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
rowStr += '</tr>';
|
||||
|
||||
return rowStr;
|
||||
};
|
||||
|
||||
//Link lesionLocationSelected event
|
||||
$(document).on("lesionLocationSelected",function(event,data ){
|
||||
var lesionData = getLesionTableData();
|
||||
lesionData.lesionLocationObj = data;
|
||||
var tabId = lesionData.tabId;
|
||||
//var el_index = lesionData.viewportIndex;
|
||||
var tableEl = $("#content"+tabId).find(".lesionTable");
|
||||
var tblStr = returnTblStr(lesionData);
|
||||
$(tableEl).append(tblStr);
|
||||
|
||||
});
|
||||
|
||||
//Link addLesionToExistedRow event
|
||||
$(document).on("addLesionToExistedRow",function(event,data ){
|
||||
// Get count of lds
|
||||
var tabId = data.tabId;
|
||||
var lds = $("#content"+tabId).find(".lesionTable th.ld");
|
||||
// Add measurement to right column
|
||||
for(var i=0; i< lds.length; i++) {
|
||||
if(i === data.viewportIndex) {
|
||||
var rowIndex = data.rowIndex + 1;
|
||||
var row = $("#content"+tabId).find(".lesionTable tr").eq(rowIndex);
|
||||
var cell = $(row).find("td.lesion").eq(data.viewportIndex);
|
||||
$(cell).attr("id", data.lineIndex);
|
||||
$(cell).html(data.lesions);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("lesionTextChanged", function(event, data){
|
||||
var cellId = data.index;
|
||||
$("td#"+cellId).html(data.measurementText);
|
||||
});
|
||||
|
||||
|
||||
Template.lesionTable.onRendered( function () {
|
||||
|
||||
// TODO: Set lesion table as hiding-panel
|
||||
console.log(this);
|
||||
var template = this;
|
||||
var tabId = this.data.tabId;
|
||||
var viewports = $("#content"+tabId).find(".imageViewerViewport");
|
||||
var lesionTable = $("#content"+tabId).find(".lesionTable");
|
||||
|
||||
var viewportCount = viewports.length;
|
||||
|
||||
var lesionTableWidth = $(lesionTable).width();
|
||||
var viewportWidth = viewports.width();
|
||||
var ldColumnRatio = viewportWidth / lesionTableWidth * 100;
|
||||
|
||||
// Add LD column as viewportCount
|
||||
// Set lesion table columns width
|
||||
|
||||
if(viewportCount > 0) {
|
||||
if(viewportCount == 1) {
|
||||
$('#content'+tabId+' thead tr').append( $('<th />', {text : 'Location', width: ldColumnRatio/2+'%', class:'thLocation'}) )
|
||||
$('#content'+tabId+' thead tr').append( $('<th />', {text : 'LD', width: ldColumnRatio/2+'%', class:'ld'}) )
|
||||
|
||||
} else if(viewportCount == 2) {
|
||||
|
||||
for(var i = 0; i< viewportCount; i++) {
|
||||
$('#content'+tabId+' thead tr').append( $('<th />', {text : 'Location'+i, width: ldColumnRatio/2+'%', class:'thLocation'}) )
|
||||
$('#content'+tabId+' thead tr').append( $('<th />', {text : 'LD'+i, width: ldColumnRatio/2+'%', class:'ld'}) )
|
||||
}
|
||||
|
||||
} else if(viewportCount > 2) {
|
||||
// TODO: Set when viewport count is bigger than 2
|
||||
}
|
||||
}
|
||||
// TODO: When layout is changed, add and calculate new columns for measurement
|
||||
});
|
||||
|
||||
Template.lesionTable.events({
|
||||
'click button.btnRemove': function (e) {
|
||||
var el = $(e.target);
|
||||
var contentId = Session.get("activeContentId");
|
||||
return Template.instance().timepointNamesDictionary.get(contentId);
|
||||
},
|
||||
'click table tbody tr': function(e) {
|
||||
console.log(this);
|
||||
var row = e.currentTarget;
|
||||
var lesionCells = $(row).find("td.lesion");
|
||||
for(var i = 0; i< lesionCells.length; i++) {
|
||||
var cell = lesionCells[i];
|
||||
var idAttr = $(cell).attr("id");
|
||||
if(idAttr != undefined) {
|
||||
// TODO: Create eventObject and trigger LesionToolModified event
|
||||
var viewports = $(".imageViewerViewport");
|
||||
var eventObject = {
|
||||
enabledElement: cornerstone.getEnabledElement(viewports[0]),
|
||||
lineIndex: parseInt(idAttr),
|
||||
type: "active"
|
||||
};
|
||||
$(viewports[0]).trigger("LesionToolModified", eventObject);
|
||||
}
|
||||
}
|
||||
'lesionData': function() {
|
||||
var array = [];
|
||||
var lesions = this.lesionData;
|
||||
Object.keys(lesions).forEach(function(key) {
|
||||
array.push(lesions[key]);
|
||||
});
|
||||
return array;
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
Template.lesionTable.onRendered(function() {
|
||||
|
||||
// TODO: Create seperate method
|
||||
var cols = Template.instance().data.viewportColumns.curValue;
|
||||
var rows = Template.instance().data.viewportRows.curValue;
|
||||
|
||||
var totalViewports = cols * rows;
|
||||
|
||||
var contentId = Session.get('activeContentId');
|
||||
for(var i=0; i< totalViewports; i++) {
|
||||
var timepointNamesArray = [];
|
||||
if(Template.instance().timepointNamesDictionary.get(contentId) != undefined) {
|
||||
timepointNamesArray = Template.instance().timepointNamesDictionary.get(contentId);
|
||||
}
|
||||
var timepointID = contentId.toString()+ i.toString();
|
||||
var timepointName = "Baseline";
|
||||
if(i > 0) {
|
||||
timepointName = "Follow Up "+i;
|
||||
}
|
||||
var timepointObject = {id: timepointID, name: timepointName};
|
||||
timepointNamesArray.push(timepointObject);
|
||||
Template.instance().timepointNamesDictionary.set(contentId, timepointNamesArray);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Template.lesionTable.onCreated(function() {
|
||||
this.timepointNamesDictionary = new ReactiveDict();
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
#lesionTableContainer
|
||||
width: 100%
|
||||
height: 25%
|
||||
width: 100%
|
||||
height: 25%
|
||||
overflow: auto
|
||||
|
||||
table.lesionTable
|
||||
thead
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template name="lesionTableRow">
|
||||
<tr>
|
||||
<th class='lesionNumber'>{{lesionNumber}}</th>
|
||||
<th class='target'>{{isTarget}}</th>
|
||||
<th class='location'>{{location}}</th>
|
||||
<th class='lesionNumber'>{{lesionData.lesionNumber}}</th>
|
||||
<th class='target'>{{#if lesionData.isTarget}} Y {{else}} N {{/if}}</th>
|
||||
<th class='location'>{{lesionData.location}}</th>
|
||||
<!--Each time point as a column-->
|
||||
{{ #each timepoints}}
|
||||
{{ >lesionTableTimepointCell}}
|
||||
{{ /each }}
|
||||
{{# each timepoints }}
|
||||
{{> lesionTableTimepointCell }}
|
||||
{{/ each }}
|
||||
</tr>
|
||||
</template>
|
||||
@@ -1,10 +1,10 @@
|
||||
Template.lesionTableRow.helpers({
|
||||
'timepoints': function() {
|
||||
var array = [];
|
||||
var timepoints = this.timepoints;
|
||||
var timepoints = this.lesionData.timepoints;
|
||||
Object.keys(timepoints).forEach(function(key) {
|
||||
array.push(timepoints[key]);
|
||||
});
|
||||
return array;
|
||||
},
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user