Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 42 additions & 41 deletions WNPRC_EHR/resources/web/ehr/ext3/ExtContainers.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ EHR.ext.HematologyExcelWin = Ext.extend(Ext.Panel, {
tests = {};

//result.animalId = row1[2].substr(0,6);
result.animalId = row1.substr(27,6);
result.animalId = row1.substring(27,33);
result.animalId = result.animalId.toLowerCase();

var requestNumber = runsStore.find('Id',result.animalId)
Expand All @@ -997,66 +997,67 @@ EHR.ext.HematologyExcelWin = Ext.extend(Ext.Panel, {
return;
}

tests['WBC'] = row2.substr(6,6);
tests['RBC'] = row2.substr(12,5);
tests['HGB'] = row2.substr(17,5);
tests['HCT'] = row2.substr(22,5);
tests['MCV'] = row2.substr(27,5);
tests['MCH'] = row2.substr(32,5);
tests['MCHC'] = row2.substr(37,5);
tests['PLT'] = row2.substr(42,5);
//tests['LYMPH%'] = row2.substr(47,5);
tests['LY'] = row2.substr(47,5);

//tests['MONO%'] = row2.substr(52,5);
tests['MN'] = row2.substr(52,5);

//tests['SEG%'] = row2.substr(57,5);
tests['NE'] = row2.substr(57,5);

//tests['EOSIN%'] = row2.substr(62,5);
tests['EO'] = row2.substr(62,5);

//tests['BASO%'] = row2.substr(67,5);
tests['BS'] = row2.substr(67,5);

//tests['LYMPH#'] = row2.substr(72,6);
//tests['MONO#'] = row2.substr(78,6);
//tests['SEG#'] = row2.substr(84,6);
//tests['EOSIN#'] = row2.substr(90,6);
//tests['BASO#'] = row2.substr(96,6);
tests['RDW'] = row2.substr(102,5);
//tests'RDW-CV'] = row2.substr(102,5);
//tests['RDW-SD'] = row2.substr(107,5);
//tests['PDW'] = row2.substr(112,5);
tests['MPV'] = row2.substr(117,5);
//tests['P-LCR'] = row2.substr(122,5);
tests['WBC'] = row2.substring(6, 12);
tests['RBC'] = row2.substring(12, 17);
tests['HGB'] = row2.substring(17, 22);
tests['HCT'] = row2.substring(22, 27);
tests['MCV'] = row2.substring(27, 32);
tests['MCH'] = row2.substring(32, 37);
tests['MCHC'] = row2.substring(37, 42);
tests['PLT'] = row2.substring(42, 47);
//tests['LYMPH%'] = row2.substring(47, 52);
tests['LY'] = row2.substring(47, 52);

//tests['MONO%'] = row2.substring(52, 57);
tests['MN'] = row2.substring(52, 57);

//tests['SEG%'] = row2.substring(57, 62);
tests['NE'] = row2.substring(57, 62);

//tests['EOSIN%'] = row2.substring(62, 67);
tests['EO'] = row2.substring(62, 67);

//tests['BASO%'] = row2.substring(67, 72);
tests['BS'] = row2.substring(67, 72);

//tests['LYMPH#'] = row2.substring(72, 78);
//tests['MONO#'] = row2.substring(78, 84);
//tests['SEG#'] = row2.substring(84, 90);
//tests['EOSIN#'] = row2.substring(90, 96);
//tests['BASO#'] = row2.substring(96, 102);
//tests['RDW'] = row2.substring(102, 107);
tests['RDW-CV'] = row2.substring(102, 107);
tests['RDW-SD'] = row2.substring(107, 112);
//tests['PDW'] = row2.substring(112, 117);
tests['MPV'] = row2.substring(117, 122);
//tests['P-LCR'] = row2.substring(122, 127);


var value;
for(var test in tests){
var origVal = tests[test];
value = tests[test];

if (value.match(/^00(\d){4}$/)) {
tests[test] = value.substr(2,3) / 100;
tests[test] = value.substring(2,5) / 100;
}
//note: at the moment WBC is the only test with 6 chars, so this test is possibly redundant
else if (value.match(/^0(\d){4,}$/) && test=='WBC') {
tests[test] = value.substr(1,4) / 100;
tests[test] = value.substring(1,5) / 100;
}
else if (value.match(/^0\d{4}$/)){
if (test=='RBC') {
tests[test] = value.substr(1,3) / 100;
tests[test] = value.substring(1,4) / 100;
}
else if (test=='PLT') {
tests[test] = value.substr(1,3) / 1; //convert to number
tests[test] = value.substring(1,4) / 1; //convert to number
}
else {
tests[test] = value.substr(1,3) / 10;
tests[test] = value.substring(1,4) / 10;
}
}
else if (test=='PLT') {
tests[test] = value.substr(0,4);
tests[test] = value.substring(0,4);
}

//NOTE: the following is a possible replacement for the logic above
Expand Down
241 changes: 1 addition & 240 deletions WNPRC_EHR/resources/web/wnprc_ehr/wnprcOverRides.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,243 +819,4 @@ EHR.Metadata.registerMetadata('NewAnimal', {
}
}
}
});

/*
* This (the rest of this file) is a patch for the Hematology bulk add button, to fix issue WNPRC#4430.
* However, as it duplicates code from ExtContainers.js and ehrGridFormPanel.js, it is only meant as
* a temporary solution until a more permanent solution can be formulated.
*/
WNPRC_EHR.HematologyBulkAdd = Ext.extend(Ext.Panel, {
initComponent: function() {
Ext.applyIf(this, {
title: 'Enter Hematology From Sysmex Analyzer',
bodyBorder: true,
border: true,
bodyStyle: 'padding:5px',
width: '100%',
defaults: {
border: false,
bodyBorder: false
},
items: [
{
xtype: 'displayfield',
value: 'This allows bulk import of hematology results using the output of a Sysmex Hematology Analyzer. Cut/paste the contents of the output below.'
},{
xtype: 'textarea',
ref: 'fileField',
height: 350,
width: 430
}
],
buttons: [{
text:'Submit',
disabled:false,
ref: '../submit',
scope: this,
handler: function(s){
this.processData();
}
},{
text: 'Close',
scope: this,
handler: function(){
this.ownerCt.hide();
}
}]
});

EHR.ext.HematologyExcelWin.superclass.initComponent.call(this, arguments);
},
processData: function(){
var data = this.fileField.getValue();

if (!data) {
alert('Must Paste Contents of File');
return;
}

var skippedRows = [];

var hematologyResults = Ext.StoreMgr.get("study||Hematology Results||||");
var runsStore = Ext.StoreMgr.get("study||Clinpath Runs||||");
var unitStore = Ext.StoreMgr.get("ehr_lookups||hematology_tests||testid||testid");

var result;
var tests;
var row1;
var row2;
var toAdd = [];

if(!data.length || !data[0].length){
alert('Something went wrong processing the file');
console.log(data);
return;
}

data = data.split(/D1U/i);

Ext.each(data, function(row, idx){
if(!row.match(/D2U/i))
return;

row = row.split(/D2U/i);

row1 = row[0];
row2 = row[1];
row1 = row1.replace(/\s+/g, '');
row2 = row2.split(/\s+/);
row2 = row2.slice(2, row2.length-1);
row2 = row2.join('');

result = {};
tests = {};

result.animalId = row1.substr(27,6);
result.animalId = result.animalId.toLowerCase();

var requestNumber = runsStore.find('Id',result.animalId)
var record = runsStore.getAt(requestNumber);

//Getting the collection time from the request itself, if it matches animalId
if(requestNumber!= -1 && result.animalId == record.get('Id')){

var collectionDate = record.get('date');
}

result.date= new Date(collectionDate);

if(!result.animalId || runsStore.find('Id', result.animalId)==-1){
//alert('ID: '+result.animalId+' not found in Clinpath Runs section. Records will not be added');
skippedRows.push('Not found in Clinpath Runs: '+result.animalId);
return;
}

tests['WBC'] = row2.substr(6,6);
tests['RBC'] = row2.substr(12,5);
tests['HGB'] = row2.substr(17,5);
tests['HCT'] = row2.substr(22,5);
tests['MCV'] = row2.substr(27,5);
tests['MCH'] = row2.substr(32,5);
tests['MCHC'] = row2.substr(37,5);
tests['PLT'] = row2.substr(42,5);
//tests['LYMPH%'] = row2.substr(47,5);
tests['LY'] = row2.substr(47,5);

//tests['MONO%'] = row2.substr(52,5);
tests['MN'] = row2.substr(52,5);

//tests['SEG%'] = row2.substr(57,5);
tests['NE'] = row2.substr(57,5);

//tests['EOSIN%'] = row2.substr(62,5);
tests['EO'] = row2.substr(62,5);

//tests['BASO%'] = row2.substr(67,5);
tests['BS'] = row2.substr(67,5);

//tests['LYMPH#'] = row2.substr(72,6);
//tests['MONO#'] = row2.substr(78,6);
//tests['SEG#'] = row2.substr(84,6);
//tests['EOSIN#'] = row2.substr(90,6);
//tests['BASO#'] = row2.substr(96,6);
tests['RDW'] = row2.substr(102,5);
//tests'RDW-CV'] = row2.substr(102,5);
//tests['RDW-SD'] = row2.substr(107,5);
//tests['PDW'] = row2.substr(112,5);
tests['MPV'] = row2.substr(117,5);
//tests['P-LCR'] = row2.substr(122,5);

var value;
for(var test in tests){
var origVal = tests[test];
value = tests[test];

if (value.match(/^00(\d){4}$/)) {
tests[test] = value.substr(2,3) / 100;
}
//note: at the moment WBC is the only test with 6 chars, so this test is possibly redundant
else if (value.match(/^0(\d){4,}$/) && test=='WBC') {
tests[test] = value.substr(1,4) / 100;
}
else if (value.match(/^0\d{4}$/)){
if (test=='RBC') {
tests[test] = value.substr(1,3) / 100;
}
else if (test=='PLT') {
tests[test] = value.substr(1,3) / 1; //convert to number
}
else {
tests[test] = value.substr(1,3) / 10;
}
}
else if (test=='PLT') {
tests[test] = value.substr(0,4);
}

//find units
var idx = unitStore.find('testid', test);
var units = null;
var sortOrder = null;
if(idx!=-1){
units = unitStore.getAt(idx).get('units');
sortOrder = unitStore.getAt(idx).get('sort_order');
}

if(tests[test] && isNaN(tests[test])){
skippedRows.push('Invalid Result for: '+result.animalId+', TestId: '+test+', '+tests[test]);
tests[test] = null;
}

toAdd.push({
Id: result.animalId,
date: result.date,
testid: test,
result: tests[test],
units: units,
sortOrder: sortOrder
});
}

}, this);

if(toAdd.length){
toAdd.sort(function(a, b){
return a.Id < b.Id ? -1 :
a.Id > b.Id ? 1 :
a.date < b.date ? -1 :
a.date > b.date ? 1 :
a.sortOrder < b.sortOrder ? -1 :
a.sortOrder > b.sortOrder ? 1 :
0
});
hematologyResults.addRecords(toAdd);
}

if(skippedRows.length){
alert('One or more rows were skipped:\n'+skippedRows.join('\n'));
}
}
});
Ext.reg('wnprc_ehr-hematologybulkadd', WNPRC_EHR.HematologyBulkAdd);

/*
* Let Ctrl+x open the popup
*/
WNPRC_EHR.HematologyPopup = function() {
var popup = new Ext.Window({
closeAction:'hide',
width: 450,
items: [{
xtype: 'wnprc_ehr-hematologybulkadd'
}]
});

popup.show();
};
jQuery(document).on('keypress', function(e){
if (e.ctrlKey && (e.which == 24)) {
WNPRC_EHR.HematologyPopup();
}
});
});
Loading