Ever wonder how to calculate elapsed time in the EMR? The attached form demonstrates one approach to this often asked question. The .dlg is fully commented and the code simplified in the hope that all skill levels will be able to leverage the functionality.
Some notes (also found in the dlg):
Elapsed Time Calc uses the 12 hour clock for data entry
(not many are well versed in the 24 hour clock format) 1) Individual fields are required to ensure time is constructed using valid characters a. Hour field i. Field length limited to 2 characters 1. Will accept one digit entry ii. Numeric mask used (positive integer only) iii. Numeric Validation forced iv. Range Validation forced 1. Range Minimum 1 2. Range Maximum 12 3. Units hour b. Minute field i. Field length limited to 2 characters ii. Numeric mask used (positive integer only) iii. Due to the need to enter '00' minutes, cannot use numeric or range validation 1. MEL watcher used to validate max minutes is 59 a. Numeric mask prevents entering negative numbers 2. MEL watcher is used to validate size of minutes a. Two digits are always required c. AM/PM field i. Required field for conversion to 24 hour clock 2) Hidden fields a. Start Time - value built using MEL watcher b. Stop Time - value built using MEL watcher c. Elapsed Time - value built when button is clicked and function is run 3) Button to trigger function a. Using a watcher will cause function to issue warning messages that are needed for data entry errors
Be certain to review all elements of the form for the appropriate settings as well as the MEL code.
Enjoy!
While this does have nice functionality, I am having difficulty suppressing the text translation for the Start and Stop time if nothing is entered. Suppression blocks don't seem to be working here.
The form is a demo form created to be used as an example for individual use. It is not intended to be used in a live update, hence why it is not 'production ready'. Typically, this functionality would be incorporated into an existing form in an effort to reduce impact on already familiar workflow.
You can always use a bit of MEL code to ensure a translation is not generated if you want to use the form 'as is'.
I.e:
{if DOCUMENT.START_TIME <> "" and DOCUMENT.STOP_TIME <> "" then CFMT(....) else "" endif}