@@ -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 ( / D 1 U / i) ;
898-
899- Ext . each ( data , function ( row , idx ) {
900- if ( ! row . match ( / D 2 U / i) )
901- return ;
902-
903- row = row . split ( / D 2 U / 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 ( / ^ 0 0 ( \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