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

APSPDRX.m

Go to the documentation of this file.
APSPDRX ; IHS/DSD/ENM/PLS - DAILY RX LOG;11-Jun-2013 18:05;PLS
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1008,1016**;Sep 23, 2004;Build 74
EP ;ENTRY POINT
INIT ;
 D:'$D(PSOPAR) ^PSOLSET I '$D(PSOPAR) W !,"No Site Param's Defined!..quitting." Q
 N APSPBD,APSPED,APSBDF,APSPEDF,APSPDIV
 ;S APSPDIV=$S($D(^PS(59,PSOSITE,0)):$P(^(0),U,6),1:"") ;SITE NBR
 W @IOF
 W "Pharmacy Daily Rx Report",!!
 D ASKDATES^APSPUTIL(.APSPBD,.APSPED,.APSPQ,DT,DT)
 Q:APSPQ
 S APSPBDF=$P($TR($$FMTE^XLFDT(APSPBD,"5Z"),"@"," "),":",1,2)
 S APSPEDF=$P($TR($$FMTE^XLFDT(APSPED,"5Z"),"@"," "),":",1,2)
 S APSPBD=APSPBD-.01,APSPED=APSPED+.99
 ;SELECT DIVISION
 S APSPDIV=$$DIR^APSPUTIL("Y","Would you like all pharmacy divisions","Yes",,.APSPQ)
 Q:APSPQ
 I APSPDIV D
 .S APSPDIV="*"
 E  D  Q:APSPQ
 .S APSPDIV=$$GETIEN^APSPUTIL(59,"Select Pharmacy Division: ",.APSPQ)
 Q:APSPQ
 D DEV
 Q
DEV ;
 N XBRP,XBNS
 S XBRP="OUT^APSPDRX"
 S XBNS="APS*"
 D ^XBDBQUE
 Q
OUT N APSPG,APSPDT,APSPRN,APSPLN,FTYPE,APSPOUT,APSPRX
 N APSPDFN,APSPDG,APSPNM,APSPPRV,DIV,APSPSTN,QTY
 U IO
 K ^TMP($J,"APSPX")
 S APSPG=0,APSPOUT=""
 S APSPDT=APSPBD F  S APSPDT=$O(^PSRX("ZAL",APSPDT)) Q:'APSPDT!(APSPDT>APSPED)  D PRT
 D PRNT W !!,"End of Report"
 Q
PRT ;
 S RXIEN=0 F  S RXIEN=$O(^PSRX("ZAL",APSPDT,RXIEN)) Q:'RXIEN  D PR1
 Q
PR1 S APSPLN=0 F  S APSPLN=$O(^PSRX("ZAL",APSPDT,RXIEN,APSPLN)) Q:'APSPLN  D PR2
 Q
PR2 S FTYPE="" F  S FTYPE=$O(^PSRX("ZAL",APSPDT,RXIEN,APSPLN,FTYPE)) Q:FTYPE=""  D DSET
 Q
