SCDXMSG2 ;ALB/JRP - AMB CARE TRANSMISSION BULLETINS;01-JUL-1996 ; 1/17/02 5:07pm
;;5.3;Scheduling;**44,121,128,66,132,247,393,466**;AUG 13, 1993;Build 2
;
CMPLBULL(SENT,ERRCNT,IPCNT,IPERR) ;Send completion bulletin
;
;Input : SENT - Number of encounters sent to NPCDB (Defaults to 0)
; ERRCNT - Contains the number of errored encounters
; IPCNT - Number of inpatient encounters
; IPERR - Contains the number of inpatient errored encounters
;Output : None
;
;Declare variables
N MSGTXT,XMB,XMTEXT,XMY,XMDUZ,XMDT,XMZ,XMITPTR,LINE
N ENCPTR,DELPTR,ENCDATE,ENCLOC,NAME,TMP,ENCZERO,SSN,PATZERO
;Deliver bulletin
S XMB="SCDX AMBCARE TO NPCDB SUMMARY"
S XMB(1)=+$G(SENT)
S XMB(2)=+$G(ERRCNT)
S XMB(3)=+$G(SENT)-(+$G(IPCNT))
S XMB(4)=+$G(IPCNT)
S XMB(5)=+$G(ERRCNT)-(+$G(IPERR))
S XMB(6)=+$G(IPERR)
D ^XMB
Q
;
ERRBULL(REASON) ;Send error bulletin
;
;Input : REASON - Why transmission of data could not be completed
;Output : None
;
;Check input
S REASON=$G(REASON)
;Declare variables
N MSGTXT,XMB,XMTEXT,XMY,XMDUZ,XMDT,XMZ
;Set message text
S MSGTXT(1)="Transmission of data to the National Patient Care Database"
S MSGTXT(2)=" "
S MSGTXT(3)="could not be completed for the following reason:"
S MSGTXT(4)=" "
S MSGTXT(5)=" "_REASON
;Set bulletin subject
S XMB(1)="** TRANSMISSION OF DATA TO NPCDB NOT COMPLETED **"
;Deliver bulletin
S XMB="SCDX AMBCARE TO NPCDB SUMMARY"
S XMTEXT="MSGTXT("
D ^XMB
;Done
Q
;
LATEACT(XMITPTR,ACT,USER,DATE) ;Send late activity bulletin
;
;Input : XMITPTR - Pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
; (#409.73) that was acted upon
; ACT - Late activity that occurred
; Free text (defaults to transmission event of XMITPTR)
; USER - Who did the activity
; Pointer to NEW PERSON file (#200)
; (defaults to causer of event of XMITPTR)
; DATE - Date/time activity took place
; FileMan format (defaults to event date of XMITPTR)
;Output : None
;Notes : Late activity bulletin will be sent to members of the mail
; group contained in the LATE ACTIVITY MAIL GROUP field (#217)
; of the MAS PARAMETER file (#43). The bulletin will not be
; sent if this mail group has not been defined.
; : POSTMASTER (DUZ=.5) will be converted to 'ACRP NIGHTLY
; TRANSMISSION BUILDER' as the causer of the event
; : Bulletin will default to a transmission event if no ACT
; is specified
;
;Check input
S XMITPTR=+$G(XMITPTR)
Q:('$D(^SD(409.73,XMITPTR,0)))
S ACT=$G(ACT)
S USER=+$G(USER)
S DATE=+$G(DATE)
;Declare variables
N NODE,ENCPTR,DELPTR,ENCDATE,XMDUZ,XMTEXT,XMSUB,XMY,MSGL,SMTB,SMTN
N CLOSED,DFN,CLINIC,DIV,VA,LASTXMIT,LASTACK,LASTCODE,HISTARR
;Send bulletin to site specified mail group
; Don't send if mail group not defined or is invalid
S NODE=$G(^DG(43,1,"SCLR"))
Q:('$P(NODE,"^",17))
D XMY^SDUTL2($P(NODE,"^",17),0,0)
Q:('$D(XMY))
;Get zero node of transmission file
S NODE=$G(^SD(409.73,XMITPTR,0))
;Set default values (if applicable)
I (ACT="") D Q:(ACT="")
.S ACT=+$P(NODE,"^",5)
.I (ACT=1)!(ACT=2) S ACT="Creation/Editing of encounter" Q
.I (ACT=3) S ACT="Deletion of encounter" Q
.S ACT="Retransmission of encounter"
I ('USER) D
.S USER=+$P(NODE,"^",7)
.S:('USER) USER=+$G(DUZ)
S:(USER=.5) USER="ACRP NIGHTLY TRANSMISSION BUILDER"
I ('DATE) S DATE=+$P(NODE,"^",6) S:('DATE) DATE=$$DT^XLFDT()
;Get pointer to encounter and deleted encounter
S ENCPTR=+$P(NODE,"^",2)
S DELPTR=+$P(NODE,"^",3)
;Get zero node of [deleted] encounter
S NODE=""
S:(ENCPTR) NODE=$G(^SCE(ENCPTR,0))
S:('ENCPTR) NODE=$G(^SD(409.74,DELPTR,1))
;Get date/time of encounter
S ENCDATE=+NODE
;Get DFN
S DFN=+$P(NODE,"^",2)
;Get clinic pointer
S CLINIC=+$P(NODE,"^",4)
;Get division
S DIV=+$P(NODE,"^",11)
;Get transmission history
S (LASTXMIT,LASTACK,LASTCODE)=""
S HISTARR=$NA(^TMP("SCDXMSG2",$J,"HIST"))
K @HISTARR
I ($$HST4XMIT^SCDXFU13(XMITPTR,HISTARR,1)) D
.;Get last xmit date
.S LASTXMIT=+$O(@HISTARR@(""),-1)
.Q:('LASTXMIT)
.;Get ack info for last xmit
.S LASTACK=$G(@HISTARR@(LASTXMIT))
.S LASTCODE=$P(LASTACK,"^",3)
.S LASTACK=$P(LASTACK,"^",2)
K @HISTARR
;Determine the level of acceptance for data base credit and/or
;workload credit
S MSGL=$$XMIT4DBC^SCDXFU04(XMITPTR)
Q:MSGL<1!(MSGL>4) ; Only four levels of messages are defined
; 0 - no message, transmit
; 5 - no transmit; error
;Build message
S SMTB="The following activity occurred "
S XMTEXT(1)=SMTB_"after the National Patient Care"
S XMTEXT(2)="Database was closed"
I MSGL=4 S XMTEXT(2)=XMTEXT(2)_"."
I MSGL=3 D
.S XMTEXT(2)=XMTEXT(2)_" for yearly workload credit but will be sent"
.S XMTEXT(3)="to the NPCD for historical accuracy of the database."
I MSGL=2 D
.S XMTEXT(2)=XMTEXT(2)_" for monthly workload credit but will be sent"
.S XMTEXT(3)="to the NPCD to be included in the fiscal year totals."
I MSGL=1 D
.; the rolling 20-day message is based on setup of ROLLD=19 in
.; CLOSEOUT^SCDXFU04
.S XMTEXT(1)=SMTB_"20 or more days after the encounter"
.S XMTEXT(2)="date but is valid for workload credit and will be sent"
.S XMTEXT(3)="to the National Patient Care Database."
S SMTN=$S(MSGL=4:3,1:4) S XMTEXT(SMTN)=" "
S XMTEXT(SMTN+1)=" Activity: "_ACT
S XMTEXT(SMTN+2)="Entered By: "_$S(USER:$P($G(^VA(200,USER,0)),"^",1),1:USER)
S XMTEXT(SMTN+3)="Entered On: "_$$FMTE^XLFDT(DATE)
S XMTEXT(SMTN+4)=" "
S XMTEXT(SMTN+5)=" Encounter Date: "_$$FMTE^XLFDT(ENCDATE)_" (#"_$S(ENCPTR:ENCPTR,1:DELPTR)_")"
S:('ENCPTR) XMTEXT(SMTN+5)=XMTEXT(SMTN+5)_" ** Deleted Encounter **"
S XMTEXT(SMTN+6)="Last NPCD Transmission: "_$S(LASTXMIT:$$FMTE^XLFDT(LASTXMIT),1:"Encounter data never transmitted ")_" (#"_XMITPTR_")"
S XMTEXT(SMTN+7)="Last NPCD Ack Received: "_$S(LASTACK:$$FMTE^XLFDT(+LASTACK),1:"Acknowledgement not received")
S:(LASTACK) XMTEXT(SMTN+7)=XMTEXT(SMTN+7)_" ("_$S((LASTCODE'=""):$$EXTERNAL^DILFD(409.73,15,"",LASTCODE),1:"Status unknown")_")"
S XMTEXT(SMTN+8)=" "
S XMTEXT(SMTN+9)=" Clinic: "_$P($G(^SC(CLINIC,0)),"^",1)
D PID^VADPT6
S XMTEXT(SMTN+10)="Patient: "_$P($G(^DPT(DFN,0)),"^",1)_" ("_VA("BID")_")"
;Send message
S XMSUB="Late ACRP Related Activity"_$$DIV^SDAMEVT1(DIV)
S XMTEXT="XMTEXT("
S XMDUZ=.5
S:(USER) XMY(USER)=""
D ^XMD ; REMOVE COMMENT
;Done
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCDXMSG2 6570 printed Dec 13, 2024@02:39:20 Page 2
SCDXMSG2 ;ALB/JRP - AMB CARE TRANSMISSION BULLETINS;01-JUL-1996 ; 1/17/02 5:07pm
+1 ;;5.3;Scheduling;**44,121,128,66,132,247,393,466**;AUG 13, 1993;Build 2
+2 ;
CMPLBULL(SENT,ERRCNT,IPCNT,IPERR) ;Send completion bulletin
+1 ;
+2 ;Input : SENT - Number of encounters sent to NPCDB (Defaults to 0)
+3 ; ERRCNT - Contains the number of errored encounters
+4 ; IPCNT - Number of inpatient encounters
+5 ; IPERR - Contains the number of inpatient errored encounters
+6 ;Output : None
+7 ;
+8 ;Declare variables
+9 NEW MSGTXT,XMB,XMTEXT,XMY,XMDUZ,XMDT,XMZ,XMITPTR,LINE
+10 NEW ENCPTR,DELPTR,ENCDATE,ENCLOC,NAME,TMP,ENCZERO,SSN,PATZERO
+11 ;Deliver bulletin
+12 SET XMB="SCDX AMBCARE TO NPCDB SUMMARY"
+13 SET XMB(1)=+$GET(SENT)
+14 SET XMB(2)=+$GET(ERRCNT)
+15 SET XMB(3)=+$GET(SENT)-(+$GET(IPCNT))
+16 SET XMB(4)=+$GET(IPCNT)
+17 SET XMB(5)=+$GET(ERRCNT)-(+$GET(IPERR))
+18 SET XMB(6)=+$GET(IPERR)
+19 DO ^XMB
+20 QUIT
+21 ;
ERRBULL(REASON) ;Send error bulletin
+1 ;
+2 ;Input : REASON - Why transmission of data could not be completed
+3 ;Output : None
+4 ;
+5 ;Check input
+6 SET REASON=$GET(REASON)
+7 ;Declare variables
+8 NEW MSGTXT,XMB,XMTEXT,XMY,XMDUZ,XMDT,XMZ
+9 ;Set message text
+10 SET MSGTXT(1)="Transmission of data to the National Patient Care Database"
+11 SET MSGTXT(2)=" "
+12 SET MSGTXT(3)="could not be completed for the following reason:"
+13 SET MSGTXT(4)=" "
+14 SET MSGTXT(5)=" "_REASON
+15 ;Set bulletin subject
+16 SET XMB(1)="** TRANSMISSION OF DATA TO NPCDB NOT COMPLETED **"
+17 ;Deliver bulletin
+18 SET XMB="SCDX AMBCARE TO NPCDB SUMMARY"
+19 SET XMTEXT="MSGTXT("
+20 DO ^XMB
+21 ;Done
+22 QUIT
+23 ;
LATEACT(XMITPTR,ACT,USER,DATE) ;Send late activity bulletin
+1 ;
+2 ;Input : XMITPTR - Pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
+3 ; (#409.73) that was acted upon
+4 ; ACT - Late activity that occurred
+5 ; Free text (defaults to transmission event of XMITPTR)
+6 ; USER - Who did the activity
+7 ; Pointer to NEW PERSON file (#200)
+8 ; (defaults to causer of event of XMITPTR)
+9 ; DATE - Date/time activity took place
+10 ; FileMan format (defaults to event date of XMITPTR)
+11 ;Output : None
+12 ;Notes : Late activity bulletin will be sent to members of the mail
+13 ; group contained in the LATE ACTIVITY MAIL GROUP field (#217)
+14 ; of the MAS PARAMETER file (#43). The bulletin will not be
+15 ; sent if this mail group has not been defined.
+16 ; : POSTMASTER (DUZ=.5) will be converted to 'ACRP NIGHTLY
+17 ; TRANSMISSION BUILDER' as the causer of the event
+18 ; : Bulletin will default to a transmission event if no ACT
+19 ; is specified
+20 ;
+21 ;Check input
+22 SET XMITPTR=+$GET(XMITPTR)
+23 if ('$DATA(^SD(409.73,XMITPTR,0)))
QUIT
+24 SET ACT=$GET(ACT)
+25 SET USER=+$GET(USER)
+26 SET DATE=+$GET(DATE)
+27 ;Declare variables
+28 NEW NODE,ENCPTR,DELPTR,ENCDATE,XMDUZ,XMTEXT,XMSUB,XMY,MSGL,SMTB,SMTN
+29 NEW CLOSED,DFN,CLINIC,DIV,VA,LASTXMIT,LASTACK,LASTCODE,HISTARR
+30 ;Send bulletin to site specified mail group
+31 ; Don't send if mail group not defined or is invalid
+32 SET NODE=$GET(^DG(43,1,"SCLR"))
+33 if ('$PIECE(NODE,"^",17))
QUIT
+34 DO XMY^SDUTL2($PIECE(NODE,"^",17),0,0)
+35 if ('$DATA(XMY))
QUIT
+36 ;Get zero node of transmission file
+37 SET NODE=$GET(^SD(409.73,XMITPTR,0))
+38 ;Set default values (if applicable)
+39 IF (ACT="")
Begin DoDot:1
+40 SET ACT=+$PIECE(NODE,"^",5)
+41 IF (ACT=1)!(ACT=2)
SET ACT="Creation/Editing of encounter"
QUIT
+42 IF (ACT=3)
SET ACT="Deletion of encounter"
QUIT
+43 SET ACT="Retransmission of encounter"
End DoDot:1
if (ACT="")
QUIT
+44 IF ('USER)
Begin DoDot:1
+45 SET USER=+$PIECE(NODE,"^",7)
+46 if ('USER)
SET USER=+$GET(DUZ)
End DoDot:1
+47 if (USER=.5)
SET USER="ACRP NIGHTLY TRANSMISSION BUILDER"
+48 IF ('DATE)
SET DATE=+$PIECE(NODE,"^",6)
if ('DATE)
SET DATE=$$DT^XLFDT()
+49 ;Get pointer to encounter and deleted encounter
+50 SET ENCPTR=+$PIECE(NODE,"^",2)
+51 SET DELPTR=+$PIECE(NODE,"^",3)
+52 ;Get zero node of [deleted] encounter
+53 SET NODE=""
+54 if (ENCPTR)
SET NODE=$GET(^SCE(ENCPTR,0))
+55 if ('ENCPTR)
SET NODE=$GET(^SD(409.74,DELPTR,1))
+56 ;Get date/time of encounter
+57 SET ENCDATE=+NODE
+58 ;Get DFN
+59 SET DFN=+$PIECE(NODE,"^",2)
+60 ;Get clinic pointer
+61 SET CLINIC=+$PIECE(NODE,"^",4)
+62 ;Get division
+63 SET DIV=+$PIECE(NODE,"^",11)
+64 ;Get transmission history
+65 SET (LASTXMIT,LASTACK,LASTCODE)=""
+66 SET HISTARR=$NAME(^TMP("SCDXMSG2",$JOB,"HIST"))
+67 KILL @HISTARR
+68 IF ($$HST4XMIT^SCDXFU13(XMITPTR,HISTARR,1))
Begin DoDot:1
+69 ;Get last xmit date
+70 SET LASTXMIT=+$ORDER(@HISTARR@(""),-1)
+71 if ('LASTXMIT)
QUIT
+72 ;Get ack info for last xmit
+73 SET LASTACK=$GET(@HISTARR@(LASTXMIT))
+74 SET LASTCODE=$PIECE(LASTACK,"^",3)
+75 SET LASTACK=$PIECE(LASTACK,"^",2)
End DoDot:1
+76 KILL @HISTARR
+77 ;Determine the level of acceptance for data base credit and/or
+78 ;workload credit
+79 SET MSGL=$$XMIT4DBC^SCDXFU04(XMITPTR)
+80 ; Only four levels of messages are defined
if MSGL<1!(MSGL>4)
QUIT
+81 ; 0 - no message, transmit
+82 ; 5 - no transmit; error
+83 ;Build message
+84 SET SMTB="The following activity occurred "
+85 SET XMTEXT(1)=SMTB_"after the National Patient Care"
+86 SET XMTEXT(2)="Database was closed"
+87 IF MSGL=4
SET XMTEXT(2)=XMTEXT(2)_"."
+88 IF MSGL=3
Begin DoDot:1
+89 SET XMTEXT(2)=XMTEXT(2)_" for yearly workload credit but will be sent"
+90 SET XMTEXT(3)="to the NPCD for historical accuracy of the database."
End DoDot:1
+91 IF MSGL=2
Begin DoDot:1
+92 SET XMTEXT(2)=XMTEXT(2)_" for monthly workload credit but will be sent"
+93 SET XMTEXT(3)="to the NPCD to be included in the fiscal year totals."
End DoDot:1
+94 IF MSGL=1
Begin DoDot:1
+95 ; the rolling 20-day message is based on setup of ROLLD=19 in
+96 ; CLOSEOUT^SCDXFU04
+97 SET XMTEXT(1)=SMTB_"20 or more days after the encounter"
+98 SET XMTEXT(2)="date but is valid for workload credit and will be sent"
+99 SET XMTEXT(3)="to the National Patient Care Database."
End DoDot:1
+100 SET SMTN=$SELECT(MSGL=4:3,1:4)
SET XMTEXT(SMTN)=" "
+101 SET XMTEXT(SMTN+1)=" Activity: "_ACT
+102 SET XMTEXT(SMTN+2)="Entered By: "_$SELECT(USER:$PIECE($GET(^VA(200,USER,0)),"^",1),1:USER)
+103 SET XMTEXT(SMTN+3)="Entered On: "_$$FMTE^XLFDT(DATE)
+104 SET XMTEXT(SMTN+4)=" "
+105 SET XMTEXT(SMTN+5)=" Encounter Date: "_$$FMTE^XLFDT(ENCDATE)_" (#"_$SELECT(ENCPTR:ENCPTR,1:DELPTR)_")"
+106 if ('ENCPTR)
SET XMTEXT(SMTN+5)=XMTEXT(SMTN+5)_" ** Deleted Encounter **"
+107 SET XMTEXT(SMTN+6)="Last NPCD Transmission: "_$SELECT(LASTXMIT:$$FMTE^XLFDT(LASTXMIT),1:"Encounter data never transmitted ")_" (#"_XMITPTR_")"
+108 SET XMTEXT(SMTN+7)="Last NPCD Ack Received: "_$SELECT(LASTACK:$$FMTE^XLFDT(+LASTACK),1:"Acknowledgement not received")
+109 if (LASTACK)
SET XMTEXT(SMTN+7)=XMTEXT(SMTN+7)_" ("_$SELECT((LASTCODE'=""):$$EXTERNAL^DILFD(409.73,15,"",LASTCODE),1:"Status unknown")_")"
+110 SET XMTEXT(SMTN+8)=" "
+111 SET XMTEXT(SMTN+9)=" Clinic: "_$PIECE($GET(^SC(CLINIC,0)),"^",1)
+112 DO PID^VADPT6
+113 SET XMTEXT(SMTN+10)="Patient: "_$PIECE($GET(^DPT(DFN,0)),"^",1)_" ("_VA("BID")_")"
+114 ;Send message
+115 SET XMSUB="Late ACRP Related Activity"_$$DIV^SDAMEVT1(DIV)
+116 SET XMTEXT="XMTEXT("
+117 SET XMDUZ=.5
+118 if (USER)
SET XMY(USER)=""
+119 ; REMOVE COMMENT
DO ^XMD
+120 ;Done
+121 QUIT