EDPWSP ;SLC/KCM - Preserve Worksheet State ;3/1/12 10:40am
;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
;
PRESERVE(REQ) ; loop thru XML and preserve nodes for each model/plugin
;
; Source (XML passed in via REQ("preserve",n)):
;
; <worksheet id={worksheetIEN} scroll={scrollPosition}>
; <section id={sectionIEN} open={true|false}>
; <state>{XML for visual state of plugin}</state>
; </section>
; ...
; </worksheet>
; <models>
; <model name={unique name} >
; <state>{uncommitted data}</state>
; </model>
; ...
; </models>
;
; Destination:
;
; ^XTMP("EDPWSS-log-duz",0)=DT+7^DT^Worksheet State
; ^XTMP("EDPWSS-log-duz",worksheetID)={scroll position}
; ^XTMP("EDPWSS-log-duz",worksheetID,sectionID)={isOpen}
; ^XTMP("EDPWSS-log-duz",worksheetID,sectionID,...)={visual state XML}
; ^XTMP("EDPWSS-log-duz",modelID,...)={uncommitted data XML}
;
N WSXML,STATE,XROOT,LOG
M WSXML=REQ("preserve") K REQ("preserve")
D TOARR^EDPXML(.WSXML,.STATE,"preserve") K WSXML
S LOG=$G(REQ("log",1)) Q:'LOG
S XROOT="EDPWSS-"_LOG_"-"_DUZ
S ^XTMP(XROOT,0)=$$FMADD^XLFDT(DT,1)_U_DT_U_"EDIS Worksheet State"
D PWORKS,PMODEL
Q
PWORKS ; preserve worksheet state
; from: PRESERVE
; expects: STATE,XROOT
N WKS,SCROLL,I,SEC,SECS,OPEN
S WKS=$G(STATE("worksheet",1,"id")) Q:'WKS
S SCROLL=$G(STATE("worksheet",1,"scroll"),0)
S I=0 F S I=$O(STATE("worksheet",1,"section",I)) Q:'I D
. S SEC=$G(STATE("worksheet",1,"section",I,"id")) Q:'SEC
. S OPEN=$G(STATE("worksheet",1,"section",I,"open"))
. S SECS(SEC)=OPEN
. M SECS(SEC)=STATE("worksheet",1,"section",I,"state",1)
S ^XTMP(XROOT,WKS)=SCROLL
M ^XTMP(XROOT,WKS)=SECS
Q
PMODEL ; preserve state for models
; from: PRESERVE
; expects: STATE,XROOT
N I,MODEL
S I=0 F S I=$O(STATE("models",1,"model",I)) Q:'I D
. S MODEL=$G(STATE("models",1,"model",I,"id")) Q:'MODEL
. M ^XTMP(XROOT,MODEL)=STATE("models",1,"section",I,"state",1)
Q
SAVE(REQ) ; Save the uncommitted models from the worksheet
N WSXML,STATE,VROOT,EDPCTXT
M WSXML=REQ("preserve") K REQ("preserve")
D TOARR^EDPXML(.WSXML,.STATE,"preserve") K WSXML
D SETCTXT^EDPWSL(.EDPCTXT,.REQ)
;
N I,MODEL,EDPDATA,SAVECALL
S I=0 F S I=$O(STATE("models",1,"model",I)) Q:'I D
. S MODEL=$G(STATE("models",1,"model",I,"id")) Q:'MODEL
. M EDPDATA=STATE("models",1,"section",I,"state",1)
. S SAVECALL=$P($G(^EDPB(232.72,MODEL,2)),U,1,2) Q:'$L(SAVECALL)
. D @(SAVECALL_"(.EDPCTXT,.EDPDATA)")
. I $G(^XTMP(VROOT,EDPCTXT("log"),MODEL)) S ^XTMP(VROOT,EDPCTXT("log"),MODEL)=0
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPWSP 2594 printed Nov 22, 2024@17:02:44 Page 2
EDPWSP ;SLC/KCM - Preserve Worksheet State ;3/1/12 10:40am
+1 ;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
+2 ;
PRESERVE(REQ) ; loop thru XML and preserve nodes for each model/plugin
+1 ;
+2 ; Source (XML passed in via REQ("preserve",n)):
+3 ;
+4 ; <worksheet id={worksheetIEN} scroll={scrollPosition}>
+5 ; <section id={sectionIEN} open={true|false}>
+6 ; <state>{XML for visual state of plugin}</state>
+7 ; </section>
+8 ; ...
+9 ; </worksheet>
+10 ; <models>
+11 ; <model name={unique name} >
+12 ; <state>{uncommitted data}</state>
+13 ; </model>
+14 ; ...
+15 ; </models>
+16 ;
+17 ; Destination:
+18 ;
+19 ; ^XTMP("EDPWSS-log-duz",0)=DT+7^DT^Worksheet State
+20 ; ^XTMP("EDPWSS-log-duz",worksheetID)={scroll position}
+21 ; ^XTMP("EDPWSS-log-duz",worksheetID,sectionID)={isOpen}
+22 ; ^XTMP("EDPWSS-log-duz",worksheetID,sectionID,...)={visual state XML}
+23 ; ^XTMP("EDPWSS-log-duz",modelID,...)={uncommitted data XML}
+24 ;
+25 NEW WSXML,STATE,XROOT,LOG
+26 MERGE WSXML=REQ("preserve")
KILL REQ("preserve")
+27 DO TOARR^EDPXML(.WSXML,.STATE,"preserve")
KILL WSXML
+28 SET LOG=$GET(REQ("log",1))
if 'LOG
QUIT
+29 SET XROOT="EDPWSS-"_LOG_"-"_DUZ
+30 SET ^XTMP(XROOT,0)=$$FMADD^XLFDT(DT,1)_U_DT_U_"EDIS Worksheet State"
+31 DO PWORKS
DO PMODEL
+32 QUIT
PWORKS ; preserve worksheet state
+1 ; from: PRESERVE
+2 ; expects: STATE,XROOT
+3 NEW WKS,SCROLL,I,SEC,SECS,OPEN
+4 SET WKS=$GET(STATE("worksheet",1,"id"))
if 'WKS
QUIT
+5 SET SCROLL=$GET(STATE("worksheet",1,"scroll"),0)
+6 SET I=0
FOR
SET I=$ORDER(STATE("worksheet",1,"section",I))
if 'I
QUIT
Begin DoDot:1
+7 SET SEC=$GET(STATE("worksheet",1,"section",I,"id"))
if 'SEC
QUIT
+8 SET OPEN=$GET(STATE("worksheet",1,"section",I,"open"))
+9 SET SECS(SEC)=OPEN
+10 MERGE SECS(SEC)=STATE("worksheet",1,"section",I,"state",1)
End DoDot:1
+11 SET ^XTMP(XROOT,WKS)=SCROLL
+12 MERGE ^XTMP(XROOT,WKS)=SECS
+13 QUIT
PMODEL ; preserve state for models
+1 ; from: PRESERVE
+2 ; expects: STATE,XROOT
+3 NEW I,MODEL
+4 SET I=0
FOR
SET I=$ORDER(STATE("models",1,"model",I))
if 'I
QUIT
Begin DoDot:1
+5 SET MODEL=$GET(STATE("models",1,"model",I,"id"))
if 'MODEL
QUIT
+6 MERGE ^XTMP(XROOT,MODEL)=STATE("models",1,"section",I,"state",1)
End DoDot:1
+7 QUIT
SAVE(REQ) ; Save the uncommitted models from the worksheet
+1 NEW WSXML,STATE,VROOT,EDPCTXT
+2 MERGE WSXML=REQ("preserve")
KILL REQ("preserve")
+3 DO TOARR^EDPXML(.WSXML,.STATE,"preserve")
KILL WSXML
+4 DO SETCTXT^EDPWSL(.EDPCTXT,.REQ)
+5 ;
+6 NEW I,MODEL,EDPDATA,SAVECALL
+7 SET I=0
FOR
SET I=$ORDER(STATE("models",1,"model",I))
if 'I
QUIT
Begin DoDot:1
+8 SET MODEL=$GET(STATE("models",1,"model",I,"id"))
if 'MODEL
QUIT
+9 MERGE EDPDATA=STATE("models",1,"section",I,"state",1)
+10 SET SAVECALL=$PIECE($GET(^EDPB(232.72,MODEL,2)),U,1,2)
if '$LENGTH(SAVECALL)
QUIT
+11 DO @(SAVECALL_"(.EDPCTXT,.EDPDATA)")
+12 IF $GET(^XTMP(VROOT,EDPCTXT("log"),MODEL))
SET ^XTMP(VROOT,EDPCTXT("log"),MODEL)=0
End DoDot:1
+13 QUIT