Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SCDXMSG2

SCDXMSG2.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. CMPLBULL(SENT,ERRCNT,IPCNT,IPERR) ;Send completion bulletin
  1. ;
  1. ;Input : SENT - Number of encounters sent to NPCDB (Defaults to 0)
  1. ; ERRCNT - Contains the number of errored encounters
  1. ; IPCNT - Number of inpatient encounters
  1. ; IPERR - Contains the number of inpatient errored encounters
  1. ;Output : None
  1. ;
  1. ;Declare variables
  1. N MSGTXT,XMB,XMTEXT,XMY,XMDUZ,XMDT,XMZ,XMITPTR,LINE
  1. N ENCPTR,DELPTR,ENCDATE,ENCLOC,NAME,TMP,ENCZERO,SSN,PATZERO
  1. ;Deliver bulletin
  1. S XMB="SCDX AMBCARE TO NPCDB SUMMARY"
  1. S XMB(1)=+$G(SENT)
  1. S XMB(2)=+$G(ERRCNT)
  1. S XMB(3)=+$G(SENT)-(+$G(IPCNT))
  1. S XMB(4)=+$G(IPCNT)
  1. S XMB(5)=+$G(ERRCNT)-(+$G(IPERR))
  1. S XMB(6)=+$G(IPERR)
  1. D ^XMB
  1. Q
  1. ;
  1. ERRBULL(REASON) ;Send error bulletin
  1. ;
  1. ;Input : REASON - Why transmission of data could not be completed
  1. ;Output : None
  1. ;
  1. ;Check input
  1. S REASON=$G(REASON)
  1. ;Declare variables
  1. N MSGTXT,XMB,XMTEXT,XMY,XMDUZ,XMDT,XMZ
  1. ;Set message text
  1. S MSGTXT(1)="Transmission of data to the National Patient Care Database"
  1. S MSGTXT(2)=" "
  1. S MSGTXT(3)="could not be completed for the following reason:"
  1. S MSGTXT(4)=" "
  1. S MSGTXT(5)=" "_REASON
  1. ;Set bulletin subject
  1. S XMB(1)="** TRANSMISSION OF DATA TO NPCDB NOT COMPLETED **"
  1. ;Deliver bulletin
  1. S XMB="SCDX AMBCARE TO NPCDB SUMMARY"
  1. S XMTEXT="MSGTXT("
  1. D ^XMB
  1. ;Done
  1. Q
  1. ;
  1. LATEACT(XMITPTR,ACT,USER,DATE) ;Send late activity bulletin
  1. ;
  1. ;Input : XMITPTR - Pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
  1. ; (#409.73) that was acted upon
  1. ; ACT - Late activity that occurred
  1. ; Free text (defaults to transmission event of XMITPTR)
  1. ; USER - Who did the activity
  1. ; Pointer to NEW PERSON file (#200)
  1. ; (defaults to causer of event of XMITPTR)
  1. ; DATE - Date/time activity took place
  1. ; FileMan format (defaults to event date of XMITPTR)
  1. ;Output : None
  1. ;Notes : Late activity bulletin will be sent to members of the mail
  1. ; group contained in the LATE ACTIVITY MAIL GROUP field (#217)
  1. ; of the MAS PARAMETER file (#43). The bulletin will not be
  1. ; sent if this mail group has not been defined.
  1. ; : POSTMASTER (DUZ=.5) will be converted to 'ACRP NIGHTLY
  1. ; TRANSMISSION BUILDER' as the causer of the event
  1. ; : Bulletin will default to a transmission event if no ACT
  1. ; is specified
  1. ;
  1. ;Check input
  1. S XMITPTR=+$G(XMITPTR)
  1. Q:('$D(^SD(409.73,XMITPTR,0)))
  1. S ACT=$G(ACT)
  1. S USER=+$G(USER)
  1. S DATE=+$G(DATE)
  1. ;Declare variables
  1. N NODE,ENCPTR,DELPTR,ENCDATE,XMDUZ,XMTEXT,XMSUB,XMY,MSGL,SMTB,SMTN
  1. N CLOSED,DFN,CLINIC,DIV,VA,LASTXMIT,LASTACK,LASTCODE,HISTARR
  1. ;Send bulletin to site specified mail group
  1. ; Don't send if mail group not defined or is invalid
  1. S NODE=$G(^DG(43,1,"SCLR"))
  1. Q:('$P(NODE,"^",17))
  1. D XMY^SDUTL2($P(NODE,"^",17),0,0)
  1. Q:('$D(XMY))
  1. ;Get zero node of transmission file
  1. S NODE=$G(^SD(409.73,XMITPTR,0))
  1. ;Set default values (if applicable)
  1. I (ACT="") D Q:(ACT="")
  1. .S ACT=+$P(NODE,"^",5)
  1. .I (ACT=1)!(ACT=2) S ACT="Creation/Editing of encounter" Q
  1. .I (ACT=3) S ACT="Deletion of encounter" Q
  1. .S ACT="Retransmission of encounter"
  1. I ('USER) D
  1. .S USER=+$P(NODE,"^",7)
  1. .S:('USER) USER=+$G(DUZ)
  1. S:(USER=.5) USER="ACRP NIGHTLY TRANSMISSION BUILDER"
  1. I ('DATE) S DATE=+$P(NODE,"^",6) S:('DATE) DATE=$$DT^XLFDT()
  1. ;Get pointer to encounter and deleted encounter
  1. S ENCPTR=+$P(NODE,"^",2)
  1. S DELPTR=+$P(NODE,"^",3)
  1. ;Get zero node of [deleted] encounter
  1. S NODE=""
  1. S:(ENCPTR) NODE=$G(^SCE(ENCPTR,0))
  1. S:('ENCPTR) NODE=$G(^SD(409.74,DELPTR,1))
  1. ;Get date/time of encounter
  1. S ENCDATE=+NODE
  1. ;Get DFN
  1. S DFN=+$P(NODE,"^",2)
  1. ;Get clinic pointer
  1. S CLINIC=+$P(NODE,"^",4)
  1. ;Get division
  1. S DIV=+$P(NODE,"^",11)
  1. ;Get transmission history
  1. S (LASTXMIT,LASTACK,LASTCODE)=""
  1. S HISTARR=$NA(^TMP("SCDXMSG2",$J,"HIST"))
  1. K @HISTARR
  1. I ($$HST4XMIT^SCDXFU13(XMITPTR,HISTARR,1)) D
  1. .;Get last xmit date
  1. .S LASTXMIT=+$O(@HISTARR@(""),-1)
  1. .Q:('LASTXMIT)
  1. .;Get ack info for last xmit
  1. .S LASTACK=$G(@HISTARR@(LASTXMIT))
  1. .S LASTCODE=$P(LASTACK,"^",3)
  1. .S LASTACK=$P(LASTACK,"^",2)
  1. K @HISTARR
  1. ;Determine the level of acceptance for data base credit and/or
  1. ;workload credit
  1. S MSGL=$$XMIT4DBC^SCDXFU04(XMITPTR)
  1. Q:MSGL<1!(MSGL>4) ; Only four levels of messages are defined
  1. ; 0 - no message, transmit
  1. ; 5 - no transmit; error
  1. ;Build message
  1. S SMTB="The following activity occurred "
  1. S XMTEXT(1)=SMTB_"after the National Patient Care"
  1. S XMTEXT(2)="Database was closed"
  1. I MSGL=4 S XMTEXT(2)=XMTEXT(2)_"."
  1. I MSGL=3 D
  1. .S XMTEXT(2)=XMTEXT(2)_" for yearly workload credit but will be sent"
  1. .S XMTEXT(3)="to the NPCD for historical accuracy of the database."
  1. I MSGL=2 D
  1. .S XMTEXT(2)=XMTEXT(2)_" for monthly workload credit but will be sent"
  1. .S XMTEXT(3)="to the NPCD to be included in the fiscal year totals."
  1. I MSGL=1 D
  1. .; the rolling 20-day message is based on setup of ROLLD=19 in
  1. .; CLOSEOUT^SCDXFU04
  1. .S XMTEXT(1)=SMTB_"20 or more days after the encounter"
  1. .S XMTEXT(2)="date but is valid for workload credit and will be sent"
  1. .S XMTEXT(3)="to the National Patient Care Database."
  1. S SMTN=$S(MSGL=4:3,1:4) S XMTEXT(SMTN)=" "
  1. S XMTEXT(SMTN+1)=" Activity: "_ACT
  1. S XMTEXT(SMTN+2)="Entered By: "_$S(USER:$P($G(^VA(200,USER,0)),"^",1),1:USER)
  1. S XMTEXT(SMTN+3)="Entered On: "_$$FMTE^XLFDT(DATE)
  1. S XMTEXT(SMTN+4)=" "
  1. S XMTEXT(SMTN+5)=" Encounter Date: "_$$FMTE^XLFDT(ENCDATE)_" (#"_$S(ENCPTR:ENCPTR,1:DELPTR)_")"
  1. S:('ENCPTR) XMTEXT(SMTN+5)=XMTEXT(SMTN+5)_" ** Deleted Encounter **"
  1. S XMTEXT(SMTN+6)="Last NPCD Transmission: "_$S(LASTXMIT:$$FMTE^XLFDT(LASTXMIT),1:"Encounter data never transmitted ")_" (#"_XMITPTR_")"
  1. S XMTEXT(SMTN+7)="Last NPCD Ack Received: "_$S(LASTACK:$$FMTE^XLFDT(+LASTACK),1:"Acknowledgement not received")
  1. S:(LASTACK) XMTEXT(SMTN+7)=XMTEXT(SMTN+7)_" ("_$S((LASTCODE'=""):$$EXTERNAL^DILFD(409.73,15,"",LASTCODE),1:"Status unknown")_")"
  1. S XMTEXT(SMTN+8)=" "
  1. S XMTEXT(SMTN+9)=" Clinic: "_$P($G(^SC(CLINIC,0)),"^",1)
  1. D PID^VADPT6
  1. S XMTEXT(SMTN+10)="Patient: "_$P($G(^DPT(DFN,0)),"^",1)_" ("_VA("BID")_")"
  1. ;Send message
  1. S XMSUB="Late ACRP Related Activity"_$$DIV^SDAMEVT1(DIV)
  1. S XMTEXT="XMTEXT("
  1. S XMDUZ=.5
  1. S:(USER) XMY(USER)=""
  1. D ^XMD ; REMOVE COMMENT
  1. ;Done
  1. Q