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

PSD68P.m

Go to the documentation of this file.
PSD68P ;B'ham ISC/RJS - PSD*3*68 POST INSTALL ; 30 Oct 09
 ;;3.0; CONTROLLED SUBSTANCES ;**68**;30 Oct 09;Build 12
 ;Identify bad PSD(58.81,"D" INDEXES & TRANSACTIONS THEN CLEAN THEM UP
 S ZTDESC="CONTROLLED SUBSTANCES - PSD*3*68 POST INSTALL",ZTIO="",ZTDTH=$H,ZTRTN="START^PSD68P",ZTSAVE="" D ^%ZTLOAD
 D BMES^XPDUTL("PSD*3*68 POST INSTALL Task Queued!")
 Q
START ; FIND NAOU'S
 S PSDLOC=0 F  S PSDLOC=$O(^PSD(58.8,PSDLOC)) Q:'PSDLOC  D
 .I $P(^PSD(58.8,PSDLOC,0),U,2)="N" S PSDLOC(PSDLOC)=1
 ;
 ; LOOP THROUGH ^PSD(58.81 & GATHER ALL NAOU TRANSACTIONS WITH RX#
 ; 
 S PSDTRN=0 F  S PSDTRN=$O(^PSD(58.81,PSDTRN)) Q:'PSDTRN  D
 .S PSDNAOU=$P(^PSD(58.81,PSDTRN,0),U,18)
 .Q:$G(PSDNAOU)=""
 .Q:'$G(PSDLOC(PSDNAOU))
 .S PSDPN=$P(^PSD(58.81,PSDTRN,0),U,17),PSDRG=$P(^PSD(58.81,PSDTRN,0),U,5)
 .I $G(PSDPN) D
 ..S ^TMP($J,"PSD68P",PSDNAOU,PSDPN,PSDRG,PSDTRN)=^PSD(58.81,PSDTRN,0)
 ..S ^TMP($J,"PSD68P",PSDNAOU,PSDPN)=$G(^TMP($J,"PSD68P",PSDNAOU,PSDPN))+1
 ;
 ; LOOP THROUGH ^TMP($J,"PSD68P AND FIND BAD DRUG DISPENSING # & INDEX
 ; 
 S XMSUB="PSD*3*68 POST INSTALL Report",PSDRPT="PSD68P-D"
 S ^TMP($J,PSDRPT,1)="PSD*3*68 DRUG ACCOUNTABILITY TRANSACTION Drug Dispensing # Index Repair"
 S ^TMP($J,PSDRPT,2)=""
 S ^TMP($J,PSDRPT,3)="The following Drug Dispensing # Index for the DRUG ACCOUNTABILITY TRANSACTION"
 S ^TMP($J,PSDRPT,4)="file have been fixed."
 S ^TMP($J,PSDRPT,5)=""
 S PSDTXT="" D TXT("Transaction#",1),TXT("Drug Name",15),TXT("Dispensing#",60)
 S ^TMP($J,PSDRPT,6)=PSDTXT,^TMP($J,PSDRPT,7)="",PSDCNT=7
 S PSDNAOU="" F  S PSDNAOU=$O(^TMP($J,"PSD68P",PSDNAOU)) Q:'PSDNAOU  D
 .S PSDPN="" F  S PSDPN=$O(^TMP($J,"PSD68P",PSDNAOU,PSDPN)) Q:'PSDPN  D
 ..I $G(^TMP($J,"PSD68P",PSDNAOU,PSDPN))=1 K ^TMP($J,"PSD68P",PSDNAOU,PSDPN) Q
 ..S PSDRG="" F  S PSDRG=$O(^TMP($J,"PSD68P",PSDNAOU,PSDPN,PSDRG)) Q:'PSDRG  D CLEAN
 ..K ^TMP($J,"PSD68P",PSDNAOU,PSDPN)
 I '$G(PSDFND) S ^TMP($J,PSDRPT,3)="There were NO incorrect Drug Dispensing # Indexes found.",^TMP($J,PSDRPT,4)="",PSDCNT=5
 D MAIL
 Q
TXT(PSDVAL,PSDCOL) ; FORAMT THE MAILMAN TEXT
 S:'$D(PSDTXT) PSDTXT="" S PSDTXT=$$SETSTR^VALM1(PSDVAL,PSDTXT,PSDCOL,$L(PSDVAL))
 Q
CLEAN ; REMOVE THE BAD DRUG DISPENSING # & INDEX
 S PSDTRN=0 F  S PSDTRN=$O(^TMP($J,"PSD68P",PSDNAOU,PSDPN,PSDRG,PSDTRN)) Q:'PSDTRN  D
 .Q:$P(^TMP($J,"PSD68P",PSDNAOU,PSDPN,PSDRG,PSDTRN),"^",2)'=17
 .S PSDDT=$P(^TMP($J,"PSD68P",PSDNAOU,PSDPN,PSDRG,PSDTRN),"^",4),PSDDAYS=$$FMDIFF^DILIBF(DT,PSDDT,"")
 .S $P(^PSD(58.81,PSDTRN,0),U,17)="",$P(^PSD(58.81,PSDTRN,0),U,20)="",PSDFND=1
 .D MQUE
 .K ^PSD(58.81,"D",PSDPN,PSDTRN)
 .K DA,DIK S DA=PSDTRN,DIK="^PSD(58.81," D IX^DIK K DA,DIK
 Q
MQUE ; STEP UP THE ^TMP( DATA FOR THE MAILMAN MESSAGE
 S PSDTXT="" D TXT(PSDTRN,2),TXT($P(^PSDRUG(PSDRG,0),"^"),15),TXT(PSDPN,62)
 S PSDCNT=PSDCNT+1,^TMP($J,PSDRPT,PSDCNT)=PSDTXT
 S PSDCNT=PSDCNT+1,^TMP($J,PSDRPT,PSDCNT)=""
 Q
MAIL ; SEND THE MAILMAN MESSAGE
 N DIFROM
 S PSDCNT=PSDCNT+1,^TMP($J,PSDRPT,PSDCNT)="***** End Of Report *****"
 S XMTEXT="^TMP($J,PSDRPT,",XMDUZ="PSD*3*68 Post Install"
 S PSDDUZ=0 F  S PSDDUZ=$O(^XUSEC("PSDMGR",PSDDUZ)) Q:'PSDDUZ  S XMY(PSDDUZ)=""
 D ^XMD
EXIT ; CLEAN UP
 K ^TMP($J),XMDUZ,XMSUB,XMTEXT,XMY,PSDCNT,PSDDAYS,PSDDT,PSDDUZ,PSDFND,PSDRPT,PSDRG,PSDPN,PSDTRN,PSDNAOU,PSDLOC,PSDVAL,PSDCOL,PSDTXT
 Q