Skip to content

Commit

Permalink
IPC project files, Round 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kollil committed Oct 26, 2023
1 parent 951a407 commit db5a391
Show file tree
Hide file tree
Showing 22 changed files with 1,482 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT value, name from Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.onprc_ehr.IPC_Reference_Data
Where name like 'IPCFrozenSectionThickness' and dateDisabled is null
3 changes: 3 additions & 0 deletions onprc_ehr/resources/queries/study/IPC_Locations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT room
From Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.ehr_lookups.rooms
Where dateDisabled is null order by room
113 changes: 113 additions & 0 deletions onprc_ehr/resources/web/onprc_ehr/data/IPCClientStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2013-2015 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
Ext4.define('EHR.data.IPCClientStore', {
extend: 'EHR.data.DataEntryClientStore',

constructor: function(){
this.callParent(arguments);

this.on('add', this.onAddRecord, this);
},

onAddRecord: function(store, records){
Ext4.each(records, function(record){
this.onRecordUpdate(record, ['procedureid']);
}, this);
},

afterEdit: function(record, modifiedFieldNames){
this.onRecordUpdate(record, modifiedFieldNames);

this.callParent(arguments);
},

onRecordUpdate: function(record, modifiedFieldNames){
if (record.get('procedureid')){
modifiedFieldNames = modifiedFieldNames || [];

var lookupRec = this.getProcedureRecord(record.get('procedureid'));
if (!lookupRec)
return;

if (lookupRec.get('remark')&& record.get('remark')== null){
record.beginEdit();
record.set('remark', lookupRec.get('remark'));
record.endEdit(true);
}
}

if (modifiedFieldNames && (modifiedFieldNames.indexOf('Id') > -1 || modifiedFieldNames.indexOf('project') > -1 )){ //} modifiedFieldNames.indexOf('chargetype') > -1)){
if (record.get('objectid')){
var toApply = {
Id: record.get('Id'),
project: record.get('project'),
//chargetype: record.get('chargetype')
};

this.storeCollection.clientStores.each(function(cs){
if (cs.storeId === this.storeCollection.collectionId + '-' + 'IPC_ServiceRequestDetails'){
return;
}

var projectField = cs.getFields().get('project');
// var chargeTypeField = cs.getFields().get('chargetype');
var hasChanges = false;

if (cs.getFields().get('parentid')){
if (cs.getFields().get('Id') || cs.getFields().get('project')){
cs.each(function(r){
if (r.get('parentid') === record.get('objectid')){
var obj = {};

if (projectField){
if (!r.get('project') || (projectField.inheritFromParent && r.get('project') !== record.get('project'))){
obj.project = record.get('project');
}
}
//
// if (chargeTypeField){
// if (!r.get('chargetype') || (chargeTypeField.inheritFromParent && r.get('chargetype') !== record.get('chargetype'))){
// obj.chargetype = record.get('chargetype');
// }
// }

if (r.get('Id') !== record.get('Id')){
obj.Id = record.get('Id');
}

if (!Ext4.Object.isEmpty(obj)){
r.beginEdit();
r.set(obj);
r.endEdit(true);
hasChanges = true;
}
}
}, this);
}
}

if (hasChanges){
cs.fireEvent('datachanged', cs);
}
}, this);
}
}
},

getProcedureRecord: function(procedureId) {
var procedureStore = EHR.DataEntryUtils.getProceduresStore();
LDK.Assert.assertNotEmpty('Unable to find procedureStore from IPCClientStore', procedureStore);

var procRecIdx = procedureStore.findExact('rowid', procedureId);
LDK.Assert.assertTrue('Unable to find procedure record in IPCClientStore for procedureId: [' + procedureId + ']', procRecIdx > -1);

var procedureRec = procedureStore.getAt(procRecIdx);
LDK.Assert.assertNotEmpty('Unable to find procedure record from IPCClientStore. ProcedureId was: [' + procedureId + ']', procedureRec);

return procedureRec;
}

});
151 changes: 151 additions & 0 deletions onprc_ehr/resources/web/onprc_ehr/data/IPCStoreCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (c) 2013-2014 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
Ext4.define('EHR.data.IPCStoreCollection', {
extend: 'EHR.data.TaskStoreCollection',

getIPCStore: function(){
if (this.IPCStore){
return this.IPCStore;
}

this.IPCStore = this.getClientStoreByName('IPC_ServiceRequestDetails');
LDK.Assert.assertNotEmpty('Unable to find IPC store in IPCStoreCollection', this.IPCStore);

return this.IPCStore;
},

getIPCRecord: function(parentid){
if (!parentid){
return null;
}

var IPCStore = this.getIPCStore();
var er;
IPCStore.each(function(r){
if (r.get('objectid') == parentid){
er = r;
return false;
}
}, this);

return er;
},

onClientStoreUpdate: function(){
this.doUpdateRecords();
this.callParent(arguments);
},

setClientModelDefaults: function(model){
this.callParent(arguments);

var IPCStore = this.getIPCStore();
if (model.store && model.store.storeId == IPCStore.storeId){
console.log('is IPC service request, skipping');
return;
}

if (IPCStore.getCount() == 1){
if (model.fields.get('parentid') && model.get('parentid') == null){
model.data.parentid = IPCStore.getAt(0).get('objectid');
}
}

if (model.fields.get('parentid') && model.get('parentid')){
//find matching IPC record and update fields if needed
var parentRec = this.getIPCRecord(model.get('parentid'));
if (parentRec){
model.beginEdit();
if (parentRec.get('Id') !== model.get('Id')){
model.set('Id', parentRec.get('Id'));
}

if (model.fields.get('date') && !model.get('date') && parentRec.get('date')){
model.set('date', parentRec.get('date'));
}

if (model.fields.get('project') && !model.get('project') && parentRec.get('project')){
model.set('project', parentRec.get('project'));
}

// if (model.fields.get('chargetype') && !model.get('chargetype') && parentRec.get('chargetype')){
// model.set('chargetype', parentRec.get('chargetype'));
// }

model.endEdit(true);
}
}
},

doUpdateRecords: function(){
var IPCStore = this.getIPCStore();
this.clientStores.each(function(cs){
if (cs.storeId == IPCStore.storeId){
return;
}

if (cs.getFields().get('Id') == null || cs.getFields().get('parentid') == null){
return;
}

var isIPCChild = cs.model.prototype.sectionCfg.configSources && cs.model.prototype.sectionCfg.configSources.indexOf('IPCChild') > -1;
cs.each(function(rec){
var IPCRec = this.getIPCRecord(rec.get('parentid'));
if (IPCRec != null){
var obj = {};
if (rec.get('Id') !== IPCRec.get('Id')){
//the goal of this is to allow specific sections to avoid inheriting the Id of the parent
if (isIPCChild || !IPCRec.get('Id'))
obj.Id = IPCRec.get('Id');

//if the ID doesnt match, clear parentid
if (!isIPCChild){
obj.parentid = null;
}
}

var pf = rec.fields.get('project');
if (pf && IPCRec.get('project')){
if (!rec.get('project')){
obj.project = IPCRec.get('project');
}
else if (pf.inheritFromParent && IPCRec.get('project') !== rec.get('project')){
obj.project = IPCRec.get('project');
}
}

// var cf = rec.fields.get('chargetype');
// if (cf && IPCRec.get('chargetype')){
// if (!rec.get('chargetype') || cf.inheritDateFromParent){
// obj.chargetype = IPCRec.get('chargetype');
// }
// }

var df = rec.fields.get('date');
if (df && IPCRec.get('date')){
if (!rec.get('date') || df.inheritDateFromParent){
if (!Ext4.Date.isEqual(rec.get('date'), IPCRec.get('date')))
obj.date = IPCRec.get('date');
}
}

if (!Ext4.Object.isEmpty(obj)){
rec.beginEdit();
rec.set(obj);
rec.endEdit(true);

// this is a slight misuse of this event. validation will queue and batch changes, rather than immediately updating each row
// individually. this is better than doing them one-by-one in large grids
if (rec.store){
rec.store.fireEvent('validation', rec.store, rec);
}
}
}

}, this);
}, this);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* User: Kolli
* Date: 4/10/2020
* Time: 10:36 AM
*/
EHR.model.DataModelManager.registerMetadata('CassettePrinting', {
allQueries: {
},

byQuery: {
'study.IPC_CassettePrinting': {

tissueType: {
columnConfig: {
width: 250
}
},

PILabel: {
header:"Additional text on cassette",
columnConfig: {
width: 200
}
},

cassetteColor: {
header:"Cassette Color",
columnConfig: {
width: 200
}
},

remark: {
header:"Remark",
hidden: false,
columnConfig: {
width: 250
}
},

performedBy: {
defaultValue: LABKEY.Security.currentUser.displayName,
columnConfig: {
width: 150
}
}
// ,
//
// qcstate: {
// hidden: true,
// defaultValue: 21
// }
}
}
});
18 changes: 18 additions & 0 deletions onprc_ehr/resources/web/onprc_ehr/model/sources/IPC_Child.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2013-2014 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
EHR.model.DataModelManager.registerMetadata('IPC_Child', {
allQueries: {
Id: {
editable: false,
columnConfig: {
editable: false
}
},
date: {
inheritDateFromParent: true
}
}
});
38 changes: 38 additions & 0 deletions onprc_ehr/resources/web/onprc_ehr/model/sources/IPC_Other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* User: Kolli
* Date: 4/10/2020
* Time: 10:36 AM
*/

EHR.model.DataModelManager.registerMetadata('IPC_Other', {
allQueries: {
},

byQuery: {
'study.IPC_Other': {

tissueType: {
columnConfig: {
width: 250
}
},

serviceAndProducts: {
header:"Service & Products",
hidden: false,
columnConfig: {
width: 250
}
},

performedBy: {
defaultValue: LABKEY.Security.currentUser.displayName,
columnConfig: {
width: 150
}
}

}

}
});
Loading

0 comments on commit db5a391

Please sign in to comment.