source: WorldVistAEHR/trunk/r/CMOP-PSX/PSXBPSMS.m@ 623

Last change on this file since 623 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.7 KB
Line 
1PSXBPSMS ;BIRM/BSR - BPS (ECME) Utilities ;10/29/98 2:13 PM
2 ;;2.0;CMOP;**48**;11 Apr 97
3 ;Reference to $$RXFLDT^PSOBPSUT supported by IA 4701
4 ;
5EN ;Main entry point.
6 N EMCNT,DFN,ORCNT,PATCNT,DIV,RX,DFN,SSN,PTLST,VADM
7 K ^TMP("PSXEPHOUT",$J)
8 S DIV="",(EMCNT,ORCNT,PATCNT)=0
9 F S DIV=$O(^TMP("PSXEPHIN",$J,DIV)) Q:DIV="" D
10 .D HEADER(DIV)
11 .S RX="" F S RX=$O(^TMP("PSXEPHIN",$J,DIV,RX)) Q:RX="" D
12 ..S DFN=+$P(^PSRX(RX,0),"^",2) D DEM^VADPT
13 ..S SSN=$E($P(VADM(2),U),6,9),PATNM=(VADM(1))
14 ..S ORCNT=$G(ORCNT)+1 D PATCNT(PATNM_SSN)
15 ..D FORMAT
16 .D FOOTER(DIV)
17 D MAIL,CLEAN
18 Q
19 ;
20 ; Format Row
21FORMAT ;
22 N LTXT,RFL
23 S RFL=+$G(^TMP("PSXEPHIN",$J,DIV,RX)),LTXT=$$GET1^DIQ(52,RX,.01)_"/"_RFL
24 S $E(LTXT,15)=$E(PATNM,1,18)_"("_SSN_")",$E(LTXT,40)=$E($$GET1^DIQ(52,RX,6),1,25)
25 I $$PATCH^XPDUTL("PSO*7.0*148") S $E(LTXT,66)=$$FMTE^XLFDT($$RXFLDT^PSOBPSUT(RX,RFL))
26 D STORELN(LTXT)
27 Q
28 ;
29 ;Count patients.
30PATCNT(NAMSSN) ;
31 I '$D(PTLST(NAMSSN)) D
32 .S PTLST(NAMSSN)=""
33 .S PATCNT=$G(PATCNT)+1
34 Q
35 ;
36 ;Build header.
37HEADER(DIV) ;
38 D STORELN("Division: "_$$GET1^DIQ(59,DIV,.01))
39 D STORELN($TR($J("",79)," ","-"))
40 D STORELN("RX#/Fill PATIENT(LAST4SSN) DRUG FILL DATE")
41 D STORELN($TR($J("",79)," ","-"))
42 Q
43 ;
44 ;Output patient count & prescriptions count & division number
45FOOTER(DIVN) ;
46 D STORELN(" ")
47 D STORELN("Total "_$$GET1^DIQ(59,DIVN,.01)_": "_PATCNT_" Patients and "_ORCNT_" Prescriptions.")
48 D STORELN(" ")
49 K PTLST S (ORCNT,PATCNT)=0
50 Q
51 ;
52 ;Build and Send email to provider.
53MAIL ;
54 N PSBMSG,M1,Y,USER,XMTEXT,XMDUZ,XMSUB,XMY
55 S PSBMSG(1)="The prescriptions listed below are third party electronically billable. They"
56 S PSBMSG(2)="have not been transmitted to CMOP because they have been submitted to"
57 S PSBMSG(3)="third party payer but we have not received a response regarding these"
58 S PSBMSG(4)="prescriptions yet. The prescriptions will remain in the CMOP queue to be"
59 S PSBMSG(5)="transmitted in the next transmission if the response from the third party"
60 S PSBMSG(6)="payer has been received."
61 S PSBMSG(7)=" "
62 S M1=8
63 S Y="" F S Y=$O(^TMP("PSXEPHOUT",$J,"M",Y)) Q:Y="" D
64 .S PSBMSG(M1)=$P(^TMP("PSXEPHOUT",$J,"M",Y),"^"),M1=M1+1
65 ; Send email to all users who hold a security key
66 S USER=0
67 I $D(^XUSEC("PSXMAIL")) D
68 .F S USER=$O(^XUSEC("PSXMAIL",USER)) Q:'USER S XMY(USER)=""
69 E D
70 .F S USER=$O(^XUSEC("PSXCMOPMGR",USER)) Q:'USER S XMY(USER)=""
71 ;
72 S XMTEXT="PSBMSG(",XMSUB="ePharmacy - CMOP Not TRANSMITTED Rx List"
73 S XMDUZ=.5
74 D ^XMD
75 Q
76 ;
77 ;Store E-mail line for later use.
78STORELN(LINE) ;
79 S EMCNT=EMCNT+1
80 S ^TMP("PSXEPHOUT",$J,"M",EMCNT)=LINE
81 Q
82 ;
83 ;Clean all remaining arrays and variables.
84CLEAN ;
85 K ^TMP("PSXEPHOUT",$J),^TMP("PSXEPHIN",$J)
86 Q
Note: See TracBrowser for help on using the repository browser.