Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* @projectDescription The SDX controller library for the PatientRecordCount data-type.
* @namespace i2b2.sdx.TypeControllers.PRC
* @inherits i2b2.sdx.TypeControllers
* @author Nick Benik, Griffin Weber MD PhD
* @version 1.3
* @see i2b2.sdx
* ----------------------------------------------------------------------------------------
* updated 9-15-08: RC4 launch [Nick Benik]
*/
console.group('Load & Execute component file: CRC > SDX > Patient Record Count');
console.time('execute time');
i2b2.sdx.TypeControllers.PRC = {};
i2b2.sdx.TypeControllers.PRC.model = {};
// *********************************************************************************
// ENCAPSULATE DATA
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.getEncapsulateInfo = function() {
// this function returns the encapsulation head information
return {sdxType: 'PRC', sdxKeyName: 'result_instance_id', sdxControlCell:'CRC', sdxDisplayNameKey:'title'};
}
i2b2.sdx.TypeControllers.PRC.SaveToDataModel = function(sdxData, sdxParentNode) {
// save to CRC data model
if (!sdxParentNode) { return false; }
var qm_id = sdxData.sdxInfo.sdxKeyValue;
var qm_hash = i2b2.sdx.Master._KeyHash(qm_id);
// class for all SDX communications
function i2b2_SDX_Encapsulation_EXTENDED() {}
// create an instance and populate with info
var t = new i2b2_SDX_Encapsulation_EXTENDED();
t.origData = Object.clone(sdxData.origData);
t.sdxInfo = Object.clone(sdxData.sdxInfo);
t.parent = sdxParentNode;
t.children = new Hash();
t.children.loaded = false;
// add to hash
sdxParentNode.children.set(qm_hash, t);
// TODO: send data update signal (use JOINING-MUTEX or AGGREGATING-MUTEX to avoid rapid fire of event!)
return t;
}
i2b2.sdx.TypeControllers.PRC.LoadFromDataModel = function(key_value) {}
i2b2.sdx.TypeControllers.PRC.ClearAllFromDataModel= function(sdxOptionalParent) {
if (sdxOptionalParent) {
try {
var findFunc = function(item_rec) {
// this function expects the second argument to be the target node's key value
var hash_key = item_rec[0];
var QM_rec = item_rec[1];
if (QM_rec.sdxInfo.sdxKeyValue == this.strip()) { return true; }
}
var dm_loc = 'i2b2.CRC.model.QueryMasters.'+i2b2.sdx.Master._KeyHash(sdxOptionalParent.sdxInfo.sdxKeyValue);
var targets = i2b2.CRC.model.QueryMasters.findAll(findFunc, sdxOptionalParent.sdxInfo.sdxKeyValue);
for (var i=0; i < targets.length; i++) {
var t = parent_QM[i].value;
t.children = new Hash();
}
} catch(e) { console.error('Could not clear children of given parent node!'); }
} else {
var dm_loc = 'i2b2.CRC.model.QueryMasters';
i2b2.CRC.model.QueryMasters.each(function(item_rec) {
try {
item_rec[1].children = new Hash();
} catch(e) { console.error('Could not clear children of all QueryMasters'); }
});
}
// TODO: send data update signal (use JOINING-MUTEX or AGGREGATING-MUTEX to avoid rapid fire of event!)
// updated dm_loc of the data model
return true;
}
// *********************************************************************************
// GENERATE HTML (DEFAULT HANDLER)
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.RenderHTML= function(sdxData, options, targetDiv) {
// OPTIONS:
// title: string
// showchildren: true | false
// cssClass: string
// icon: [data object]
// icon: (filename of img, appended to i2b2_root+cellDir + '/assets')
// iconExp: (filename of img, appended to i2b2_root+cellDir + '/assets')
// dragdrop: string (function name)
// context: string
// click: string
// dblclick: string
if (Object.isUndefined(options)) { options = {}; }
var render = {html: retHtml, htmlID: id};
var conceptId = sdxData.name;
var id = "CRC_ID-" + i2b2.GUID();
// process drag drop controllers
if (!Object.isUndefined(options.dragdrop)) {
// NOTE TO SELF: should attachment of node dragdrop controller be handled by the SDX system as well?
// This would ensure removal of the onmouseover call in a cross-browser way
var sDD = ' onmouseover="' + options.dragdrop + '(\''+ targetDiv.id +'\',\'' + id + '\')" ';
} else {
var sDD = '';
}
if (Object.isUndefined(options.cssClass)) { options.cssClass = 'sdxDefaultPRC';}
// user can override
bCanExp = true;
if (Object.isBoolean(options.showchildren)) {
bCanExp = options.showchildren;
}
render.canExpand = bCanExp;
render.iconType = "PRC";
if (!Object.isUndefined(options.icon)) { render.icon = i2b2.hive.cfg.urlFramework + 'cells/CRC/assets/'+ options.icon }
if (!Object.isUndefined(options.iconExp)) { render.iconExp = i2b2.hive.cfg.urlFramework + 'cells/CRC/assets/'+ options.iconExp }
// in cases of one set icon, copy valid icon to the missing icon
if (Object.isUndefined(render.icon) && !Object.isUndefined(render.iconExp)) { render.icon = render.iconExp; }
if (!Object.isUndefined(render.icon) && Object.isUndefined(render.iconExp)) { render.iconExp = render.icon; }
// handle the event controllers
var sMainEvents = sDD;
var sImgEvents = sDD;
// **** Render the HTML ***
var retHtml = '
';
retHtml += '
';
retHtml += ' ';
if (!Object.isUndefined(options.title)) {
retHtml += options.title;
} else {
console.warn('[SDX RenderHTML] no title was given in the creation options for an CRC > PRC node!');
retHtml += ' PRC '+id;
}
retHtml += '
';
render.html = retHtml;
render.htmlID = id;
var retObj = {};
Object.extend(retObj, sdxData);
retObj.renderData = render;
return retObj;
}
// *********************************************************************************
// HANDLE HOVER OVER TARGET ENTRY (DEFAULT HANDLER)
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.onHoverOver = function(e, id, ddProxy) {
var el = $(id);
if (el) { Element.addClassName(el,'ddPRCTarget'); }
}
// *********************************************************************************
// HANDLE HOVER OVER TARGET EXIT (DEFAULT HANDLER)
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.onHoverOut = function(e, id, ddProxy) {
var el = $(id);
if (el) { Element.removeClassName(el,'ddPRCTarget'); }
}
// *********************************************************************************
// ADD DATA TO TREENODE (DEFAULT HANDLER)
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.AppendTreeNode = function(yuiTree, yuiRootNode, sdxDataPack, callbackLoader) {
var myobj = { html: sdxDataPack.renderData.html, nodeid: sdxDataPack.renderData.htmlID}
var tmpNode = new YAHOO.widget.HTMLNode(myobj, yuiRootNode, false, true);
if (sdxDataPack.renderData.canExpand && !Object.isUndefined(callbackLoader)) {
// add the callback to load child nodes
sdxDataPack.sdxInfo.sdxLoadChildren = callbackLoader;
}
tmpNode.data.i2b2_SDX= sdxDataPack;
tmpNode.toggle = function() {
if (!this.tree.locked && ( this.hasChildren(true) ) ) {
var data = this.data.i2b2_SDX.renderData;
var img = this.getContentEl();
img = Element.select(img,'img')[0];
if (this.expanded) {
img.src = data.icon;
this.collapse();
} else {
img.src = data.iconExp;
this.expand();
}
}
};
if (!sdxDataPack.renderData.canExpand) { tmpNode.dynamicLoadComplete = true; }
return tmpNode;
}
// *********************************************************************************
// ATTACH DRAG TO DATA (DEFAULT HANDLER)
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.AttachDrag2Data = function(divParentID, divDataID){
if (Object.isUndefined($(divDataID))) { return false; }
// get the i2b2 data from the yuiTree node
var tvTree = YAHOO.widget.TreeView.getTree(divParentID);
var tvNode = tvTree.getNodeByProperty('nodeid', divDataID);
if (!Object.isUndefined(tvNode.DDProxy)) { return true; }
// attach DD
var t = new i2b2.sdx.TypeControllers.PRC.DragDrop(divDataID)
t.yuiTree = tvTree;
t.yuiTreeNode = tvNode;
tvNode.DDProxy = t;
// clear the mouseover attachment function
var tdn = $(divDataID);
if (!Object.isUndefined(tdn.onmouseover)) {
try {
delete tdn.onmouseover;
} catch(e) {
tdn.onmouseover;
}
}
if (!Object.isUndefined(tdn.attributes)) {
for (var i=0;i maxX) {posX = maxX;}
if (posX < 6) {posX = 6;}
if (posY > maxY) {posY = maxY;}
if (posY < 6) {posY = 6;}
YAHOO.util.Dom.setStyle(el, "left", posX + "px");
YAHOO.util.Dom.setStyle(el, "top", posY + "px");
}
this.cachePosition(oCoord.x, oCoord.y);
this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
};
i2b2.sdx.TypeControllers.PRC.DragDrop.prototype.onDragOver = function(e, id) {
// fire the onHoverOver (use SDX so targets can override default event handler)
i2b2.sdx.Master.onHoverOver('PRC', e, id, this);
};
i2b2.sdx.TypeControllers.PRC.DragDrop.prototype.onDragOut = function(e, id) {
// fire the onHoverOut handler (use SDX so targets can override default event handlers)
i2b2.sdx.Master.onHoverOut('PRC', e, id, this);
};
i2b2.sdx.TypeControllers.PRC.DragDrop.prototype.onDragDrop = function(e, id) {
i2b2.sdx.Master.onHoverOut('PRC', e, id, this);
// retreive the concept data from the dragged element
draggedData = this.yuiTreeNode.data.i2b2_SDX;
i2b2.sdx.Master.ProcessDrop(draggedData, id);
};
// *********************************************************************************
// DROP HANDLER
// !!!! DO NOT EDIT - ATTACH YOUR OWN CUSTOM ROUTINE USING
// !!!! THE i2b2.sdx.Master.setHandlerCustom FUNCTION
// *********************************************************************************
i2b2.sdx.TypeControllers.PRC.DropHandler = function(sdxData) {
alert('[PatientRecordCount DROPPED] You need to create your own custom drop event handler.');
}
console.timeEnd('execute time');
console.groupEnd();