EDPQLW ;SLC/KCM - Retrieve Log Entry for Worksheet ;2/28/12 08:33am
;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
;
LOAD(CTXT,ARRAY) ; create XML for log entry
N LOG S LOG=CTXT("log")
N AREA S AREA=$P(^EDP(230,LOG,0),U,3)
N EDPTIME S EDPTIME=$$NOW^XLFDT
N EDPNOVAL S EDPNOVAL=+$O(^EDPB(233.1,"B","edp.reserved.novalue",0))
N X,X0,X1,X3
;
L +^EDP(230,LOG):3
S X0=^EDP(230,LOG,0),X1=$G(^(1)),X3=$G(^(3))
D XMLTS("loadTS",$$NOW^XLFDT)
;S X("loadTS")=$$NOW^XLFDT
L -^EDP(230,LOG)
;
D XMLPTR("log",LOG,"")
D XMLBOOL("closed",$P(X0,U,7))
D XMLTS("inTS",$P(X0,U,8))
D XMLTS("outTS",$P(X0,U,9))
D XMLCODE("arrival",$P(X0,U,10))
D XMLPTR("visit",$P(X0,U,12),"")
N CLIN S CLIN=$P(X0,U,14)
I CLIN D XMLPTR("clinic",CLIN,$P($G(^SC(CLIN,0)),U))
D XMLTEXT("complaint",$P(X1,U,1))
D XMLTEXT("compLong",$G(^EDP(230,LOG,2)))
D XMLCODE("status",$P(X3,U,2))
D XMLCODE("acuity",$P(X3,U,3))
D XMLPTR("bed",$P(X3,U,4),$P($G(^EDPB(231.8,+$P(X3,U,4),0)),U,6))
D XMLPERS("md",$P(X3,U,5))
D XMLPERS("nurse",$P(X3,U,6))
D XMLPERS("res",$P(X3,U,7))
D XMLTEXT("comment",$P(X3,U,8))
D XMLCODE("delay",$P(X1,U,5))
D XMLCODE("disposition",$P(X1,U,2))
D XMLTEXT("required",$$REQ^EDPQLE(.X))
N CURBED S CURBED=$P(X3,U,4)
Q
REFS(AREA) ; create XML for log entry references
Q
XMLCODE(ELEMENT,ID) ; add XML node for coded value
Q:'ID Q:ID=EDPNOVAL
N ECODE S ECODE=$P($G(^EDPB(233.1,ID,0)),U,2) ;TODO: lookup site name
S ARRAY(ELEMENT,1,"id")=ID
S:$L(ECODE) ARRAY(ELEMENT,1,"name")=ECODE
;D XMLOUT(ELEMENT,"id",ID,ECODE)
Q
XMLPERS(ELEMENT,ID) ; add XML node for person
Q:'ID
N NAME S NAME=$P($G(^VA(200,ID,0)),U)
S ARRAY(ELEMENT,1,"id")=ID
S:$L(NAME) ARRAY(ELEMENT,1,"name")=NAME
;D XMLOUT(ELEMENT,"id",ID,$P($G(^VA(200,ID,0)),U))
Q
XMLPTR(ELEMENT,ID,NAME) ; add XML node for a pointer value
S ARRAY(ELEMENT,1,"id")=ID
S:$L(NAME) ARRAY(ELEMENT,1,"name")=NAME
;D XMLOUT(ELEMENT,"id",ID,NAME)
Q
XMLTEXT(ELEMENT,TEXT) ; add XML node for a text value
S ARRAY(ELEMENT,1,0)=TEXT
;D XMLOUT(ELEMENT,"","",TEXT)
Q
XMLTS(ELEMENT,TS) ; add XML node for a date/time
S ARRAY(ELEMENT,1,"fm")=TS
;D XMLOUT(ELEMENT,"fm",TS,"")
Q
XMLBOOL(ELEMENT,VAL) ; add XML node for a boolean
S ARRAY(ELEMENT,1,"value")=$S(+VAL:"true",1:"false")
Q
XMLOUT(ELEMENT,ATTRNM,ATTRVAL,TEXT) ; add XML
N X
I $L(ATTRNM) D
. S X="<"_ELEMENT_" "_ATTRNM_"="""_$$ESC^EDPX(ATTRVAL)_""""
E D
. S X="<"_ELEMENT
S X=X_$S($L(TEXT):">"_TEXT_"</"_ELEMENT_">",1:"/>")
D XML^EDPX(X)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPQLW 2550 printed Nov 22, 2024@17:02:21 Page 2
EDPQLW ;SLC/KCM - Retrieve Log Entry for Worksheet ;2/28/12 08:33am
+1 ;;2.0;EMERGENCY DEPARTMENT;;May 2, 2012;Build 103
+2 ;
LOAD(CTXT,ARRAY) ; create XML for log entry
+1 NEW LOG
SET LOG=CTXT("log")
+2 NEW AREA
SET AREA=$PIECE(^EDP(230,LOG,0),U,3)
+3 NEW EDPTIME
SET EDPTIME=$$NOW^XLFDT
+4 NEW EDPNOVAL
SET EDPNOVAL=+$ORDER(^EDPB(233.1,"B","edp.reserved.novalue",0))
+5 NEW X,X0,X1,X3
+6 ;
+7 LOCK +^EDP(230,LOG):3
+8 SET X0=^EDP(230,LOG,0)
SET X1=$GET(^(1))
SET X3=$GET(^(3))
+9 DO XMLTS("loadTS",$$NOW^XLFDT)
+10 ;S X("loadTS")=$$NOW^XLFDT
+11 LOCK -^EDP(230,LOG)
+12 ;
+13 DO XMLPTR("log",LOG,"")
+14 DO XMLBOOL("closed",$PIECE(X0,U,7))
+15 DO XMLTS("inTS",$PIECE(X0,U,8))
+16 DO XMLTS("outTS",$PIECE(X0,U,9))
+17 DO XMLCODE("arrival",$PIECE(X0,U,10))
+18 DO XMLPTR("visit",$PIECE(X0,U,12),"")
+19 NEW CLIN
SET CLIN=$PIECE(X0,U,14)
+20 IF CLIN
DO XMLPTR("clinic",CLIN,$PIECE($GET(^SC(CLIN,0)),U))
+21 DO XMLTEXT("complaint",$PIECE(X1,U,1))
+22 DO XMLTEXT("compLong",$GET(^EDP(230,LOG,2)))
+23 DO XMLCODE("status",$PIECE(X3,U,2))
+24 DO XMLCODE("acuity",$PIECE(X3,U,3))
+25 DO XMLPTR("bed",$PIECE(X3,U,4),$PIECE($GET(^EDPB(231.8,+$PIECE(X3,U,4),0)),U,6))
+26 DO XMLPERS("md",$PIECE(X3,U,5))
+27 DO XMLPERS("nurse",$PIECE(X3,U,6))
+28 DO XMLPERS("res",$PIECE(X3,U,7))
+29 DO XMLTEXT("comment",$PIECE(X3,U,8))
+30 DO XMLCODE("delay",$PIECE(X1,U,5))
+31 DO XMLCODE("disposition",$PIECE(X1,U,2))
+32 DO XMLTEXT("required",$$REQ^EDPQLE(.X))
+33 NEW CURBED
SET CURBED=$PIECE(X3,U,4)
+34 QUIT
REFS(AREA) ; create XML for log entry references
+1 QUIT
XMLCODE(ELEMENT,ID) ; add XML node for coded value
+1 if 'ID
QUIT
if ID=EDPNOVAL
QUIT
+2 ;TODO: lookup site name
NEW ECODE
SET ECODE=$PIECE($GET(^EDPB(233.1,ID,0)),U,2)
+3 SET ARRAY(ELEMENT,1,"id")=ID
+4 if $LENGTH(ECODE)
SET ARRAY(ELEMENT,1,"name")=ECODE
+5 ;D XMLOUT(ELEMENT,"id",ID,ECODE)
+6 QUIT
XMLPERS(ELEMENT,ID) ; add XML node for person
+1 if 'ID
QUIT
+2 NEW NAME
SET NAME=$PIECE($GET(^VA(200,ID,0)),U)
+3 SET ARRAY(ELEMENT,1,"id")=ID
+4 if $LENGTH(NAME)
SET ARRAY(ELEMENT,1,"name")=NAME
+5 ;D XMLOUT(ELEMENT,"id",ID,$P($G(^VA(200,ID,0)),U))
+6 QUIT
XMLPTR(ELEMENT,ID,NAME) ; add XML node for a pointer value
+1 SET ARRAY(ELEMENT,1,"id")=ID
+2 if $LENGTH(NAME)
SET ARRAY(ELEMENT,1,"name")=NAME
+3 ;D XMLOUT(ELEMENT,"id",ID,NAME)
+4 QUIT
XMLTEXT(ELEMENT,TEXT) ; add XML node for a text value
+1 SET ARRAY(ELEMENT,1,0)=TEXT
+2 ;D XMLOUT(ELEMENT,"","",TEXT)
+3 QUIT
XMLTS(ELEMENT,TS) ; add XML node for a date/time
+1 SET ARRAY(ELEMENT,1,"fm")=TS
+2 ;D XMLOUT(ELEMENT,"fm",TS,"")
+3 QUIT
XMLBOOL(ELEMENT,VAL) ; add XML node for a boolean
+1 SET ARRAY(ELEMENT,1,"value")=$SELECT(+VAL:"true",1:"false")
+2 QUIT
XMLOUT(ELEMENT,ATTRNM,ATTRVAL,TEXT) ; add XML
+1 NEW X
+2 IF $LENGTH(ATTRNM)
Begin DoDot:1
+3 SET X="<"_ELEMENT_" "_ATTRNM_"="""_$$ESC^EDPX(ATTRVAL)_""""
End DoDot:1
+4 IF '$TEST
Begin DoDot:1
+5 SET X="<"_ELEMENT
End DoDot:1
+6 SET X=X_$SELECT($LENGTH(TEXT):">"_TEXT_"</"_ELEMENT_">",1:"/>")
+7 DO XML^EDPX(X)
+8 QUIT