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

APSPSLBL.m

Go to the documentation of this file.
APSPSLBL ;IHS/DSD/JCM/ENM - IHS SUMMARY LABEL;17-Jan-2006 09:36;SM
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1003,1004**;09/03/97
 ;
 ;THIS ROUTINE DOES THE PRINTING OF THE REFILL OR PARTIAL
 ;SUMMARY LABEL TO BE PLACED IN THE PATIENTS CHART IF THIS SITE
 ;PARAMETER HAS BEEN CHOSEN.  PLEASE BE SURE THAT THE ESCAPE SEQUENCES
 ;FOR YOUR PRINTER HAVE BEEN ENTERED IN YOUR TERMINAL TYPE FILE FOR
 ;CONDENSED PRINT AND A SOFT RESET OR 10,12 PITCH.
 ;
 ; Modified - IHS/CIA/PLS - 01/21/04, 03/08/04, 07/27/04, 08/08/2005
EP ;IHS/DSD/ENM 11/09/94 ENTRY POINT FOR SUM OPT
 N APSPZZN,ARRAY,APSPFLG,PSODFN,PSZW,PSZL,PSZB,PSZE,PSZK,PSZTAB
 N APSPQFLG,APSPEDT,PSODFN,AUPDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX
 N PSOLIST,PSOSD,PSOOPT,APSPID,PSONUM,PSOSD,PSZB,PSZDRUG,PSZE
 ;N APSPID,APSHRN,Y
 N APSPID,APSHRN,Y,APSPZDT  ;IHS/CIA/PLS - 08/08/2005
 D:'$D(PSOPAR) ^PSOLSET
 S APSPQFLG=0,APSPEDT=0
 D PARM
 D PAT^APSPNUM
 Q:'$D(PSODFN)
EPP ;
 D PROFILE^PSORX1
 S APSPID=1 ;USED IN PSOLIST
 S PSOOPT=-1,PSONUM="LIST" D EN^APSPNUM
 I $G(Y(1))']"" D EMSG,EOJ Q
 G:Y["^" EP
DEV ;
 S %ZIS="QM"
 S %ZIS("A")="Enter SUMMARY Device: ",IOP=$G(PSOLAP) D ^%ZIS
 G:POP EOJ
 I $D(IO("Q")),IO=IO(0) D  G DEV
 .W !!,"Sorry, you cannot queue to your screen or to a slave printer.",!
 .K IO("Q") D ^%ZISC
 I $D(IO("Q")) D
 .S ZTRTN="EP1^APSPSLBL",ZTIO=ION
 .F G="PSOSITE","PSOPAR","%APSITE","PRF","PSZW","PSZK","PSZE","PSZL","PSZTAB","PSZB","PSONUM","PSOLIST(1)" S:$D(@G) ZTSAVE(G)=""
 .S ZTDESC="Outpatient Pharm Summary Label"
 .D ^%ZTLOAD
 E  D
 .D EP1
EXIT Q
EP1 ;INITIALIZE
 Q:'$G(PSOLIST(1))
 N APSP,APSPN,APSPD,APSPS,APSPQ,APSPF,APSPZ,N
 F APSPZ=1:1 S APSPRX=$P(PSOLIST(1),",",APSPZ) Q:APSPRX=""  S N=APSPZ D ESET
 D EP2,EOJ
 Q
ESET ;
 S APSP=^PSRX(APSPRX,0),APSPN=$P(APSP,U,2),APSPD=$P(APSP,U,6),APSPS=$P(^PSRX(APSPRX,"SIG"),"^",1),APSPQ=$P(APSP,U,7),APSPF=$P(^PSRX(APSPRX,2),U,2)
 ;
 ;  dmh added this next SIG change because orders put in sometimes
 ;   set the sig in SIG1 wp field.....6/20/2002
 I APSPS="" S APSPS=$G(^PSRX(APSPRX,"SIG1",1,0))  ;dmh 6/20/2002
 ;
 S APSXPS=$S($D(^PS(59,PSOSITE,0)):^(0),1:""),APSNBR=$P(APSXPS,"^",6) ;IHS/DSD/ENM 02/05/97 GET SITE NUMBER FROM SITE FILE
 S PNM=$P(^DPT(APSPN,0),U),PSZDRUG=$P(^PSDRUG(APSPD,0),U),APSHRN=$S($G(^AUPNPAT(APSPN,41,APSNBR,0)):$P(^(0),U,2),1:"") ;IHS/DSD/ENM 02/05/97
 S ARRAY(N)=$E(PNM,1,PSZW-8)_"^"_APSPRX_"^"_PSZDRUG_"^"_APSPS_"^"_APSPQ_"^"_APSPF_"^"_APSHRN
 Q
 ;
EP2 ;EP
 N AAPSITE,PSZCW,PSZCTAB,PZX,PSZW,PSZL,PSZB,PSZE,PSZK,PSZTAB
 N FDT,NUM,PSOZSLBL,PSZCTAB,QTY,SIG,PSZZL,E,L,LENGTH
 N APSP,APSPD,PSZE
 D PARM
 I $G(APSPZZN)]"" S N=APSPZZN
 S PZX=N,NUM=1,C=0,FDT=$P(ARRAY(N),"^",6)
 S AAPSITE=^APSPCTRL(PSOSITE,0)
 S PSOZSLBL("COPIES")=$S($P(AAPSITE,"^",36)]"":$P(AAPSITE,"^",36),1:1)
 ;
 S PSZZL=PSZL-1 ; THIS SETS THE NUMBER OF LINES TO PRINT
 ;AFTER THE PATIENTS NAME AND DATE IS PRINTED
 S PSZCW=$P(^APSPCTRL(PSOSITE,0),"^",14) ;IHS/DSD/ENM 08/01/96
 S PSZCTAB=$P(^APSPCTRL(PSOSITE,0),"^",13) ;IHS/DSD/ENM 08/01/96
 S:PSZCW<PSZW PSZCW=PSZW*1.6\1
 ;THE ABOVE LINES SETS MY COMPRESSED LABEL WIDTH AND
 ;MY COMPRESSED LEFT MARGIN IF NOT ALREADY SET IN
 ;THE IHS SITE PARAMETERS
 ;
 S IOP=$G(PSOLAP) D ^%ZIS U IO
 ;
 I $E(IOST,1,2)="P-",$D(^%ZIS(2,IOST(0),12.1))#2,^(12.1)]"",$D(^%ZIS(2,IOST(0),6))#2,$P(^(6),U,1)]"" W @($P(^%ZIS(2,IOST(0),12.1),U,1))
 ;THE ABOVE LINE CHECKS TO SEE IF WE ARE USING A TERMINAL OR
 ;PRINTER AND IF ESCAPE CODES ARE SET UP IN TERMINAL TYPE FILE
 ;IHS/DSD/ENM/POC 05/11/98 NEXT THREE LINES
 ;
 F PSOZSLBL("I")=1:1:PSOZSLBL("COPIES") D
 .S PZX=N,NUM=1 D BEGIN S C=0 ;IHS/DSD/ENM/POC 05/11/98 ADDED PZX AND NUM
 D FEED
 I $G(PSOFROM)]"" D EOJ ;IHS/DSD/ENM 07/31/96
 Q
