PSXBPSMS ;BIRM/BSR - BPS (ECME) Utilities ;10/29/98 2:13 PM
;;2.0;CMOP;**48**;11 Apr 97
;Reference to $$RXFLDT^PSOBPSUT supported by IA 4701
;
EN ;Main entry point.
N EMCNT,DFN,ORCNT,PATCNT,DIV,RX,DFN,SSN,PTLST,VADM
K ^TMP("PSXEPHOUT",$J)
S DIV="",(EMCNT,ORCNT,PATCNT)=0
F S DIV=$O(^TMP("PSXEPHIN",$J,DIV)) Q:DIV="" D
.D HEADER(DIV)
.S RX="" F S RX=$O(^TMP("PSXEPHIN",$J,DIV,RX)) Q:RX="" D
..S DFN=+$P(^PSRX(RX,0),"^",2) D DEM^VADPT
..S SSN=$E($P(VADM(2),U),6,9),PATNM=(VADM(1))
..S ORCNT=$G(ORCNT)+1 D PATCNT(PATNM_SSN)
..D FORMAT
.D FOOTER(DIV)
D MAIL,CLEAN
Q
;
; Format Row
FORMAT ;
N LTXT,RFL
S RFL=+$G(^TMP("PSXEPHIN",$J,DIV,RX)),LTXT=$$GET1^DIQ(52,RX,.01)_"/"_RFL
S $E(LTXT,15)=$E(PATNM,1,18)_"("_SSN_")",$E(LTXT,40)=$E($$GET1^DIQ(52,RX,6),1,25)
I $$PATCH^XPDUTL("PSO*7.0*148") S $E(LTXT,66)=$$FMTE^XLFDT($$RXFLDT^PSOBPSUT(RX,RFL))
D STORELN(LTXT)
Q
;
;Count patients.
PATCNT(NAMSSN) ;
I '$D(PTLST(NAMSSN)) D
.S PTLST(NAMSSN)=""
.S PATCNT=$G(PATCNT)+1
Q
;
;Build header.
D STORELN("Division: "_$$GET1^DIQ(59,DIV,.01))
D STORELN($TR($J("",79)," ","-"))
D STORELN("RX#/Fill PATIENT(LAST4SSN) DRUG FILL DATE")
D STORELN($TR($J("",79)," ","-"))
Q
;
;Output patient count & prescriptions count & division number
D STORELN(" ")
D STORELN("Total "_$$GET1^DIQ(59,DIVN,.01)_": "_PATCNT_" Patients and "_ORCNT_" Prescriptions.")
D STORELN(" ")
K PTLST S (ORCNT,PATCNT)=0
Q
;
;Build and Send email to provider.
MAIL ;
N PSBMSG,M1,Y,USER,XMTEXT,XMDUZ,XMSUB,XMY
S PSBMSG(1)="The prescriptions listed below are third party electronically billable. They"
S PSBMSG(2)="have not been transmitted to CMOP because they have been submitted to"
S PSBMSG(3)="third party payer but we have not received a response regarding these"
S PSBMSG(4)="prescriptions yet. The prescriptions will remain in the CMOP queue to be"
S PSBMSG(5)="transmitted in the next transmission if the response from the third party"
S PSBMSG(6)="payer has been received."
S PSBMSG(7)=" "
S M1=8
S Y="" F S Y=$O(^TMP("PSXEPHOUT",$J,"M",Y)) Q:Y="" D
.S PSBMSG(M1)=$P(^TMP("PSXEPHOUT",$J,"M",Y),"^"),M1=M1+1
; Send email to all users who hold a security key
S USER=0
I $D(^XUSEC("PSXMAIL")) D
.F S USER=$O(^XUSEC("PSXMAIL",USER)) Q:'USER S XMY(USER)=""
E D
.F S USER=$O(^XUSEC("PSXCMOPMGR",USER)) Q:'USER S XMY(USER)=""
;
S XMTEXT="PSBMSG(",XMSUB="ePharmacy - CMOP Not TRANSMITTED Rx List"
S XMDUZ=.5
D ^XMD
Q
;
;Store E-mail line for later use.
STORELN(LINE) ;
S EMCNT=EMCNT+1
S ^TMP("PSXEPHOUT",$J,"M",EMCNT)=LINE
Q
;
;Clean all remaining arrays and variables.
CLEAN ;
K ^TMP("PSXEPHOUT",$J),^TMP("PSXEPHIN",$J)
Q
PSXBPSMS ;BIRM/BSR - BPS (ECME) Utilities ;10/29/98 2:13 PM
+1 ;;2.0;CMOP;**48**;11 Apr 97
+2 ;Reference to $$RXFLDT^PSOBPSUT supported by IA 4701
+3 ;
EN ;Main entry point.
+1 NEW EMCNT,DFN,ORCNT,PATCNT,DIV,RX,DFN,SSN,PTLST,VADM
+2 KILL ^TMP("PSXEPHOUT",$JOB)
+3 SET DIV=""
SET (EMCNT,ORCNT,PATCNT)=0
+4 FOR
SET DIV=$ORDER(^TMP("PSXEPHIN",$JOB,DIV))
IF DIV=""
QUIT
Begin DoDot:1
+5 DO HEADER(DIV)
+6 SET RX=""
FOR
SET RX=$ORDER(^TMP("PSXEPHIN",$JOB,DIV,RX))
IF RX=""
QUIT
Begin DoDot:2
+7 SET DFN=+$PIECE(^PSRX(RX,0),"^",2)
DO DEM^VADPT
+8 SET SSN=$EXTRACT($PIECE(VADM(2),U),6,9)
SET PATNM=(VADM(1))
+9 SET ORCNT=$GET(ORCNT)+1
DO PATCNT(PATNM_SSN)
+10 DO FORMAT
End DoDot:2
+11 DO FOOTER(DIV)
End DoDot:1
+12 DO MAIL
DO CLEAN
+13 QUIT
+14 ;
+15 ; Format Row
FORMAT ;
+1 NEW LTXT,RFL
+2 SET RFL=+$GET(^TMP("PSXEPHIN",$JOB,DIV,RX))
SET LTXT=$$GET1^DIQ(52,RX,.01)_"/"_RFL
+3 SET $EXTRACT(LTXT,15)=$EXTRACT(PATNM,1,18)_"("_SSN_")"
SET $EXTRACT(LTXT,40)=$EXTRACT($$GET1^DIQ(52,RX,6),1,25)
+4 IF $$PATCH^XPDUTL("PSO*7.0*148")
SET $EXTRACT(LTXT,66)=$$FMTE^XLFDT($$RXFLDT^PSOBPSUT(RX,RFL))
+5 DO STORELN(LTXT)
+6 QUIT
+7 ;
+8 ;Count patients.
PATCNT(NAMSSN) ;
+1 IF '$DATA(PTLST(NAMSSN))
Begin DoDot:1
+2 SET PTLST(NAMSSN)=""
+3 SET PATCNT=$GET(PATCNT)+1
End DoDot:1
+4 QUIT
+5 ;
+6 ;Build header.
+1 DO STORELN("Division: "_$$GET1^DIQ(59,DIV,.01))
+2 DO STORELN($TRANSLATE($JUSTIFY("",79)," ","-"))
+3 DO STORELN("RX#/Fill PATIENT(LAST4SSN) DRUG FILL DATE")
+4 DO STORELN($TRANSLATE($JUSTIFY("",79)," ","-"))
+5 QUIT
+6 ;
+7 ;Output patient count & prescriptions count & division number
+1 DO STORELN(" ")
+2 DO STORELN("Total "_$$GET1^DIQ(59,DIVN,.01)_": "_PATCNT_" Patients and "_ORCNT_" Prescriptions.")
+3 DO STORELN(" ")
+4 KILL PTLST
SET (ORCNT,PATCNT)=0
+5 QUIT
+6 ;
+7 ;Build and Send email to provider.
MAIL ;
+1 NEW PSBMSG,M1,Y,USER,XMTEXT,XMDUZ,XMSUB,XMY
+2 SET PSBMSG(1)="The prescriptions listed below are third party electronically billable. They"
+3 SET PSBMSG(2)="have not been transmitted to CMOP because they have been submitted to"
+4 SET PSBMSG(3)="third party payer but we have not received a response regarding these"
+5 SET PSBMSG(4)="prescriptions yet. The prescriptions will remain in the CMOP queue to be"
+6 SET PSBMSG(5)="transmitted in the next transmission if the response from the third party"
+7 SET PSBMSG(6)="payer has been received."
+8 SET PSBMSG(7)=" "
+9 SET M1=8
+10 SET Y=""
FOR
SET Y=$ORDER(^TMP("PSXEPHOUT",$JOB,"M",Y))
IF Y=""
QUIT
Begin DoDot:1
+11 SET PSBMSG(M1)=$PIECE(^TMP("PSXEPHOUT",$JOB,"M",Y),"^")
SET M1=M1+1
End DoDot:1
+12 ; Send email to all users who hold a security key
+13 SET USER=0
+14 IF $DATA(^XUSEC("PSXMAIL"))
Begin DoDot:1
+15 FOR
SET USER=$ORDER(^XUSEC("PSXMAIL",USER))
IF 'USER
QUIT
SET XMY(USER)=""
End DoDot:1
+16 IF '$TEST
Begin DoDot:1
+17 FOR
SET USER=$ORDER(^XUSEC("PSXCMOPMGR",USER))
IF 'USER
QUIT
SET XMY(USER)=""
End DoDot:1
+18 ;
+19 SET XMTEXT="PSBMSG("
SET XMSUB="ePharmacy - CMOP Not TRANSMITTED Rx List"
+20 SET XMDUZ=.5
+21 DO ^XMD
+22 QUIT
+23 ;
+24 ;Store E-mail line for later use.
STORELN(LINE) ;
+1 SET EMCNT=EMCNT+1
+2 SET ^TMP("PSXEPHOUT",$JOB,"M",EMCNT)=LINE
+3 QUIT
+4 ;
+5 ;Clean all remaining arrays and variables.
CLEAN ;
+1 KILL ^TMP("PSXEPHOUT",$JOB),^TMP("PSXEPHIN",$JOB)
+2 QUIT