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

PSUOPMD.m

Go to the documentation of this file.
PSUOPMD ;BIR/CFL,DAM - PSU PBM Multidose Outpatient Pharmacy create mailman messages ;17 NOV 2004
 ;;4.0;PHARMACY BENEFITS MANAGEMENT;;MARCH, 2005
 ;
 ;DBIA(s)
 ; Reference to file #4.3 supported by DBIA 2496
 ; Reference to file #59  supported by DBIA 2510
 ; Reference to file #4   supported by DBIA 10090
 ;
EN ;
 ;
 S $P(PSUDASH,"-",100)=""
 S $P(PSUFILL," ",100)=""
 ;Organize index of ^XTMP("DATAMD") global
 S (PSUDV,PSUTMP)=""
 F  S PSUDV=$O(^XTMP(PSUOPSUB,"DATAMD",PSUDV)) Q:PSUDV=""  D
 .S PSULCT=0
 .S PSURXIEN=""
 .F  S PSURXIEN=$O(^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN)) Q:PSURXIEN=""  D
 ..S PSURCT=0
 ..F  S PSURCT=$O(^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT)) Q:PSURCT=""  D
 ...S PSULCT=PSULCT+1
 ...S ^XTMP(PSUOPSUB,"RECMD",PSUDV,PSULCT)=^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,1)
 ...S PSULCT=PSULCT+1
 ...S ^XTMP(PSUOPSUB,"RECMD",PSUDV,PSULCT)=^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,2)
 ...S PSULCT=PSULCT+1
 ...S ^XTMP(PSUOPSUB,"RECMD",PSUDV,PSULCT)=^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,3)
 ...Q:'$D(^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,4))
 ...S PSULCT=PSULCT+1
 ...S ^XTMP(PSUOPSUB,"RECMD",PSUDV,PSULCT)=^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,4)
 ...Q:'$D(^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,5))
 ...S PSULCT=PSULCT+1
 ...S ^XTMP(PSUOPSUB,"RECMD",PSUDV,PSULCT)=^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,5)
 ...Q:'$D(^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,6))
 ...S PSULCT=PSULCT+1
 ...S ^XTMP(PSUOPSUB,"RECMD",PSUDV,PSULCT)=^XTMP(PSUOPSUB,"DATAMD",PSUDV,PSURXIEN,PSURCT,6)
 ;
 ;
MSG ;Set up the number of lines and messages for mailman
 ;
 S PSUNOREC="",NONE=""
 S PSUMSGT("M")=0,PSUMSGT("L")=0
 I '$D(^XTMP(PSUOPSUB,"RECMD")) D NODATA Q  ;Do not go any further if there is no data to report
 S PSUDIV=0,Z=0
 F  S PSUDIV=$O(^XTMP(PSUOPSUB,"RECMD",PSUDIV)) Q:PSUDIV=""  D
 .S X=PSUDIV,DIC=59,DIC(0)="XM" D ^DIC ;**1
 .S X=+Y,PSUDIVNM=$$VAL^PSUTL(59,X,.01)
 .I PSUMASF!PSUDUZ!PSUPBMG D 
 ..D XMD,SETCNT
 Q
XMD ;
 NEW PSUMAX,PSULC,PSUTMC,PSUTLC,PSUMC,PSUOLD1,PSUOLD2,PSUOLD3
 S PSUMAX=$$VAL^PSUTL(4.3,1,8.3)
 S PSUMAX=$S(PSUMAX="":10000,PSUMAX>10000:10000,1:PSUMAX)
 K ^XTMP(PSUOPSUB,"XMD")
 S PSUMC=1,PSUMLC=0
 F PSULC=1:1 S X=$G(^XTMP(PSUOPSUB,"RECMD",PSUDIV,PSULC)) Q:X=""  D
 .S PSUMLC=PSUMLC+1
 .I PSUMLC>PSUMAX D
 ..I $E(X,1)'="*" S PSUMLC=1
 ..I $E(X,1)="*" D OLD
 .I $L(X)<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UOLD2
 K ^XTMP(PSUOPSUB,"XMD",PSUMC,PSUMLC-2)
 S ^XTMP(PSUOPSUB,"XMD",PSUMC+1,2)=PSUOLD1
 K ^XTMP(PSUOPSUB,"XMD",PSUMC,PSUMLC-1)
 S PSUMLC=3
 K PSUOLD2,PSUOLD1
 Q
 ;
OLD1 ;
 S ^XTMP(PSUOPSUB,"XMD",PSUMC+1,1)=PSUOLD1
 K ^XTMP(PSUOPSUB,"XMD",PSUMC,PSUMLC-1)
 S PSUMLC=2
 K PSUOLD1
 Q
 ;
 ;   Transmit Messages
VARS ; Setup variables for contents
 F PSUM=1:1:PSUMC D
 .S XMSUB="V. 4.0 PBMOP(MULTIDOSE) "_PSUMON_" "_PSUM_"/"_PSUMC_" "_PSUDIV_" "_PSUDIVNM
 .S XMTEXT="^XTMP(PSUOPSUB,""XMD"",PSUM,"
 .S XMCHAN=1
 .I PSUMASF!PSUDUZ!PSUPBMG D
 ..M XMY=PSUXMYH
 .I 'PSUMASF M XMY=PSUXMYS1
 .I '$G(PSUSMRY) D ^XMD
 ;
 S:NONE PSUTLC=0
 S PSUMSG("M")=PSUMC
 S PSUMSG("L")=PSUTLC
 Q
NODATA ;Send "No data to report" message
 S ^XTMP(PSUOPSUB,"RECMD",PSUSNDR,1)="No data to report"
 S NONE=1,PSUDIV=PSUSNDR
 ;S ^XTMP("PSU_"_PSUJOB,"PSUNONE","RX")=""
 S X=PSUDIV,DIC=4,DIC(0)="XM" D ^DIC ;**1
 S X=+Y,PSUDIVNM=$$VAL^PSUTL(4,X,.01)
 D XMD
SETCNT ;Set message count and line count
 S PSUMSGT(PSUDIV,"MD","M")=$G(PSUMSGT(PSUDIV,"MD","M"))+PSUMSG("M")
 S PSUMSGT(PSUDIV,"MD","L")=$G(PSUMSGT(PSUDIV,"MD","L"))+PSUMSG("L")
 S ^XTMP("PSU_"_PSUJOB,"CONFIRMD",PSUDIV,PSUOPTN,"M")=PSUMSGT(PSUDIV,"MD","M")
 S ^XTMP("PSU_"_PSUJOB,"CONFIRMD",PSUDIV,PSUOPTN,"L")=PSUMSGT(PSUDIV,"MD","L")
 Q