BEGIN ;
 F I=1:1:PSZB W ! ;THIS SETS MY LINE FEEDS AT BEGINNING OF LABEL
 ;
 ;PATIENTS NAME & DATE OF ISSUE
 W !,?(PSZCTAB),$P(ARRAY(N),"^",1)_" : "_APSHRN_" "
 I $G(APSPID)]"" W ?(PSZCTAB+PSZCW-9),+$E(APSPEDT,4,5),"-",$E(APSPEDT,6,7),"-",$E(APSPEDT,2,3) G ZZL ; Display Last Fill Date
 W ?(PSZCTAB+PSZCW-9),+$E(FDT,4,5),"-",$E(FDT,6,7),"-",$E(FDT,2,3)
 ;
ZZL ;LABEL INFORMATION
 F N=NUM:1:PZX D LABEL S C=C+1 Q:C=PSZZL
 ;
 F I=1:1:PSZE+(PSZZL-C) W ! ; Set at Top of Form
 I $D(ARRAY(N+1)) S C=0,NUM=N+1 G BEGIN
 Q
 ;
FEED I $D(PSZK),PSZK S L=PSZL+PSZE+PSZB*PSZK F I=1:1:L W !
 ;THE ABOVE LINE ACTS AS A FORM FEED WHERE PSZK
 ;EQUALS THE NUMBER OF FORM FEEDS
 Q
 ;
EOJ ;
 I $E(IOST,1,2)="P-",$D(^%ZIS(2,IOST(0),6))#2,$P(^(6),U,1)]"" W @($P(^%ZIS(2,IOST(0),6),U,1))
 D ^%ZISC
 U IO
 Q
LABEL ;
 S LENGTH=$L($P(ARRAY(N),"^",3,5))+1
 ;
 S DRUG=$E($P(ARRAY(N),"^",3),1,PSZCW-5)  ;Truncates Drug Name if needed.
 ;
 S E=PSZCW-$L(DRUG)-2 ;POSITION WHERE SIG SHOULD PRINT
 ;
 S QTY=$P(ARRAY(N),"^",5) ;THE QUANTITY ISSUED
 ;
 S SIG=$E($P(ARRAY(N),"^",4),1,PSZCW-$L(QTY)-2+E)
 ;THE ABOVE LINE SETS THE VALUE AND MAX LENGTH OF SIG
 ;
 I LENGTH'>PSZCW W !,?(PSZCTAB),DRUG,"  ",SIG,?(PSZCTAB+PSZCW-$L(QTY)),QTY Q
 ;THE ABOVE LINE PRINTS DRUG,SIG,QTY ON ONE LINE IF IT WILL FIT
 ;
 I C=(PSZZL-1) S N=N-1 W ! Q  ;MAKES SURE THERE ARE TWO
 ;LINES AVAILABLE TO PRINT ON AND RESETS N TO CORRECT VALUE
 ; AND DOES A LINE FEED IF NOT
 ;
 W !,?(PSZCTAB),DRUG,"  ",$E(SIG,1,E) ;FIRST LINE
 ;
 I $E(SIG,E+1)'=" " I $E(SIG,E+1)'="" W "-"
 ;
 W !,?(PSZCTAB),$E(SIG,E+1,99)
 W ?(PSZCTAB+PSZCW-$L(QTY)),QTY
 ;THE ABOVE TWO LINES PRINT THE SECOND LINE
 ;
 S C=C+1
 ;
 Q
EMSG ;IHS/DSD/ENM 01/29/97
 W !,"No Rx's found for this date....!" H 2
 Q
PARM ;EP
 ;IHS/DSD/ENM 02/04/97 MODULE FROM APSPLBL FOR SUMMARY LBLS
 ;SET LBL WTH/LN/MAR & GET DATA FROM FILE #9009033
 S X=$S($D(^APSPCTRL(PSOSITE,0)):^(0),1:""),PSZW=$P(X,U,14),PSZL=$P(X,U,5),PSZB=$P(X,U,6),PSZE=$P(X,U,7),PSZK=$P(X,U,9),PSZTAB=$P(X,U,13) ;IHS/DSD/ENM 08/01/96
 Q