EDPWSLM ;SLC/KCM - Load & Register Models ;2/28/12 08:33am
;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
;
BLDMDL(EDPCTXT,MIENS,MODELS) ; Build models as array to convert to XML
; returned XML will be:
;
; <model name={full class name} type={visit|reference}>
; <data>{xml specific for this model}</data>
; <state>{xml for uncommitted state for this model}</state>
; </model>
; ...
;
; Structures to track which models have been sent to client:
;
; ^XTMP("EDPWSV-dfn-session",0)=DT+1^DT^EDIS Visit Models
; ^XTMP("EDPWSV-dfn-session",IEN)=1 if fresh ^ DUZ
; ^XTMP("EDPWSR-area-session",0)=DT+1^DT
; ^XTMP("EDPWSR-area-session",IEN)=1 if fresh ^ DUZ
;
; Structure to keep uncommitted state
;
; ^XTMP("EDPWS-dfn-duz",IEN,n)={uncommitted data XML}
;
; Models desired: MIENS(ptr 232.72)=""
;
N IEN,VROOT,RROOT,WROOT,MTYPE,LOADCALL
S VROOT="EDPWSV-"_EDPCTXT("dfn")_"-"_EDPCTXT("session")
S RROOT="EDPWSR-"_EDPCTXT("area")_"-"_EDPCTXT("session")
S WROOT="EDPWS-"_EDPCTXT("dfn")_"-"_DUZ
S IEN=0 F S IEN=$O(MIENS(IEN)) Q:'IEN D ; loop thru models req'd by client
. S MTYPE=$P(^EDPB(232.72,IEN,0),U,4)
. I MTYPE="V",$G(^XTMP(VROOT,IEN)) Q ; client visit model still fresh
. I MTYPE="R",$G(^XTMP(RROOT,IEN)) Q ; client ref model still fresh
. S EDPCTXT("model")=IEN
. S LOADCALL=$P($G(^EDPB(232.72,IEN,1)),U,1,2)
. Q:'$L(LOADCALL)
. I $P(^EDPB(232.72,IEN,1),U,3) D
. . N EDPXML
. . D @(LOADCALL_"(.EDPCTXT)")
. . D TOARR^EDPXML(.EDPXML,.EDPDATA)
. E D @(LOADCALL_"(.EDPCTXT,.EDPDATA)")
. I $D(EDPDATA) M MODELS("model",IEN,"data",1)=EDPDATA
. K EDPDATA
. ; add any uncommitted state
. I $D(^XTMP(WROOT,IEN))>1 M MODELS("model",IEN,"state",1)=^XTMP(WROOT,IEN)
;
; NOTE: when updating the structures that track models
; F S X=$O(^XTMP("EDPWSV-dfn")) Q:$P(X,"-",2)'=DFN D
; . S ^XTMP(X,moniker)=0 ; check DUZ, logID etc.
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPWSLM 1937 printed Nov 22, 2024@17:02:44 Page 2
EDPWSLM ;SLC/KCM - Load & Register Models ;2/28/12 08:33am
+1 ;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
+2 ;
BLDMDL(EDPCTXT,MIENS,MODELS) ; Build models as array to convert to XML
+1 ; returned XML will be:
+2 ;
+3 ; <model name={full class name} type={visit|reference}>
+4 ; <data>{xml specific for this model}</data>
+5 ; <state>{xml for uncommitted state for this model}</state>
+6 ; </model>
+7 ; ...
+8 ;
+9 ; Structures to track which models have been sent to client:
+10 ;
+11 ; ^XTMP("EDPWSV-dfn-session",0)=DT+1^DT^EDIS Visit Models
+12 ; ^XTMP("EDPWSV-dfn-session",IEN)=1 if fresh ^ DUZ
+13 ; ^XTMP("EDPWSR-area-session",0)=DT+1^DT
+14 ; ^XTMP("EDPWSR-area-session",IEN)=1 if fresh ^ DUZ
+15 ;
+16 ; Structure to keep uncommitted state
+17 ;
+18 ; ^XTMP("EDPWS-dfn-duz",IEN,n)={uncommitted data XML}
+19 ;
+20 ; Models desired: MIENS(ptr 232.72)=""
+21 ;
+22 NEW IEN,VROOT,RROOT,WROOT,MTYPE,LOADCALL
+23 SET VROOT="EDPWSV-"_EDPCTXT("dfn")_"-"_EDPCTXT("session")
+24 SET RROOT="EDPWSR-"_EDPCTXT("area")_"-"_EDPCTXT("session")
+25 SET WROOT="EDPWS-"_EDPCTXT("dfn")_"-"_DUZ
+26 ; loop thru models req'd by client
SET IEN=0
FOR
SET IEN=$ORDER(MIENS(IEN))
if 'IEN
QUIT
Begin DoDot:1
+27 SET MTYPE=$PIECE(^EDPB(232.72,IEN,0),U,4)
+28 ; client visit model still fresh
IF MTYPE="V"
IF $GET(^XTMP(VROOT,IEN))
QUIT
+29 ; client ref model still fresh
IF MTYPE="R"
IF $GET(^XTMP(RROOT,IEN))
QUIT
+30 SET EDPCTXT("model")=IEN
+31 SET LOADCALL=$PIECE($GET(^EDPB(232.72,IEN,1)),U,1,2)
+32 if '$LENGTH(LOADCALL)
QUIT
+33 IF $PIECE(^EDPB(232.72,IEN,1),U,3)
Begin DoDot:2
+34 NEW EDPXML
+35 DO @(LOADCALL_"(.EDPCTXT)")
+36 DO TOARR^EDPXML(.EDPXML,.EDPDATA)
End DoDot:2
+37 IF '$TEST
DO @(LOADCALL_"(.EDPCTXT,.EDPDATA)")
+38 IF $DATA(EDPDATA)
MERGE MODELS("model",IEN,"data",1)=EDPDATA
+39 KILL EDPDATA
+40 ; add any uncommitted state
+41 IF $DATA(^XTMP(WROOT,IEN))>1
MERGE MODELS("model",IEN,"state",1)=^XTMP(WROOT,IEN)
End DoDot:1
+42 ;
+43 ; NOTE: when updating the structures that track models
+44 ; F S X=$O(^XTMP("EDPWSV-dfn")) Q:$P(X,"-",2)'=DFN D
+45 ; . S ^XTMP(X,moniker)=0 ; check DUZ, logID etc.
+46 QUIT