BTPWPEVO ;VNGT/HS/BEE-CMET Event Utilities ; 04 Feb 2009 2:55 PM
;;1.0;CARE MANAGEMENT EVENT TRACKING;;Feb 07, 2011
;
ROPEN(DATA,CMIEN,COMMENT) ;EP -- BTPW REOPEN CLOSED EVENT
; Input Parameters
; CMIEN - IENs of the file 90620 entry or entries to be reopened
; COMMENT - New Comment
;
; Output Value
; RESULT = Piece 1 - (1) - Successful/(-1) - Unsuccessful
; = Piece 2 - Error Message
;
NEW UID,II,PIEN,PC
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BTPWPEVO",UID))
K @DATA
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWPEVO D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
S @DATA@(II)="I00010RESULT^I00010CMET_IEN^T01024MSG^T00060EVENT^D00015EVENT_DATE^T00050PATIENT_NAME^T00030HRN"_$C(30)
;
;Make sure IEN is populated
I $TR($G(CMIEN),$C(29))="" S II=II+1,@DATA@(II)="-1^^Event IEN is required^^^^"_$C(30) G DONE
;
;Loop through entries and close
F PC=1:1:$L(CMIEN,$C(29)) S PIEN=$P(CMIEN,$C(29),PC) I PIEN]"" D REOP(PIEN,COMMENT)
;
DONE ;
S II=II+1,@DATA@(II)=$C(31)
Q
;
REOP(PIEN,COMMENT) ;EP - Reopen Individual Record
;
N STATE,LN,I,P,BTPUPD,ERROR,CMTVAR,COM,DTTM
;
;Make sure event exists
I $$GET1^DIQ(90620,PIEN_",",".01","I")="" S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Could not find event corresponding to provided IEN")_$C(30) Q
;
;Make sure event is in a closed state
S STATE=$$GET1^DIQ(90620,PIEN_",",1.01,"I")
I STATE'="C" S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Event is not in a closed state")_$C(30) Q
;
;Set up comment for processing
S COMMENT=$G(COMMENT,"")
S LN=0 F I=1:1:$L(COMMENT,$C(13)_$C(10)) S P=$P(COMMENT,$C(13)_$C(10),I) S LN=LN+1,COM(LN)=P
I '$D(COM(1)) S CMTVAR="@"
E S CMTVAR="COM"
;
S DTTM=$$NOW^XLFDT()
S BTPUPD(90620,PIEN_",",1.01)="O"
S BTPUPD(90620,PIEN_",",1.09)=DTTM
S BTPUPD(90620,PIEN_",",1.1)=DUZ
S BTPUPD(90620,PIEN_",",1.04)="@"
S BTPUPD(90620,PIEN_",",1.08)="@"
;
;Save History
D RLOG^BTPWHIST(.BTPUPD,DUZ,DTTM,"Event Reopen")
;
;Reopen event
D FILE^DIE("","BTPUPD","ERROR")
I $D(ERROR) S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Unable to reopen event")_$C(30) Q
;
;Save Comment History
D WLOG^BTPWHIST(.COM,"90620:3",PIEN_",",DUZ,DTTM,"Event Reopened")
;
;Save comments
D WP^DIE(90620,PIEN_",",3,"",CMTVAR)
;
S II=II+1,@DATA@(II)="1^"_PIEN_"^^^^^"_$C(30)
;
Q
;
CLOSE(DATA,CMIEN,CREASON,COMMENT) ;EP -- BTPW CLOSE EVENT
; Input Parameters
; CMIEN - IENs of the file 90620 entry or entries to be closed
; CREASON - Close Reason
; COMMENT - New Comment
;
; Output Value
; RESULT = Piece 1 - (1) - Successful/(-1) - Unsuccessful
; = Piece 2 - Error Message
;
NEW UID,II,ERROR,PC,PIEN
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BTPWPEVO",UID))
K @DATA
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWPEVO D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
S @DATA@(II)="I00010RESULT^I00010CMET_IEN^T01024MSG^T00060EVENT^D00015EVENT_DATE^T00050PATIENT_NAME^T00030HRN"_$C(30)
;
;Make sure IEN is populated
I $TR($G(CMIEN),$C(29))="" S II=II+1,@DATA@(II)="-1^^Event IEN is required^^^^"_$C(30) G XDONE
;
;Loop through entries and close
F PC=1:1:$L(CMIEN,$C(29)) S PIEN=$P(CMIEN,$C(29),PC) I PIEN]"" D CLS(PIEN,CREASON,COMMENT)
;
XDONE ;
S II=II+1,@DATA@(II)=$C(31)
Q
;
CLS(PIEN,CREASON,COMMENT) ;EP - Close individual record
N STATE,LN,I,P,CMTVAR,COM,BTPUPD,DTTM
;
;Make sure event exists
I $$GET1^DIQ(90620,PIEN_",",".01","I")="" S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Could not find event corresponding to provided IEN")_$C(30) Q
;
;Make sure event is not in a closed state
S STATE=$$GET1^DIQ(90620,PIEN_",",1.01,"I")
I STATE="C" S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Event is already in a closed state")_$C(30) Q
;
;Check for valid Close Reason
I CREASON]"",CREASON'=1,CREASON'=2,CREASON'=3,CREASON'=4 S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Invalid Close Reason")_$C(30) Q
S:CREASON="" CREASON="@" ;If blank, clear out what is in field
;
;Set up comment for processing
S COMMENT=$G(COMMENT,"")
S LN=0 F I=1:1:$L(COMMENT,$C(13)_$C(10)) S P=$P(COMMENT,$C(13)_$C(10),I) S LN=LN+1,COM(LN)=P
I '$D(COM(1)) S CMTVAR="@"
E S CMTVAR="COM"
;
S DTTM=$$NOW^XLFDT()
S BTPUPD(90620,PIEN_",",1.01)="C"
S BTPUPD(90620,PIEN_",",1.09)=DTTM
S BTPUPD(90620,PIEN_",",1.1)=DUZ
S BTPUPD(90620,PIEN_",",1.04)=CREASON
S BTPUPD(90620,PIEN_",",1.08)="@"
;
;Save History
D RLOG^BTPWHIST(.BTPUPD,DUZ,DTTM,"Event Closed")
;
;Close the event
D FILE^DIE("","BTPUPD","ERROR")
I $D(ERROR) S II=II+1,@DATA@(II)=$$EMSG(PIEN,"Unable to close event")_$C(30) Q
;
;Save Comment History
D WLOG^BTPWHIST(.COM,"90620:3",PIEN_",",DUZ,DTTM,"Event Close")
;
;Save comments
D WP^DIE(90620,PIEN_",",3,"",CMTVAR)
;
S II=II+1,@DATA@(II)="1^"_PIEN_"^^^^^"_$C(30)
;
Q
;
EMSG(PIEN,MSG) ; EP - Compose Return Error Message
N RET,TDATA,DFN,PNAM,PROC,PROCNM,PRCDT,HRN
S TDATA=$G(^BTPWP(PIEN,0)),DFN=$P(TDATA,U,2),PNAM=$P(^DPT(DFN,0),"^",1)
S PROC=$P(TDATA,U,1),PROCNM=$P(^BTPW(90621,PROC,0),U,1) ;Procedure/Name (Event)
S PRCDT=$$FMTE^BQIUL1($P(TDATA,U,3)) ;Event Date
S HRN=$TR($$HRNL^BQIULPT(DFN),";",$C(10)) ;HRN
S RET="-1"_U_PIEN_U_MSG_U_PROCNM_U_PRCDT_U_PNAM_U_HRN
Q RET
;
ERR ;
D ^%ZTER
NEW Y,ERRDTM
S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
S BMXSEC="Recording that an error occurred at "_ERRDTM
S II=II+1,@DATA@(II)=$C(31)
Q
;
EIE(DATA,CMIEN,TYPE,IENS) ;EP -- BTPW EVENT ENT IN ERROR
; Input Parameters
; CMIEN - IENs of the file 90620 entry
; TYPE - Type of Entry - 'Finding'
; 'Follow-up'
; 'Notification'
; IENS (OPT) - Specific entries to mark entered in error
;
; Output Value
; RESULT = Piece 1 - (1) - Successful/(-1) - Unsuccessful
; = Piece 2 - Error Message
;
NEW UID,II,PIEN,DTTM
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BTPWPEVO",UID))
K @DATA
;
S II=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWPEVO D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
S @DATA@(II)="I00010RESULT^I00010IEN^T01024MSG"_$C(30)
S IENS=$G(IENS)
;
;Make sure IEN is populated
I $TR($G(CMIEN),$C(29))="" S II=II+1,@DATA@(II)="-1^^Event IEN is required"_$C(30) G EDONE
;
;Make sure TYPE is defined
I TYPE'="Finding",TYPE'="Follow-up",TYPE'="Notification" S II=II+1,@DATA@(II)="-1^^Event TYPE is required"_$C(30) G EDONE
;
;Pull current date/time
S DTTM=$$NOW^XLFDT()
;
;Findings
I TYPE="Finding" D G EDONE
. N IEN
. ;
. ;Process Individual Findings
. I IENS]"" D Q
.. N I
.. F I=1:1:$L(IENS,$C(29)) S IEN=$P(IENS,$C(29),I) D EFND(CMIEN,IEN,DTTM)
. ;
. ;Process All Findings
. S IEN=0 F S IEN=$O(^BTPWP(CMIEN,10,IEN)) Q:'IEN D EFND(CMIEN,IEN,DTTM)
;
;Follow-ups
I TYPE="Follow-up" D G EDONE
. N IEN
. ;
. ;Process Individual Follow-ups
. I IENS]"" D Q
.. N I
.. F I=1:1:$L(IENS,$C(29)) S IEN=$P(IENS,$C(29),I) D EFOL(CMIEN,IEN,DTTM)
. ;
. ;Process All Follow-ups
. S IEN=0 F S IEN=$O(^BTPWP(CMIEN,10,IEN)) Q:'IEN D EFOL(CMIEN,IEN,DTTM)
;
;Notifications
I TYPE="Notification" D G EDONE
. N IEN
. ;
. ;Process Individual Notifications
. I IENS]"" D Q
.. N I
.. F I=1:1:$L(IENS,$C(29)) S IEN=$P(IENS,$C(29),I) D ENOT(CMIEN,IEN,DTTM)
. ;
. ;Process All Notifications
. S IEN=0 F S IEN=$O(^BTPWP(CMIEN,10,IEN)) Q:'IEN D ENOT(CMIEN,IEN,DTTM)
;
EDONE ;
S II=II+1,@DATA@(II)=$C(31)
Q
;
;Mark Findings as ENTERED IN ERROR
EFND(CMIEN,IEN,DTTM) ;
N BTPWDTA,DA,IENS,ERROR
;
S DA(1)=CMIEN,DA=IEN,IENS=$$IENS^DILF(.DA)
S BTPWDTA(90620.01,IENS,.08)="Y"
S BTPWDTA(90620.01,IENS,.04)=DTTM
S BTPWDTA(90620.01,IENS,.05)=DUZ
S BTPWDTA(90620,CMIEN_",",1.09)=DTTM
S BTPWDTA(90620,CMIEN_",",1.1)=DUZ
;
;Save History
D RLOG^BTPWHIST(.BTPWDTA,DUZ,DTTM,"Entered In Error")
;
D FILE^DIE("","BTPWDTA","ERROR")
I $D(ERROR) S II=II+1,@DATA@(II)="-1^"_IEN_"^Could not set finding to ENTERED IN ERROR"_$C(30) G XEFND
S II=II+1,@DATA@(II)="1^"_IEN_"^"_$C(30)
;
XEFND Q
;
;Mark Follow-ups as ENTERED IN ERROR
EFOL(CMIEN,IEN,DTTM) ;
N BTPWDTA,DA,IENS,ERROR,FTIEN
;
S DA(1)=CMIEN,DA=IEN,IENS=$$IENS^DILF(.DA)
S BTPWDTA(90620.012,IENS,.07)="Y"
S BTPWDTA(90620.012,IENS,.03)=DTTM
S BTPWDTA(90620.012,IENS,.04)=DUZ
S BTPWDTA(90620,CMIEN_",",1.09)=DTTM
S BTPWDTA(90620,CMIEN_",",1.1)=DUZ
;
;Save History
D RLOG^BTPWHIST(.BTPWDTA,DUZ,DTTM,"Entered In Error")
;
D FILE^DIE("","BTPWDTA","ERROR")
I $D(ERROR) S II=II+1,@DATA@(II)="-1^"_IEN_"^Could not set Follow-up to ENTERED IN ERROR"_$C(30) G XEFND
S II=II+1,@DATA@(II)="1^"_IEN_"^"_$C(30)
;
;Process Future Record
;
;Delete if still in a FUTURE state
S FTIEN=$$GET1^DIQ(90620.012,IENS,.06,"I") Q:FTIEN=""
I $$GET1^DIQ(90620,FTIEN_",",1.01,"I")="F" D Q
. N DA,DIK
. S DA=FTIEN,DIK="^BTPWP(" D ^DIK Q
;
;Future record no longer in FUTURE state, remove pointer
N BTPWUPD
S BTPWUPD(90620,FTIEN_",",.11)="@"
D FILE^DIE("","BTPWUPD","ERROR")
;
Q
;
;Mark Notifications as ENTERED IN ERROR
ENOT(CMIEN,IEN,DTTM) ;
N BTPWDTA,DA,IENS,ERROR
;
S DA(1)=CMIEN,DA=IEN,IENS=$$IENS^DILF(.DA)
S BTPWDTA(90620.011,IENS,.09)="Y"
S BTPWDTA(90620.011,IENS,.03)=DTTM
S BTPWDTA(90620.011,IENS,.04)=DUZ
S BTPWDTA(90620,CMIEN_",",1.09)=DTTM
S BTPWDTA(90620,CMIEN_",",1.1)=DUZ
;
;Save History
D RLOG^BTPWHIST(.BTPWDTA,DUZ,DTTM,"Entered In Error")
;
D FILE^DIE("","BTPWDTA","ERROR")
I $D(ERROR) S II=II+1,@DATA@(II)="-1^"_IEN_"^Could not set Notification to ENTERED IN ERROR"_$C(30) G XEFND
S II=II+1,@DATA@(II)="1^"_IEN_"^"_$C(30)
;
Q
BTPWPEVO ;VNGT/HS/BEE-CMET Event Utilities ; 04 Feb 2009 2:55 PM
+1 ;;1.0;CARE MANAGEMENT EVENT TRACKING;;Feb 07, 2011
+2 ;
ROPEN(DATA,CMIEN,COMMENT) ;EP -- BTPW REOPEN CLOSED EVENT
+1 ; Input Parameters
+2 ; CMIEN - IENs of the file 90620 entry or entries to be reopened
+3 ; COMMENT - New Comment
+4 ;
+5 ; Output Value
+6 ; RESULT = Piece 1 - (1) - Successful/(-1) - Unsuccessful
+7 ; = Piece 2 - Error Message
+8 ;
+9 NEW UID,II,PIEN,PC
+10 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+11 SET DATA=$NAME(^TMP("BTPWPEVO",UID))
+12 KILL @DATA
+13 ;
+14 SET II=0
+15 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BTPWPEVO D UNWIND^%ZTER"
+16 SET @DATA@(II)="I00010RESULT^I00010CMET_IEN^T01024MSG^T00060EVENT^D00015EVENT_DATE^T00050PATIENT_NAME^T00030HRN"_$CHAR(30)
+17 ;
+18 ;Make sure IEN is populated
+19 IF $TRANSLATE($GET(CMIEN),$CHAR(29))=""
SET II=II+1
SET @DATA@(II)="-1^^Event IEN is required^^^^"_$CHAR(30)
GOTO DONE
+20 ;
+21 ;Loop through entries and close
+22 FOR PC=1:1:$LENGTH(CMIEN,$CHAR(29))
SET PIEN=$PIECE(CMIEN,$CHAR(29),PC)
IF PIEN]""
DO REOP(PIEN,COMMENT)
+23 ;
DONE ;
+1 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+2 QUIT
+3 ;
REOP(PIEN,COMMENT) ;EP - Reopen Individual Record
+1 ;
+2 NEW STATE,LN,I,P,BTPUPD,ERROR,CMTVAR,COM,DTTM
+3 ;
+4 ;Make sure event exists
+5 IF $$GET1^DIQ(90620,PIEN_",",".01","I")=""
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Could not find event corresponding to provided IEN")_$CHAR(30)
QUIT
+6 ;
+7 ;Make sure event is in a closed state
+8 SET STATE=$$GET1^DIQ(90620,PIEN_",",1.01,"I")
+9 IF STATE'="C"
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Event is not in a closed state")_$CHAR(30)
QUIT
+10 ;
+11 ;Set up comment for processing
+12 SET COMMENT=$GET(COMMENT,"")
+13 SET LN=0
FOR I=1:1:$LENGTH(COMMENT,$CHAR(13)_$CHAR(10))
SET P=$PIECE(COMMENT,$CHAR(13)_$CHAR(10),I)
SET LN=LN+1
SET COM(LN)=P
+14 IF '$DATA(COM(1))
SET CMTVAR="@"
+15 IF '$TEST
SET CMTVAR="COM"
+16 ;
+17 SET DTTM=$$NOW^XLFDT()
+18 SET BTPUPD(90620,PIEN_",",1.01)="O"
+19 SET BTPUPD(90620,PIEN_",",1.09)=DTTM
+20 SET BTPUPD(90620,PIEN_",",1.1)=DUZ
+21 SET BTPUPD(90620,PIEN_",",1.04)="@"
+22 SET BTPUPD(90620,PIEN_",",1.08)="@"
+23 ;
+24 ;Save History
+25 DO RLOG^BTPWHIST(.BTPUPD,DUZ,DTTM,"Event Reopen")
+26 ;
+27 ;Reopen event
+28 DO FILE^DIE("","BTPUPD","ERROR")
+29 IF $DATA(ERROR)
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Unable to reopen event")_$CHAR(30)
QUIT
+30 ;
+31 ;Save Comment History
+32 DO WLOG^BTPWHIST(.COM,"90620:3",PIEN_",",DUZ,DTTM,"Event Reopened")
+33 ;
+34 ;Save comments
+35 DO WP^DIE(90620,PIEN_",",3,"",CMTVAR)
+36 ;
+37 SET II=II+1
SET @DATA@(II)="1^"_PIEN_"^^^^^"_$CHAR(30)
+38 ;
+39 QUIT
+40 ;
CLOSE(DATA,CMIEN,CREASON,COMMENT) ;EP -- BTPW CLOSE EVENT
+1 ; Input Parameters
+2 ; CMIEN - IENs of the file 90620 entry or entries to be closed
+3 ; CREASON - Close Reason
+4 ; COMMENT - New Comment
+5 ;
+6 ; Output Value
+7 ; RESULT = Piece 1 - (1) - Successful/(-1) - Unsuccessful
+8 ; = Piece 2 - Error Message
+9 ;
+10 NEW UID,II,ERROR,PC,PIEN
+11 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+12 SET DATA=$NAME(^TMP("BTPWPEVO",UID))
+13 KILL @DATA
+14 ;
+15 SET II=0
+16 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BTPWPEVO D UNWIND^%ZTER"
+17 SET @DATA@(II)="I00010RESULT^I00010CMET_IEN^T01024MSG^T00060EVENT^D00015EVENT_DATE^T00050PATIENT_NAME^T00030HRN"_$CHAR(30)
+18 ;
+19 ;Make sure IEN is populated
+20 IF $TRANSLATE($GET(CMIEN),$CHAR(29))=""
SET II=II+1
SET @DATA@(II)="-1^^Event IEN is required^^^^"_$CHAR(30)
GOTO XDONE
+21 ;
+22 ;Loop through entries and close
+23 FOR PC=1:1:$LENGTH(CMIEN,$CHAR(29))
SET PIEN=$PIECE(CMIEN,$CHAR(29),PC)
IF PIEN]""
DO CLS(PIEN,CREASON,COMMENT)
+24 ;
XDONE ;
+1 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+2 QUIT
+3 ;
CLS(PIEN,CREASON,COMMENT) ;EP - Close individual record
+1 NEW STATE,LN,I,P,CMTVAR,COM,BTPUPD,DTTM
+2 ;
+3 ;Make sure event exists
+4 IF $$GET1^DIQ(90620,PIEN_",",".01","I")=""
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Could not find event corresponding to provided IEN")_$CHAR(30)
QUIT
+5 ;
+6 ;Make sure event is not in a closed state
+7 SET STATE=$$GET1^DIQ(90620,PIEN_",",1.01,"I")
+8 IF STATE="C"
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Event is already in a closed state")_$CHAR(30)
QUIT
+9 ;
+10 ;Check for valid Close Reason
+11 IF CREASON]""
IF CREASON'=1
IF CREASON'=2
IF CREASON'=3
IF CREASON'=4
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Invalid Close Reason")_$CHAR(30)
QUIT
+12 ;If blank, clear out what is in field
IF CREASON=""
SET CREASON="@"
+13 ;
+14 ;Set up comment for processing
+15 SET COMMENT=$GET(COMMENT,"")
+16 SET LN=0
FOR I=1:1:$LENGTH(COMMENT,$CHAR(13)_$CHAR(10))
SET P=$PIECE(COMMENT,$CHAR(13)_$CHAR(10),I)
SET LN=LN+1
SET COM(LN)=P
+17 IF '$DATA(COM(1))
SET CMTVAR="@"
+18 IF '$TEST
SET CMTVAR="COM"
+19 ;
+20 SET DTTM=$$NOW^XLFDT()
+21 SET BTPUPD(90620,PIEN_",",1.01)="C"
+22 SET BTPUPD(90620,PIEN_",",1.09)=DTTM
+23 SET BTPUPD(90620,PIEN_",",1.1)=DUZ
+24 SET BTPUPD(90620,PIEN_",",1.04)=CREASON
+25 SET BTPUPD(90620,PIEN_",",1.08)="@"
+26 ;
+27 ;Save History
+28 DO RLOG^BTPWHIST(.BTPUPD,DUZ,DTTM,"Event Closed")
+29 ;
+30 ;Close the event
+31 DO FILE^DIE("","BTPUPD","ERROR")
+32 IF $DATA(ERROR)
SET II=II+1
SET @DATA@(II)=$$EMSG(PIEN,"Unable to close event")_$CHAR(30)
QUIT
+33 ;
+34 ;Save Comment History
+35 DO WLOG^BTPWHIST(.COM,"90620:3",PIEN_",",DUZ,DTTM,"Event Close")
+36 ;
+37 ;Save comments
+38 DO WP^DIE(90620,PIEN_",",3,"",CMTVAR)
+39 ;
+40 SET II=II+1
SET @DATA@(II)="1^"_PIEN_"^^^^^"_$CHAR(30)
+41 ;
+42 QUIT
+43 ;
EMSG(PIEN,MSG) ; EP - Compose Return Error Message
+1 NEW RET,TDATA,DFN,PNAM,PROC,PROCNM,PRCDT,HRN
+2 SET TDATA=$GET(^BTPWP(PIEN,0))
SET DFN=$PIECE(TDATA,U,2)
SET PNAM=$PIECE(^DPT(DFN,0),"^",1)
+3 ;Procedure/Name (Event)
SET PROC=$PIECE(TDATA,U,1)
SET PROCNM=$PIECE(^BTPW(90621,PROC,0),U,1)
+4 ;Event Date
SET PRCDT=$$FMTE^BQIUL1($PIECE(TDATA,U,3))
+5 ;HRN
SET HRN=$TRANSLATE($$HRNL^BQIULPT(DFN),";",$CHAR(10))
+6 SET RET="-1"_U_PIEN_U_MSG_U_PROCNM_U_PRCDT_U_PNAM_U_HRN
+7 QUIT RET
+8 ;
ERR ;
+1 DO ^%ZTER
+2 NEW Y,ERRDTM
+3 SET Y=$$NOW^XLFDT()
XECUTE ^DD("DD")
SET ERRDTM=Y
+4 SET BMXSEC="Recording that an error occurred at "_ERRDTM
+5 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+6 QUIT
+7 ;
EIE(DATA,CMIEN,TYPE,IENS) ;EP -- BTPW EVENT ENT IN ERROR
+1 ; Input Parameters
+2 ; CMIEN - IENs of the file 90620 entry
+3 ; TYPE - Type of Entry - 'Finding'
+4 ; 'Follow-up'
+5 ; 'Notification'
+6 ; IENS (OPT) - Specific entries to mark entered in error
+7 ;
+8 ; Output Value
+9 ; RESULT = Piece 1 - (1) - Successful/(-1) - Unsuccessful
+10 ; = Piece 2 - Error Message
+11 ;
+12 NEW UID,II,PIEN,DTTM
+13 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+14 SET DATA=$NAME(^TMP("BTPWPEVO",UID))
+15 KILL @DATA
+16 ;
+17 SET II=0
+18 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BTPWPEVO D UNWIND^%ZTER"
+19 SET @DATA@(II)="I00010RESULT^I00010IEN^T01024MSG"_$CHAR(30)
+20 SET IENS=$GET(IENS)
+21 ;
+22 ;Make sure IEN is populated
+23 IF $TRANSLATE($GET(CMIEN),$CHAR(29))=""
SET II=II+1
SET @DATA@(II)="-1^^Event IEN is required"_$CHAR(30)
GOTO EDONE
+24 ;
+25 ;Make sure TYPE is defined
+26 IF TYPE'="Finding"
IF TYPE'="Follow-up"
IF TYPE'="Notification"
SET II=II+1
SET @DATA@(II)="-1^^Event TYPE is required"_$CHAR(30)
GOTO EDONE
+27 ;
+28 ;Pull current date/time
+29 SET DTTM=$$NOW^XLFDT()
+30 ;
+31 ;Findings
+32 IF TYPE="Finding"
Begin DoDot:1
+33 NEW IEN
+34 ;
+35 ;Process Individual Findings
+36 IF IENS]""
Begin DoDot:2
+37 NEW I
+38 FOR I=1:1:$LENGTH(IENS,$CHAR(29))
SET IEN=$PIECE(IENS,$CHAR(29),I)
DO EFND(CMIEN,IEN,DTTM)
End DoDot:2
QUIT
+39 ;
+40 ;Process All Findings
+41 SET IEN=0
FOR
SET IEN=$ORDER(^BTPWP(CMIEN,10,IEN))
IF 'IEN
QUIT
DO EFND(CMIEN,IEN,DTTM)
End DoDot:1
GOTO EDONE
+42 ;
+43 ;Follow-ups
+44 IF TYPE="Follow-up"
Begin DoDot:1
+45 NEW IEN
+46 ;
+47 ;Process Individual Follow-ups
+48 IF IENS]""
Begin DoDot:2
+49 NEW I
+50 FOR I=1:1:$LENGTH(IENS,$CHAR(29))
SET IEN=$PIECE(IENS,$CHAR(29),I)
DO EFOL(CMIEN,IEN,DTTM)
End DoDot:2
QUIT
+51 ;
+52 ;Process All Follow-ups
+53 SET IEN=0
FOR
SET IEN=$ORDER(^BTPWP(CMIEN,10,IEN))
IF 'IEN
QUIT
DO EFOL(CMIEN,IEN,DTTM)
End DoDot:1
GOTO EDONE
+54 ;
+55 ;Notifications
+56 IF TYPE="Notification"
Begin DoDot:1
+57 NEW IEN
+58 ;
+59 ;Process Individual Notifications
+60 IF IENS]""
Begin DoDot:2
+61 NEW I
+62 FOR I=1:1:$LENGTH(IENS,$CHAR(29))
SET IEN=$PIECE(IENS,$CHAR(29),I)
DO ENOT(CMIEN,IEN,DTTM)
End DoDot:2
QUIT
+63 ;
+64 ;Process All Notifications
+65 SET IEN=0
FOR
SET IEN=$ORDER(^BTPWP(CMIEN,10,IEN))
IF 'IEN
QUIT
DO ENOT(CMIEN,IEN,DTTM)
End DoDot:1
GOTO EDONE
+66 ;
EDONE ;
+1 SET II=II+1
SET @DATA@(II)=$CHAR(31)
+2 QUIT
+3 ;
+4 ;Mark Findings as ENTERED IN ERROR
EFND(CMIEN,IEN,DTTM) ;
+1 NEW BTPWDTA,DA,IENS,ERROR
+2 ;
+3 SET DA(1)=CMIEN
SET DA=IEN
SET IENS=$$IENS^DILF(.DA)
+4 SET BTPWDTA(90620.01,IENS,.08)="Y"
+5 SET BTPWDTA(90620.01,IENS,.04)=DTTM
+6 SET BTPWDTA(90620.01,IENS,.05)=DUZ
+7 SET BTPWDTA(90620,CMIEN_",",1.09)=DTTM
+8 SET BTPWDTA(90620,CMIEN_",",1.1)=DUZ
+9 ;
+10 ;Save History
+11 DO RLOG^BTPWHIST(.BTPWDTA,DUZ,DTTM,"Entered In Error")
+12 ;
+13 DO FILE^DIE("","BTPWDTA","ERROR")
+14 IF $DATA(ERROR)
SET II=II+1
SET @DATA@(II)="-1^"_IEN_"^Could not set finding to ENTERED IN ERROR"_$CHAR(30)
GOTO XEFND
+15 SET II=II+1
SET @DATA@(II)="1^"_IEN_"^"_$CHAR(30)
+16 ;
XEFND QUIT
+1 ;
+2 ;Mark Follow-ups as ENTERED IN ERROR
EFOL(CMIEN,IEN,DTTM) ;
+1 NEW BTPWDTA,DA,IENS,ERROR,FTIEN
+2 ;
+3 SET DA(1)=CMIEN
SET DA=IEN
SET IENS=$$IENS^DILF(.DA)
+4 SET BTPWDTA(90620.012,IENS,.07)="Y"
+5 SET BTPWDTA(90620.012,IENS,.03)=DTTM
+6 SET BTPWDTA(90620.012,IENS,.04)=DUZ
+7 SET BTPWDTA(90620,CMIEN_",",1.09)=DTTM
+8 SET BTPWDTA(90620,CMIEN_",",1.1)=DUZ
+9 ;
+10 ;Save History
+11 DO RLOG^BTPWHIST(.BTPWDTA,DUZ,DTTM,"Entered In Error")
+12 ;
+13 DO FILE^DIE("","BTPWDTA","ERROR")
+14 IF $DATA(ERROR)
SET II=II+1
SET @DATA@(II)="-1^"_IEN_"^Could not set Follow-up to ENTERED IN ERROR"_$CHAR(30)
GOTO XEFND
+15 SET II=II+1
SET @DATA@(II)="1^"_IEN_"^"_$CHAR(30)
+16 ;
+17 ;Process Future Record
+18 ;
+19 ;Delete if still in a FUTURE state
+20 SET FTIEN=$$GET1^DIQ(90620.012,IENS,.06,"I")
IF FTIEN=""
QUIT
+21 IF $$GET1^DIQ(90620,FTIEN_",",1.01,"I")="F"
Begin DoDot:1
+22 NEW DA,DIK
+23 SET DA=FTIEN
SET DIK="^BTPWP("
DO ^DIK
QUIT
End DoDot:1
QUIT
+24 ;
+25 ;Future record no longer in FUTURE state, remove pointer
+26 NEW BTPWUPD
+27 SET BTPWUPD(90620,FTIEN_",",.11)="@"
+28 DO FILE^DIE("","BTPWUPD","ERROR")
+29 ;
+30 QUIT
+31 ;
+32 ;Mark Notifications as ENTERED IN ERROR
ENOT(CMIEN,IEN,DTTM) ;
+1 NEW BTPWDTA,DA,IENS,ERROR
+2 ;
+3 SET DA(1)=CMIEN
SET DA=IEN
SET IENS=$$IENS^DILF(.DA)
+4 SET BTPWDTA(90620.011,IENS,.09)="Y"
+5 SET BTPWDTA(90620.011,IENS,.03)=DTTM
+6 SET BTPWDTA(90620.011,IENS,.04)=DUZ
+7 SET BTPWDTA(90620,CMIEN_",",1.09)=DTTM
+8 SET BTPWDTA(90620,CMIEN_",",1.1)=DUZ
+9 ;
+10 ;Save History
+11 DO RLOG^BTPWHIST(.BTPWDTA,DUZ,DTTM,"Entered In Error")
+12 ;
+13 DO FILE^DIE("","BTPWDTA","ERROR")
+14 IF $DATA(ERROR)
SET II=II+1
SET @DATA@(II)="-1^"_IEN_"^Could not set Notification to ENTERED IN ERROR"_$CHAR(30)
GOTO XEFND
+15 SET II=II+1
SET @DATA@(II)="1^"_IEN_"^"_$CHAR(30)
+16 ;
+17 QUIT