EDPRPT13 ;SLC/BWF - Removed in Error Report ;4/25/13 3:15pm
;;2.0;EMERGENCY DEPARTMENT;**6**;May 2, 2012;Build 200
;
Q
; INPUT:
; BEG - Beginning Date
; END - Ending Date
EN(BEG,END,CSV) ; Get report of patients removed in error
N CHKDT,LOG,ROW,TAB,X0,X1,X3,CNT,I,LOGH,FOUND,X
S CNT("ALL")=0 ; set counter to 0
D:'$G(CSV) XML^EDPX("<removedInErrorEntries>") I $G(CSV) D ;headers
. S TAB=$C(9)
. S X="ED IEN"_TAB_"Time In"_TAB_"Time Out"_TAB_"Restored to Board"_TAB_"Restored Date/Time"_TAB_"Restored By"_TAB_"Closed By"_TAB_"Closed Date/Time" ;_TAB_"ER Spec Visit"
. D ADD^EDPCSV(X)
S CHKDT=$G(BEG)-.000001
F S CHKDT=$O(^EDP(230,"ARIE",CHKDT)) Q:'CHKDT!(CHKDT>END) D
.S LOG=0 F S LOG=$O(^EDP(230,"ARIE",CHKDT,LOG)) Q:'LOG D
..S X0=^EDP(230,LOG,0),X1=$G(^(1)),X3=$G(^(3))
..;***pij change "ID" due to undef error 4/24/2013
..;N ROW S ROW("ID")=LOG
..N ROW S ROW("id")=LOG
..;***
..S ROW("patientName")=$$GET1^DIQ(2,$P(X0,U,6),.01)
..S ROW("timeInED")=$P(X0,U,8)
..S ROW("timeOutED")=$p(X0,U,9)
..S ROW("restored")=$P(X0,U,17)
..S ROW("restoredDateTime")=$P(X0,U,19)
..S ROW("restoredBy")=$$GET1^DIQ(200,$P(X0,U,18),.01)
..; initialize closedby and closedDateTime
..S (ROW("closedBy"),ROW("closedDateTime"))=""
..; look at the appropriate log history entry to get who closed this record
..S FOUND=0
..S LOGH="A" F S LOGH=$O(^EDP(230.1,"B",LOG,LOGH),-1) Q:'LOGH!(FOUND) D
...S X3=$G(^EDP(230.1,LOGH,3))
...I $P(X3,U,9) D
....S ROW("closedBy")=$$GET1^DIQ(200,$P(X3,U,11),.01),ROW("closedDateTime")=$P(X3,U,10)
....S FOUND=1
..;S ROW("closedBy")=$$GET1^DIQ(200,$P(X0,U,16),.01)
..;S ROW("closedDateTime")=$P(X0,U,15)
..S ROW("ssn")=$S($P(X0,U,5):$P(X0,U,5),'$P(X0,U,5):$$SSN^DPTLK1($P(X0,U,6)),1:"")
..I '$G(CSV) S X=$$XMLA^EDPX("log",.ROW) D XML^EDPX(X) Q
..S X=ROW("id")
..F I="patientName","timeInED","timeOutED","restored","restoredDateTime","restoredBy","closedBy","closedDateTime" D
...S X=X_$C(9)_$G(ROW(I)) D ADD^EDPCSV(X)
D:'$G(CSV) XML^EDPX("</removedInErrorEntries>")
Q
;
INIT ;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPRPT13 2100 printed Dec 13, 2024@01:52:20 Page 2
EDPRPT13 ;SLC/BWF - Removed in Error Report ;4/25/13 3:15pm
+1 ;;2.0;EMERGENCY DEPARTMENT;**6**;May 2, 2012;Build 200
+2 ;
+3 QUIT
+4 ; INPUT:
+5 ; BEG - Beginning Date
+6 ; END - Ending Date
EN(BEG,END,CSV) ; Get report of patients removed in error
+1 NEW CHKDT,LOG,ROW,TAB,X0,X1,X3,CNT,I,LOGH,FOUND,X
+2 ; set counter to 0
SET CNT("ALL")=0
+3 ;headers
if '$GET(CSV)
DO XML^EDPX("<removedInErrorEntries>")
IF $GET(CSV)
Begin DoDot:1
+4 SET TAB=$CHAR(9)
+5 ;_TAB_"ER Spec Visit"
SET X="ED IEN"_TAB_"Time In"_TAB_"Time Out"_TAB_"Restored to Board"_TAB_"Restored Date/Time"_TAB_"Restored By"_TAB_"Closed By"_TAB_"Closed Date/Time"
+6 DO ADD^EDPCSV(X)
End DoDot:1
+7 SET CHKDT=$GET(BEG)-.000001
+8 FOR
SET CHKDT=$ORDER(^EDP(230,"ARIE",CHKDT))
if 'CHKDT!(CHKDT>END)
QUIT
Begin DoDot:1
+9 SET LOG=0
FOR
SET LOG=$ORDER(^EDP(230,"ARIE",CHKDT,LOG))
if 'LOG
QUIT
Begin DoDot:2
+10 SET X0=^EDP(230,LOG,0)
SET X1=$GET(^(1))
SET X3=$GET(^(3))
+11 ;***pij change "ID" due to undef error 4/24/2013
+12 ;N ROW S ROW("ID")=LOG
+13 NEW ROW
SET ROW("id")=LOG
+14 ;***
+15 SET ROW("patientName")=$$GET1^DIQ(2,$PIECE(X0,U,6),.01)
+16 SET ROW("timeInED")=$PIECE(X0,U,8)
+17
*** ERROR ***
SET ROW("timeOutED")=$p(X0,U,9)
+18 SET ROW("restored")=$PIECE(X0,U,17)
+19 SET ROW("restoredDateTime")=$PIECE(X0,U,19)
+20 SET ROW("restoredBy")=$$GET1^DIQ(200,$PIECE(X0,U,18),.01)
+21 ; initialize closedby and closedDateTime
+22 SET (ROW("closedBy"),ROW("closedDateTime"))=""
+23 ; look at the appropriate log history entry to get who closed this record
+24 SET FOUND=0
+25 SET LOGH="A"
FOR
SET LOGH=$ORDER(^EDP(230.1,"B",LOG,LOGH),-1)
if 'LOGH!(FOUND)
QUIT
Begin DoDot:3
+26 SET X3=$GET(^EDP(230.1,LOGH,3))
+27 IF $PIECE(X3,U,9)
Begin DoDot:4
+28 SET ROW("closedBy")=$$GET1^DIQ(200,$PIECE(X3,U,11),.01)
SET ROW("closedDateTime")=$PIECE(X3,U,10)
+29 SET FOUND=1
End DoDot:4
End DoDot:3
+30 ;S ROW("closedBy")=$$GET1^DIQ(200,$P(X0,U,16),.01)
+31 ;S ROW("closedDateTime")=$P(X0,U,15)
+32 SET ROW("ssn")=$SELECT($PIECE(X0,U,5):$PIECE(X0,U,5),'$PIECE(X0,U,5):$$SSN^DPTLK1($PIECE(X0,U,6)),1:"")
+33 IF '$GET(CSV)
SET X=$$XMLA^EDPX("log",.ROW)
DO XML^EDPX(X)
QUIT
+34 SET X=ROW("id")
+35 FOR I="patientName","timeInED","timeOutED","restored","restoredDateTime","restoredBy","closedBy","closedDateTime"
Begin DoDot:3
+36 SET X=X_$CHAR(9)_$GET(ROW(I))
DO ADD^EDPCSV(X)
End DoDot:3
End DoDot:2
End DoDot:1
+37 if '$GET(CSV)
DO XML^EDPX("</removedInErrorEntries>")
+38 QUIT
+39 ;
INIT ;
+1 QUIT