EDPWSL ;SLC/KCM - Load Worksheet and Models ;3/1/12 10:43am
;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
;
LOAD(REQ) ; Load Worksheet and Models (data)
; expected: area, log, role, dfn
; optional: worksheet, preserve XML
;
; -- save the previous worksheet state, if any
D PRESERVE^EDPWSP(.REQ)
; -- set context
N EDPCTXT,WKS,MIENS,SPEC,MODELS
D SETCTXT(.EDPCTXT,.REQ)
DB ; -- determine worksheet
S WKS=$G(REQ("worksheet",1))
I 'WKS S WKS=$$DFLTWKS(EDPCTXT("role"),EDPCTXT("area"))
I 'WKS D XML^EDPX("<worksheet />") Q ;TODO -- trigger error section?
;
D BLDWS(WKS,.SPEC,.MIENS)
D BLDMDL^EDPWSLM(.EDPCTXT,.MIENS,.MODELS)
; put it all together and return the XML
M MODELS("worksheet",1)=SPEC K SPEC
D TOXML^EDPXML(.MODELS,.EDPXML) K MODELS
Q
DFLTWKS(ROLE,AREA) ; Return default worksheet for this role
N IEN S IEN=$O(^EDPB(232.5,"C",EDPSITE,AREA,ROLE,0))
Q:'IEN 0
Q $P(^EDPB(232.5,IEN,0),U,4)
;
BLDWS(WSID,SPEC,MIENS) ; build XML for worksheet
;
; returned XML:
;
; <worksheet id={worksheetIEN} name={worksheetName} scroll={lastScrollPos}>
; <section detailPlugin={full class name} displayName={name} id={sectionIEN}
; initialOpen={false|true} summaryPlugin={full class name} taskType={1|2|3} >
; <config>{configuration XML for plugin</config>
; <state>{visual state XML</state>
; <model id={modelIEN} name={full class name for required model}/>
; ...
; </section>
; ...
; </worksheet>
;
; worksheet state saved in:
;
; ^XTMP("EDPWS-dfn-duz",0)=DT+7^DT^Worksheet State
; ^XTMP("EDPWS-dfn-duz",worksheetID)={scroll position}
; ^XTMP("EDPWS-dfn-duz",worksheetID,sectionID)={isOpen}
; ^XTMP("EDPWS-dfn-duz",worksheetID,sectionID,n)={visual state XML}
; ^XTMP("EDPWS-dfn-duz",modelID,n)={uncommitted data XML}
;
N SEQ,SEQ1,SECID,WROOT
; -- load the worksheet spec
D GETWKS^EDPBWS(WSID,.SPEC)
S WROOT="EDPWS-"_EDPCTXT("dfn")_"-"_DUZ
S SPEC("scroll")=+$G(^XTMP(WROOT,WSID))
; -- iterate thru loaded sections
S SEQ=0 F S SEQ=$O(SPEC("section",SEQ)) Q:'SEQ D
. S SECID=SPEC("section",SEQ,"id")
. ; -- apply visual state to section
. I $D(^XTMP(WROOT,WSID,SECID)) D
. . S SPEC("section",SEQ,"initialOpen")=$G(^XTMP(WROOT,WSID,SECID),SPEC("section",SEQ,"initialOpen"))
. . ; TODO: load the XML visual state
. ; -- build list of unique models
. S SEQ1=0 F S SEQ1=$O(SPEC("section",SEQ,"model",SEQ1)) Q:'SEQ1 D
. . S MIENS(SPEC("section",SEQ,"model",SEQ1,"id"))=""
Q
SETCTXT(EDPCTXT,REQ) ; Set the context from the request
S EDPCTXT("area")=$G(REQ("area",1))
S EDPCTXT("log")=$G(REQ("log",1))
S EDPCTXT("dfn")=$G(REQ("dfn",1))
S EDPCTXT("role")=$G(REQ("role",1))
S EDPCTXT("session")=$G(REQ("session",1))
Q
TEST ;
S EDPSITE=DUZ(2)
S REQ("area",1)=1
S REQ("log",1)=11
S REQ("dfn",1)=100642
S REQ("role",1)=459
S REQ("session",1)=12345
D LOAD(.REQ)
;ZW EDPXML
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPWSL 2953 printed Dec 13, 2024@01:52:33 Page 2
EDPWSL ;SLC/KCM - Load Worksheet and Models ;3/1/12 10:43am
+1 ;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
+2 ;
LOAD(REQ) ; Load Worksheet and Models (data)
+1 ; expected: area, log, role, dfn
+2 ; optional: worksheet, preserve XML
+3 ;
+4 ; -- save the previous worksheet state, if any
+5 DO PRESERVE^EDPWSP(.REQ)
+6 ; -- set context
+7 NEW EDPCTXT,WKS,MIENS,SPEC,MODELS
+8 DO SETCTXT(.EDPCTXT,.REQ)
DB ; -- determine worksheet
+1 SET WKS=$GET(REQ("worksheet",1))
+2 IF 'WKS
SET WKS=$$DFLTWKS(EDPCTXT("role"),EDPCTXT("area"))
+3 ;TODO -- trigger error section?
IF 'WKS
DO XML^EDPX("<worksheet />")
QUIT
+4 ;
+5 DO BLDWS(WKS,.SPEC,.MIENS)
+6 DO BLDMDL^EDPWSLM(.EDPCTXT,.MIENS,.MODELS)
+7 ; put it all together and return the XML
+8 MERGE MODELS("worksheet",1)=SPEC
KILL SPEC
+9 DO TOXML^EDPXML(.MODELS,.EDPXML)
KILL MODELS
+10 QUIT
DFLTWKS(ROLE,AREA) ; Return default worksheet for this role
+1 NEW IEN
SET IEN=$ORDER(^EDPB(232.5,"C",EDPSITE,AREA,ROLE,0))
+2 if 'IEN
QUIT 0
+3 QUIT $PIECE(^EDPB(232.5,IEN,0),U,4)
+4 ;
BLDWS(WSID,SPEC,MIENS) ; build XML for worksheet
+1 ;
+2 ; returned XML:
+3 ;
+4 ; <worksheet id={worksheetIEN} name={worksheetName} scroll={lastScrollPos}>
+5 ; <section detailPlugin={full class name} displayName={name} id={sectionIEN}
+6 ; initialOpen={false|true} summaryPlugin={full class name} taskType={1|2|3} >
+7 ; <config>{configuration XML for plugin</config>
+8 ; <state>{visual state XML</state>
+9 ; <model id={modelIEN} name={full class name for required model}/>
+10 ; ...
+11 ; </section>
+12 ; ...
+13 ; </worksheet>
+14 ;
+15 ; worksheet state saved in:
+16 ;
+17 ; ^XTMP("EDPWS-dfn-duz",0)=DT+7^DT^Worksheet State
+18 ; ^XTMP("EDPWS-dfn-duz",worksheetID)={scroll position}
+19 ; ^XTMP("EDPWS-dfn-duz",worksheetID,sectionID)={isOpen}
+20 ; ^XTMP("EDPWS-dfn-duz",worksheetID,sectionID,n)={visual state XML}
+21 ; ^XTMP("EDPWS-dfn-duz",modelID,n)={uncommitted data XML}
+22 ;
+23 NEW SEQ,SEQ1,SECID,WROOT
+24 ; -- load the worksheet spec
+25 DO GETWKS^EDPBWS(WSID,.SPEC)
+26 SET WROOT="EDPWS-"_EDPCTXT("dfn")_"-"_DUZ
+27 SET SPEC("scroll")=+$GET(^XTMP(WROOT,WSID))
+28 ; -- iterate thru loaded sections
+29 SET SEQ=0
FOR
SET SEQ=$ORDER(SPEC("section",SEQ))
if 'SEQ
QUIT
Begin DoDot:1
+30 SET SECID=SPEC("section",SEQ,"id")
+31 ; -- apply visual state to section
+32 IF $DATA(^XTMP(WROOT,WSID,SECID))
Begin DoDot:2
+33 SET SPEC("section",SEQ,"initialOpen")=$GET(^XTMP(WROOT,WSID,SECID),SPEC("section",SEQ,"initialOpen"))
+34 ; TODO: load the XML visual state
End DoDot:2
+35 ; -- build list of unique models
+36 SET SEQ1=0
FOR
SET SEQ1=$ORDER(SPEC("section",SEQ,"model",SEQ1))
if 'SEQ1
QUIT
Begin DoDot:2
+37 SET MIENS(SPEC("section",SEQ,"model",SEQ1,"id"))=""
End DoDot:2
End DoDot:1
+38 QUIT
SETCTXT(EDPCTXT,REQ) ; Set the context from the request
+1 SET EDPCTXT("area")=$GET(REQ("area",1))
+2 SET EDPCTXT("log")=$GET(REQ("log",1))
+3 SET EDPCTXT("dfn")=$GET(REQ("dfn",1))
+4 SET EDPCTXT("role")=$GET(REQ("role",1))
+5 SET EDPCTXT("session")=$GET(REQ("session",1))
+6 QUIT
TEST ;
+1 SET EDPSITE=DUZ(2)
+2 SET REQ("area",1)=1
+3 SET REQ("log",1)=11
+4 SET REQ("dfn",1)=100642
+5 SET REQ("role",1)=459
+6 SET REQ("session",1)=12345
+7 DO LOAD(.REQ)
+8 ;ZW EDPXML
+9 QUIT