DSET ;
 N NXT
 S NXT=$O(^TMP($J,"DATA",$C(1)),-1)
 S NXT=NXT+1
 S APSPRX=$P($G(^PSRX(RXIEN,0)),U)
 S APSPDFN=$P($G(^(0)),U,2)
 S APSPDG=$P($G(^(0)),U,6)
 S APSPDRG=$P($G(^PSDRUG(APSPDG,0)),U)
 S APSPPRV=$$GET1^DIQ($S(FTYPE="P":52.2,FTYPE="R":52.1,1:52),$S("PR"[FTYPE:APSPLN_","_RXIEN_",",1:RXIEN),$S(FTYPE="P":6,FTYPE="R":15,1:4),"I")
 S DIV=$$GET1^DIQ($S(FTYPE="P":52.2,FTYPE="R":52.1,1:52),$S("PR"[FTYPE:APSPLN_","_RXIEN_",",1:RXIEN),$S(FTYPE="P":.09,FTYPE="R":8,1:20),"I")  ; Pharmacy Division IEN
 S QTY=$$GET1^DIQ($S(FTYPE="P":52.2,FTYPE="R":52.1,1:52),$S("PR"[FTYPE:APSPLN_","_RXIEN_",",1:RXIEN),$S(FTYPE="P":.04,FTYPE="R":1,1:7))
 Q:'$$DIVVRY(DIV,APSPDIV)
 ;S APSPCN=$$HRN^AUPNPAT(APSPDFN,$$GET1^DIQ(59,DIV,.06,"I"))
 S APSPCN=$$HRN^AUPNPAT(APSPDFN,$$GET1^DIQ(59,DIV,100,"I"))  ;IHS/MSC/PLS - 06/11/13
 S ^TMP($J,"APSPX",DIV,APSPDT,APSPRX,NXT)=""
 S ^TMP($J,"DATA",NXT)=APSPRX_U_APSPDFN_U_APSPDRG_U_APSPPRV_U_QTY_U_APSPCN_U_FTYPE
 Q
 ; Return boolean flag indicating valid pharmacy division
DIVVRY(RXDIV,RPTDIV) ;EP
 Q:RPTDIV="*" 1
 Q RXDIV=RPTDIV
PRNT S (APSPDP,APSPZX)="" D HDR,DSPL
 Q
DSPL ;GET DATA FROM TMP GBL
 N DIV,DIVNM,APSP,APSPDT,APSPRX,APSPNM,NXT
 S DIV="" F  S DIV=$O(^TMP($J,"APSPX",DIV)) Q:'DIV  D  ;GET DIVISION
 .S DIVNM=$$GET1^DIQ(59,DIV,.01)
 .S APSPDT=0 F  S APSPDT=$O(^TMP($J,"APSPX",DIV,APSPDT)) Q:'APSPDT!($G(APSPOUT))  D
 ..S APSPRX="" F  S APSPRX=$O(^TMP($J,"APSPX",DIV,APSPDT,APSPRX)) Q:'$L(APSPRX)!($G(APSPOUT))  D
 ...S NXT=0 F  S NXT=$O(^TMP($J,"APSPX",DIV,APSPDT,APSPRX,NXT)) Q:'NXT  D DSPS Q:$G(APSPOUT)
 Q
DSPS S APSP=^TMP($J,"DATA",NXT)
 S APSPNM=$$GET1^DIQ(2,+$P(APSP,U,2),.01)
 S APSPP=$P(APSP,U,4)
 S APSPQ=$P(APSP,U,5)
 S APSPCN=$P(APSP,U,6)
 S FTYPE=$P(APSP,U,7)
 D:$Y+4>IOSL HDR Q:$G(APSPOUT)
 S APSPTYP=$S(FTYPE="N":"NEW RX",FTYPE="R":"REFILL",FTYPE="P":"PARTIAL",1:"")
 W !,"Rx #: "_APSPRX,?17,"Name: "_APSPNM,?54,"Chart #: "_$P(APSP,U,6)
 W !,"DRUG: "_$P(APSP,U,3),?37,"Qty: "_$P(APSP,U,5),?47,"Provider: "_$$GET1^DIQ(200,$P(APSP,U,4),.01)
 W !,"Division: "_DIVNM,?37,APSPTYP,?53,"D/Time: "_$TR($$FMTE^XLFDT($E(APSPDT,1,12),"5Z"),"@"," ")
 W !
 Q
HDR I APSPG,$E(IOST)="C" K DIR S DIR(0)="FO",DIR("A")="Press Return to Continue or ""^"" to Exit" D ^DIR I X["^" S APSPOUT=1 Q
 S APSPG=APSPG+1
 W @IOF,?38,"(",APSPG,")",!,"DAILY PRESCRIPTION ACTIVITY REPORT"
 W ?51,"Print Date: ",?59,$TR($$FMTE^XLFDT($E($$NOW^XLFDT(),1,12),"5Z"),"@"," "),!
 W ?5,"Pharmacy Division: "_$S(APSPDIV:$$GET1^DIQ(59,APSPDIV,.01),1:"All"),!
 F I=1:1:80 W "."
 W !,?10,"For Rx's dispensed from "_APSPBDF_" to "_APSPEDF,!!
 Q