Extensions (LPP)
SmartForm Server-side Scripting Functions
Extensions can be used to perform server-side (cache) scripting, giving the ability to programmatically perform some data manipulation actions that are not supported within SmartForms. Most commonly, a particular type of SmartForm may not support display or editing of a specific patient data (EPT) record. To work with that information, it may be possible to manage a SmartData element within the form and to set the value of that element from the EPT record while loading the form, then return the SDE value the EPT record on closing the form.
Cache Code
Core data management functions draw from the "HULIB100" library for SmartForm scripting. Callable tags include:
SFReadOnly - Check if a form is read only
SFGetIDDAT - Get the context ID and DAT for a specific INI
SFGetCV - Get a concept (SDE) value
SFGetCVCmt - Load a SDE comment
SFPutCV - Set a SDE value
Parameters (comma delimited, quotes enclosed)
SDE identifier in AHS#NNNN format
Context: ENCOUNTER or PATIENT
SFPutCVCmt - Set a SDE comment
SFGetChron - Get a Chronicles value
SFPutChron - Set a Chronicles value
SFSetProp - Set a property on a component
SmartForm Script - Set Date Field
LPP 37963 (IP SMARTFORM SCRIPTING SET DEFAULT DATE) can be copied and used to set the value of a SmartForm Field of "Date" type (usually data bound to an SDE element). When this programming extension is added as a scripting action to the AfterDataLoaded event of the RootComponent, it will set a default date for the field when the form is loaded. The same functionality can be attached to other events (e.g., command buttons to set the date of a related field).
Parameters
SDE Identifier (AHS#NNN format)
SDE Context (use shift-F5 for values; can be PATIENT, NOTE, ENCOUNTER, EPISODE, etc.)
Relative date (use "T" or "T+N" syntax for days, weeks [W], months [MB])
Limitations
This function will only write to a null field. If a form field already has a date value, running the extension will have no effect. Be sure to include an action of clearing the field before resetting its value with the LPP.
The target SDE must be a plain Date field (not time, not instant).
Tricks
One can copy a SDE value (or an EPT value) to a temporary buffer field or label, work with the value, then copy it back to the SDE. This can be useful when trying to get around the inability of this function to write to a non-null field.
SmartForm Script - Set Label Caption from CER Message
LPP 42320 (ES SMARTFORM SET LABEL CAPTION) can be copied and used to set the caption of a SmartForm Label object.
Parameters
CER rule identifier (must return error message)
(optional extension to return text value)
Identifier of the SmartForm Label object where caption will be set
SmartForm Script - Set SmartForm Bound EPT Value from CER Message
LPP 42940 (ES SET RULE ERROR IN SMARTFORM FIELD) can be copied and used to set the value of a SmartForm Field object.
Parameters
CER rule identifier (must return error message)
EPT identifier
Limitations
Limited to SmartForms that can bind EPT data.
SmartForm Script - Append Values to a List
LPP 24516 (SMARTFORM APPEND VALUES) can be copied and used to add values to a List, SmartGrid or a SmartText Box component via SmartForm Scripting.
Parameters
SDE Identifiers (AHS#NNN format) of SDEs to append to the SmartForm
Values to append to respective SDEs; must be value values in valid format for the SmartForm setup
Context; which must match context for the SDEs in the SmartForm
Custom SmartForm Extensions
Rule to SmartData - Update SmartData element from error message from a rule
Parameters
SDE#ID - Smart Data Element Identifier
CONTEXT - match the context of the SmartForm: PATIENT = 1, ENCOUNTER = 2
Use
Single-select category or string to single select category or string
Code
s ln=1,data="" f { s val=$$SFGetCV^HULIB100("SDE#ID","CONTEXT",ln) s:val="" val=$$geti^EAXLIB("HLX",$o(^EX("HLX",40,val,"")),50,1,99999) q:val="" s data=data_$s(ln>1:", ",1:"")_val s ln=ln+1 q:ln>10 } d SFGetIDDAT^HULIB100("EPT",.patID,.patDAT) d SetFloValAry^JFSAPI3(.floValAry,patID,patDAT,FLT,FLO,"",$$time^%Zefnlib(),"",data) d storeSetup^JVITAL20(patID,patDAT,FLT,"","","",.floValAry)
SmartData to Flowsheet - Set Flowsheet Row Value from SDE Value - Category or String
Parameters
SDE#ID - Smart Data Element Identifier
CONTEXT - match the context of the SmartForm: PATIENT, ENCOUNTER, EPISODE, NOTE, ORDER, PROBLEM, etc.
FLT - Flowsheet Template identifier
FLO - Flowsheet Row identifier
Use
Single-select category or string to single select category or string
Code
s %=$$SFGetIDDAT^elibHULIB100("EPT",.ptID,.ptDAT) s val=$$SFGetCV^elibHULIB100("SDE#ID","CONTEXT",1) d SetFloValAry^JFSAPI3(.floValAry,ptID,ptDAT,FLT,FLO,"",$$time^%Zelibb(),"",val) d storeSetup^JVITAL20(ptID,ptDAT,FLT,0,"","",.floValAry)
SmartData to Flowsheet - Set Flowsheet Row Value from SDE Value - Date Only
Parameters
SDE#ID - Smart Data Element Identifier
CONTEXT - match the context of the SmartForm: PATIENT, ENCOUNTER, EPISODE, NOTE, ORDER, PROBLEM, etc.
FLT - Flowsheet Template identifier
FLO - Flowsheet Row identifier
Use
Date type SDE to Date formatted flowsheet row
Code
s val=$$zInst2DTE^%Zelibp($$SFGetCV^HULIB100("SDE#ID","CONTEXT",1)) d SFGetIDDAT^HULIB100("EPT",.patID,.patDAT) d SetFloValAry^JFSAPI3(.floValAry,patID,patDAT,FLT,FLO,"",$$time^%Zefnlib(),"",val) d storeSetup^JVITAL20(patID,patDAT,FLT,"","","",.floValAry)
SmartData to Flowsheet - Set Flowsheet Row Value from SDE Value - Multi-select
Parameters
SDE#ID - Smart Data Element Identifier
CONTEXT - match the context of the SmartForm: PATIENT, ENCOUNTER, EPISODE, NOTE, ORDER, PROBLEM, etc.
FLT - Flowsheet Template identifier
FLO - Flowsheet Row identifier
Use
Multi-select category or string to Multiselect flowsheet row
Code
s ln=1,data="" f { s val=$$SFGetCV^HULIB100("SDE#ID","CONTEXT",ln) s:val="" val=$$geti^EAXLIB("HLX",$o(^EX("HLX",40,val,"")),50,1,99999) q:val="" s data=data_$s(ln>1:", ",1:"")_val s ln=ln+1 q:ln>10 } d SFGetIDDAT^HULIB100("EPT",.patID,.patDAT) d SetFloValAry^JFSAPI3(.floValAry,patID,patDAT,FLT,FLO,"",$$time^%Zefnlib(),"",data) d storeSetup^JVITAL20(patID,patDAT,FLT,"","","",.floValAry)
SmartData to SmartData - Update one SmartData element from another (equivalent type) SDE
Parameters
FROMSDE#ID - Smart Data Element Identifier to get value from
TOSDE#ID - Smart Data Element identifier to update
CONTEXT - match the context of the SDE: PATIENT, ENCOUNTER
Use
Move data between similar type SDEs
Code
s %=$$SFGetIDDAT^elibHULIB100("EPT",.ptID,.ptDAT) s errMsg=$$SFGetCV^elibHULIB100("FROMSDE#ID","CONTEXT",1) s %=$$SFPutCV^elibHULIB100("TOSDE#ID","CONTEXT",errMsg)
Resources
Epic: Extension Search Report Template - to identify records using particular extensions
Epic Forum: Setting SmartForm Fields using Scripting and Extensions