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