1313 * @cfg defaultTemplate
1414 * @cfg allowChooseIds
1515 * @cfg idSelectionMode
16+ * @cfg showDate
1617 */
1718Ext4 . define ( 'EHR.window.ApplyTemplateWindow' , {
1819 extend : 'Ext.window.Window' ,
1920 allowChooseIds : true ,
2021 idSelectionMode : 'multi' ,
2122 title : 'Apply Template' ,
2223 closeAction : 'destroy' ,
24+ showDate : true ,
2325
2426 initComponent : function ( ) {
2527 Ext4 . applyIf ( this , {
@@ -91,16 +93,28 @@ Ext4.define('EHR.window.ApplyTemplateWindow', {
9193 helpPopup : 'If checked, you will be prompted with a screen that lets you bulk edit the records that will be created. This is often very useful when adding many similar records.' ,
9294 itemId : 'customizeValues' ,
9395 checked : false
94- } , this . getIdSelectionItems ( ) , {
95- xtype : 'xdatetime' ,
96- fieldLabel : 'Date (optional)' ,
97- itemId : 'dateField' ,
98- value : null
99- } ] ;
96+ } ,
97+ this . getIdSelectionItems ( ) ,
98+ this . getDateItem ( )
99+ ] ;
100100
101101 return items ;
102102 } ,
103103
104+ getDateItem : function ( ) {
105+ if ( this . showDate === false ) {
106+ return { }
107+ }
108+ else {
109+ return {
110+ xtype : 'xdatetime' ,
111+ fieldLabel : 'Date (optional)' ,
112+ itemId : 'dateField' ,
113+ value : null
114+ }
115+ }
116+ } ,
117+
104118 getIdSelectionItems : function ( ) {
105119 if ( this . idSelectionMode == 'single' ) {
106120 return {
@@ -243,32 +257,33 @@ Ext4.define('EHR.window.ApplyTemplateWindow', {
243257 } ,
244258
245259 getInitialRecordValues : function ( ) {
246- var ret = [ ] ;
247- var date = this . down ( '#dateField' ) . getValue ( ) ;
248- var obj = {
249- date : date
250- } ;
260+ const ret = [ ] ;
261+ const dateField = this . down ( '#dateField' ) ;
262+ const obj = { } ;
263+ if ( dateField ) {
264+ obj . date = dateField . getValue ( ) ;
265+ }
251266
252267 if ( this . down ( '#subjectIds' ) ) {
253- var subjectArray = LDK . Utils . splitIds ( this . down ( '#subjectIds' ) . getValue ( ) , true ) ;
268+ const subjectArray = LDK . Utils . splitIds ( this . down ( '#subjectIds' ) . getValue ( ) , true ) ;
254269 Ext4 . Array . each ( subjectArray , function ( subj ) {
255270 ret . push ( Ext4 . apply ( {
256271 Id : subj
257272 } , obj ) ) ;
258273 } , this ) ;
259274 }
260275 else if ( this . down ( '#encounterRecords' ) ) {
261- var combo = this . down ( '#encounterRecords' ) ;
262- var encounterIds = combo . getValue ( ) || [ ] ;
276+ const combo = this . down ( '#encounterRecords' ) ;
277+ const encounterIds = combo . getValue ( ) || [ ] ;
263278 if ( ! encounterIds . length ) {
264279 Ext4 . Msg . alert ( 'Error' , 'Must choose at least one procedure' ) ;
265280 return ;
266281 }
267282
268283 Ext4 . Array . forEach ( encounterIds , function ( encounterId ) {
269- var recIdx = combo . store . findExact ( 'parentid' , encounterId ) ;
284+ const recIdx = combo . store . findExact ( 'parentid' , encounterId ) ;
270285 if ( recIdx != - 1 ) {
271- var rec = combo . store . getAt ( recIdx ) ;
286+ const rec = combo . store . getAt ( recIdx ) ;
272287 ret . push ( {
273288 Id : rec . get ( 'Id' ) ,
274289 date : rec . get ( 'date' ) ,
@@ -470,7 +485,8 @@ EHR.DataEntryUtils.registerGridButton('TEMPLATE', function(config){
470485 idSelectionMode : menuBtn . idSelectionMode || 'multi' ,
471486 targetGrid : this . grid ,
472487 formType : this . grid . formConfig . name ,
473- defaultTemplate : btn . templateId
488+ defaultTemplate : btn . templateId ,
489+ showDate : menuBtn . showDate || true
474490 } ) . show ( ) ;
475491 }
476492 } )
@@ -510,13 +526,15 @@ EHR.DataEntryUtils.registerGridButton('TEMPLATE', function(config){
510526 Ext4 . create ( 'EHR.window.ApplyTemplateWindow' , {
511527 targetGrid : grid ,
512528 formType : grid . formConfig . name ,
513- idSelectionMode : menu . idSelectionMode || 'multi'
529+ idSelectionMode : menu . idSelectionMode || 'multi' ,
530+ showDate : menu . showDate ?? true
514531 } ) . show ( ) ;
515532 }
516533 } , {
517534 text : 'Templates' ,
518535 itemId : 'templatesMenu' ,
519536 idSelectionMode : config . idSelectionMode ,
537+ showDate : config . showDate ,
520538 menu : [ ]
521539 } ]
522540 }
@@ -531,6 +549,15 @@ EHR.DataEntryUtils.registerGridButton('TEMPLATE_NO_ID', function(config){
531549 return Ext4 . apply ( cfg , config ) ;
532550} ) ;
533551
552+ EHR . DataEntryUtils . registerGridButton ( 'TEMPLATE_NO_ID_NO_DATE' , function ( config ) {
553+ var cfg = EHR . DataEntryUtils . getGridButton ( 'TEMPLATE' , {
554+ idSelectionMode : 'none' ,
555+ showDate : false
556+ } ) ;
557+
558+ return Ext4 . apply ( cfg , config ) ;
559+ } ) ;
560+
534561EHR . DataEntryUtils . registerGridButton ( 'TEMPLATE_ENCOUNTER' , function ( config ) {
535562 var cfg = EHR . DataEntryUtils . getGridButton ( 'TEMPLATE' , {
536563 idSelectionMode : 'encounter'
0 commit comments