Skip to content

Commit 2bfdcfa

Browse files
authored
Add new tests to hematology bulk upload (#900)
* Add tests for RDW-CV and RDW-SD to hematology results * Remove ctrl + x bulk upload function for hematology results
1 parent a9466fe commit 2bfdcfa

2 files changed

Lines changed: 43 additions & 281 deletions

File tree

WNPRC_EHR/resources/web/ehr/ext3/ExtContainers.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ EHR.ext.HematologyExcelWin = Ext.extend(Ext.Panel, {
974974
tests = {};
975975

976976
//result.animalId = row1[2].substr(0,6);
977-
result.animalId = row1.substr(27,6);
977+
result.animalId = row1.substring(27,33);
978978
result.animalId = result.animalId.toLowerCase();
979979

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

1000-
tests['WBC'] = row2.substr(6,6);
1001-
tests['RBC'] = row2.substr(12,5);
1002-
tests['HGB'] = row2.substr(17,5);
1003-
tests['HCT'] = row2.substr(22,5);
1004-
tests['MCV'] = row2.substr(27,5);
1005-
tests['MCH'] = row2.substr(32,5);
1006-
tests['MCHC'] = row2.substr(37,5);
1007-
tests['PLT'] = row2.substr(42,5);
1008-
//tests['LYMPH%'] = row2.substr(47,5);
1009-
tests['LY'] = row2.substr(47,5);
1010-
1011-
//tests['MONO%'] = row2.substr(52,5);
1012-
tests['MN'] = row2.substr(52,5);
1013-
1014-
//tests['SEG%'] = row2.substr(57,5);
1015-
tests['NE'] = row2.substr(57,5);
1016-
1017-
//tests['EOSIN%'] = row2.substr(62,5);
1018-
tests['EO'] = row2.substr(62,5);
1019-
1020-
//tests['BASO%'] = row2.substr(67,5);
1021-
tests['BS'] = row2.substr(67,5);
1022-
1023-
//tests['LYMPH#'] = row2.substr(72,6);
1024-
//tests['MONO#'] = row2.substr(78,6);
1025-
//tests['SEG#'] = row2.substr(84,6);
1026-
//tests['EOSIN#'] = row2.substr(90,6);
1027-
//tests['BASO#'] = row2.substr(96,6);
1028-
tests['RDW'] = row2.substr(102,5);
1029-
//tests'RDW-CV'] = row2.substr(102,5);
1030-
//tests['RDW-SD'] = row2.substr(107,5);
1031-
//tests['PDW'] = row2.substr(112,5);
1032-
tests['MPV'] = row2.substr(117,5);
1033-
//tests['P-LCR'] = row2.substr(122,5);
1000+
tests['WBC'] = row2.substring(6, 12);
1001+
tests['RBC'] = row2.substring(12, 17);
1002+
tests['HGB'] = row2.substring(17, 22);
1003+
tests['HCT'] = row2.substring(22, 27);
1004+
tests['MCV'] = row2.substring(27, 32);
1005+
tests['MCH'] = row2.substring(32, 37);
1006+
tests['MCHC'] = row2.substring(37, 42);
1007+
tests['PLT'] = row2.substring(42, 47);
1008+
//tests['LYMPH%'] = row2.substring(47, 52);
1009+
tests['LY'] = row2.substring(47, 52);
1010+
1011+
//tests['MONO%'] = row2.substring(52, 57);
1012+
tests['MN'] = row2.substring(52, 57);
1013+
1014+
//tests['SEG%'] = row2.substring(57, 62);
1015+
tests['NE'] = row2.substring(57, 62);
1016+
1017+
//tests['EOSIN%'] = row2.substring(62, 67);
1018+
tests['EO'] = row2.substring(62, 67);
1019+
1020+
//tests['BASO%'] = row2.substring(67, 72);
1021+
tests['BS'] = row2.substring(67, 72);
1022+
1023+
//tests['LYMPH#'] = row2.substring(72, 78);
1024+
//tests['MONO#'] = row2.substring(78, 84);
1025+
//tests['SEG#'] = row2.substring(84, 90);
1026+
//tests['EOSIN#'] = row2.substring(90, 96);
1027+
//tests['BASO#'] = row2.substring(96, 102);
1028+
//tests['RDW'] = row2.substring(102, 107);
1029+
tests['RDW-CV'] = row2.substring(102, 107);
1030+
tests['RDW-SD'] = row2.substring(107, 112);
1031+
//tests['PDW'] = row2.substring(112, 117);
1032+
tests['MPV'] = row2.substring(117, 122);
1033+
//tests['P-LCR'] = row2.substring(122, 127);
1034+
10341035

10351036
var value;
10361037
for(var test in tests){
10371038
var origVal = tests[test];
10381039
value = tests[test];
10391040

10401041
if (value.match(/^00(\d){4}$/)) {
1041-
tests[test] = value.substr(2,3) / 100;
1042+
tests[test] = value.substring(2,5) / 100;
10421043
}
10431044
//note: at the moment WBC is the only test with 6 chars, so this test is possibly redundant
10441045
else if (value.match(/^0(\d){4,}$/) && test=='WBC') {
1045-
tests[test] = value.substr(1,4) / 100;
1046+
tests[test] = value.substring(1,5) / 100;
10461047
}
10471048
else if (value.match(/^0\d{4}$/)){
10481049
if (test=='RBC') {
1049-
tests[test] = value.substr(1,3) / 100;
1050+
tests[test] = value.substring(1,4) / 100;
10501051
}
10511052
else if (test=='PLT') {
1052-
tests[test] = value.substr(1,3) / 1; //convert to number
1053+
tests[test] = value.substring(1,4) / 1; //convert to number
10531054
}
10541055
else {
1055-
tests[test] = value.substr(1,3) / 10;
1056+
tests[test] = value.substring(1,4) / 10;
10561057
}
10571058
}
10581059
else if (test=='PLT') {
1059-
tests[test] = value.substr(0,4);
1060+
tests[test] = value.substring(0,4);
10601061
}
10611062

10621063
//NOTE: the following is a possible replacement for the logic above

WNPRC_EHR/resources/web/wnprc_ehr/wnprcOverRides.js

Lines changed: 1 addition & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -819,243 +819,4 @@ EHR.Metadata.registerMetadata('NewAnimal', {
819819
}
820820
}
821821
}
822-
});
823-
824-
/*
825-
* This (the rest of this file) is a patch for the Hematology bulk add button, to fix issue WNPRC#4430.
826-
* However, as it duplicates code from ExtContainers.js and ehrGridFormPanel.js, it is only meant as
827-
* a temporary solution until a more permanent solution can be formulated.
828-
*/
829-
WNPRC_EHR.HematologyBulkAdd = Ext.extend(Ext.Panel, {
830-
initComponent: function() {
831-
Ext.applyIf(this, {
832-
title: 'Enter Hematology From Sysmex Analyzer',
833-
bodyBorder: true,
834-
border: true,
835-
bodyStyle: 'padding:5px',
836-
width: '100%',
837-
defaults: {
838-
border: false,
839-
bodyBorder: false
840-
},
841-
items: [
842-
{
843-
xtype: 'displayfield',
844-
value: 'This allows bulk import of hematology results using the output of a Sysmex Hematology Analyzer. Cut/paste the contents of the output below.'
845-
},{
846-
xtype: 'textarea',
847-
ref: 'fileField',
848-
height: 350,
849-
width: 430
850-
}
851-
],
852-
buttons: [{
853-
text:'Submit',
854-
disabled:false,
855-
ref: '../submit',
856-
scope: this,
857-
handler: function(s){
858-
this.processData();
859-
}
860-
},{
861-
text: 'Close',
862-
scope: this,
863-
handler: function(){
864-
this.ownerCt.hide();
865-
}
866-
}]
867-
});
868-
869-
EHR.ext.HematologyExcelWin.superclass.initComponent.call(this, arguments);
870-
},
871-
processData: function(){
872-
var data = this.fileField.getValue();
873-
874-
if (!data) {
875-
alert('Must Paste Contents of File');
876-
return;
877-
}
878-
879-
var skippedRows = [];
880-
881-
var hematologyResults = Ext.StoreMgr.get("study||Hematology Results||||");
882-
var runsStore = Ext.StoreMgr.get("study||Clinpath Runs||||");
883-
var unitStore = Ext.StoreMgr.get("ehr_lookups||hematology_tests||testid||testid");
884-
885-
var result;
886-
var tests;
887-
var row1;
888-
var row2;
889-
var toAdd = [];
890-
891-
if(!data.length || !data[0].length){
892-
alert('Something went wrong processing the file');
893-
console.log(data);
894-
return;
895-
}
896-
897-
data = data.split(/D1U/i);
898-
899-
Ext.each(data, function(row, idx){
900-
if(!row.match(/D2U/i))
901-
return;
902-
903-
row = row.split(/D2U/i);
904-
905-
row1 = row[0];
906-
row2 = row[1];
907-
row1 = row1.replace(/\s+/g, '');
908-
row2 = row2.split(/\s+/);
909-
row2 = row2.slice(2, row2.length-1);
910-
row2 = row2.join('');
911-
912-
result = {};
913-
tests = {};
914-
915-
result.animalId = row1.substr(27,6);
916-
result.animalId = result.animalId.toLowerCase();
917-
918-
var requestNumber = runsStore.find('Id',result.animalId)
919-
var record = runsStore.getAt(requestNumber);
920-
921-
//Getting the collection time from the request itself, if it matches animalId
922-
if(requestNumber!= -1 && result.animalId == record.get('Id')){
923-
924-
var collectionDate = record.get('date');
925-
}
926-
927-
result.date= new Date(collectionDate);
928-
929-
if(!result.animalId || runsStore.find('Id', result.animalId)==-1){
930-
//alert('ID: '+result.animalId+' not found in Clinpath Runs section. Records will not be added');
931-
skippedRows.push('Not found in Clinpath Runs: '+result.animalId);
932-
return;
933-
}
934-
935-
tests['WBC'] = row2.substr(6,6);
936-
tests['RBC'] = row2.substr(12,5);
937-
tests['HGB'] = row2.substr(17,5);
938-
tests['HCT'] = row2.substr(22,5);
939-
tests['MCV'] = row2.substr(27,5);
940-
tests['MCH'] = row2.substr(32,5);
941-
tests['MCHC'] = row2.substr(37,5);
942-
tests['PLT'] = row2.substr(42,5);
943-
//tests['LYMPH%'] = row2.substr(47,5);
944-
tests['LY'] = row2.substr(47,5);
945-
946-
//tests['MONO%'] = row2.substr(52,5);
947-
tests['MN'] = row2.substr(52,5);
948-
949-
//tests['SEG%'] = row2.substr(57,5);
950-
tests['NE'] = row2.substr(57,5);
951-
952-
//tests['EOSIN%'] = row2.substr(62,5);
953-
tests['EO'] = row2.substr(62,5);
954-
955-
//tests['BASO%'] = row2.substr(67,5);
956-
tests['BS'] = row2.substr(67,5);
957-
958-
//tests['LYMPH#'] = row2.substr(72,6);
959-
//tests['MONO#'] = row2.substr(78,6);
960-
//tests['SEG#'] = row2.substr(84,6);
961-
//tests['EOSIN#'] = row2.substr(90,6);
962-
//tests['BASO#'] = row2.substr(96,6);
963-
tests['RDW'] = row2.substr(102,5);
964-
//tests'RDW-CV'] = row2.substr(102,5);
965-
//tests['RDW-SD'] = row2.substr(107,5);
966-
//tests['PDW'] = row2.substr(112,5);
967-
tests['MPV'] = row2.substr(117,5);
968-
//tests['P-LCR'] = row2.substr(122,5);
969-
970-
var value;
971-
for(var test in tests){
972-
var origVal = tests[test];
973-
value = tests[test];
974-
975-
if (value.match(/^00(\d){4}$/)) {
976-
tests[test] = value.substr(2,3) / 100;
977-
}
978-
//note: at the moment WBC is the only test with 6 chars, so this test is possibly redundant
979-
else if (value.match(/^0(\d){4,}$/) && test=='WBC') {
980-
tests[test] = value.substr(1,4) / 100;
981-
}
982-
else if (value.match(/^0\d{4}$/)){
983-
if (test=='RBC') {
984-
tests[test] = value.substr(1,3) / 100;
985-
}
986-
else if (test=='PLT') {
987-
tests[test] = value.substr(1,3) / 1; //convert to number
988-
}
989-
else {
990-
tests[test] = value.substr(1,3) / 10;
991-
}
992-
}
993-
else if (test=='PLT') {
994-
tests[test] = value.substr(0,4);
995-
}
996-
997-
//find units
998-
var idx = unitStore.find('testid', test);
999-
var units = null;
1000-
var sortOrder = null;
1001-
if(idx!=-1){
1002-
units = unitStore.getAt(idx).get('units');
1003-
sortOrder = unitStore.getAt(idx).get('sort_order');
1004-
}
1005-
1006-
if(tests[test] && isNaN(tests[test])){
1007-
skippedRows.push('Invalid Result for: '+result.animalId+', TestId: '+test+', '+tests[test]);
1008-
tests[test] = null;
1009-
}
1010-
1011-
toAdd.push({
1012-
Id: result.animalId,
1013-
date: result.date,
1014-
testid: test,
1015-
result: tests[test],
1016-
units: units,
1017-
sortOrder: sortOrder
1018-
});
1019-
}
1020-
1021-
}, this);
1022-
1023-
if(toAdd.length){
1024-
toAdd.sort(function(a, b){
1025-
return a.Id < b.Id ? -1 :
1026-
a.Id > b.Id ? 1 :
1027-
a.date < b.date ? -1 :
1028-
a.date > b.date ? 1 :
1029-
a.sortOrder < b.sortOrder ? -1 :
1030-
a.sortOrder > b.sortOrder ? 1 :
1031-
0
1032-
});
1033-
hematologyResults.addRecords(toAdd);
1034-
}
1035-
1036-
if(skippedRows.length){
1037-
alert('One or more rows were skipped:\n'+skippedRows.join('\n'));
1038-
}
1039-
}
1040-
});
1041-
Ext.reg('wnprc_ehr-hematologybulkadd', WNPRC_EHR.HematologyBulkAdd);
1042-
1043-
/*
1044-
* Let Ctrl+x open the popup
1045-
*/
1046-
WNPRC_EHR.HematologyPopup = function() {
1047-
var popup = new Ext.Window({
1048-
closeAction:'hide',
1049-
width: 450,
1050-
items: [{
1051-
xtype: 'wnprc_ehr-hematologybulkadd'
1052-
}]
1053-
});
1054-
1055-
popup.show();
1056-
};
1057-
jQuery(document).on('keypress', function(e){
1058-
if (e.ctrlKey && (e.which == 24)) {
1059-
WNPRC_EHR.HematologyPopup();
1060-
}
1061-
});
822+
});

0 commit comments

Comments
 (0)