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

APSQSIGN.m

Go to the documentation of this file.
APSQSIGN ;IHS/OKCAO/POC - RTN PRINTS SIGNATURE LABEL;19-Jan-2011 08:35;SM
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1003,1004,1005,1006,1007,1009,1010**;Sep 23, 2004
 ;ROUTINE TO WRITE SIGNATURE INFORMATION ON RX LABEL
 ; Modified - IHS/CIA/PLS - 01/13/04
 ;                          03/21/05
 ;                          10/26/05 - Line ENL+2
 ;            IHS/MSC/PLS   03/01/06 - Line ZIS+11, added EN2+2
 ;                          08/08/06 - Added line EN2+3
 ;                          08/19/08 - Line EPAGN+4
 ;                          04/30/10  - Line ENLT+5
 ;                          01/19/11 - Line HDR+10
ENL(PPL,QUIT,SKIP,WHICH,PRT,SITE,NOQ) ; EP for use when site is printing on laser labels
 N PTYPE,ZTRTN,ZTIO,ZTDESC,ZTREQ,ZTSAVE
 N VAR,ZTSK  ; IHS/CIA/PLS - 10/26/05 - Added ZTSK variable
 S PRT=$P($G(PRT),U),PTYPE=$P($G(PRT),U,2)
 Q:'$L($G(PRT))  ; Requires a device
 S NOQ=$G(NOQ,0)  ; Set default for No-queue
 I NOQ,PRT=$G(PSOLAP) D
 .D ENLT
 E  D
 .S ZTRTN="ENLT^APSQSIGN"
 .S ZTDESC="Signature Label Print"
 .S ZTDTH=$H
 .S ZTIO=PRT
 .F VAR="SITE","PPL","QUIT","SKIP","WHICH" S:$D(@VAR) ZTSAVE(VAR)=""
 .D ^%ZTLOAD
 Q
ENLT ; Tasked entry point
 S ZTREQ="@"
 N LP,RX,RX0,DFN,RXN,TMP,PSOFROM
 N LASTPCE,THISPCE,I,J,K,L,LINE,NAME,NAMDAT,LINEBEG,LINEEND
 N LINEMAX,LINESP,LINELEN,RX,RXSTNG,X,NUM,D,SITEPAR,RXN,RXSTING
 N DATE,DOB
 F LP=1:1 S RX=$P(PPL,",",LP) Q:RX=""  D
 .; Build patient/script number array
 .S RX0=$G(^PSRX(RX,0))
 .S DFN=$P(RX0,U,2),RXN=$P(RX0,U)
 .I DFN,$L(RXN) S TMP(DFN,RXN)=""
 Q:'$D(TMP)
 ; Build array for printing
 S DFN=0 F  S DFN=$O(TMP(DFN)) Q:'DFN  D
 .N APSQSTG,LP,RXN
 .S RXN="" F LP=1:1 S RXN=$O(TMP(DFN,RXN)) Q:RXN=""  D
 ..S APSQSTG(LP)=DFN_U_RXN
 .D PARMSET(SITE)
 .D BEGIN
 Q
EN(APSQSTG,QUIT,SKIP,WHICH) ;EP
 ;QUIT IS TO DECIDE IF WANT TO EXECUTE THIS RTN AT ALL
 ;SKIP IS PARAMETER TO DECIDE IF PRINT EXTRA BLANK LABELS
 ;LINESKIP IS THE NUMBER OF LABELS TO SKIP
 ;APSQSTG IS THE STRING OF RX NUMBERS TO WRITE
 ;SITEPAR IS THE PARAMETER TO DECIDE IF WRITE
 ;LINEBEG IS THE NUMBER OF LINES TO SKIP AT BEGINNING OF LABEL
 ;LINEEND IS THE NUMBER OF LINES TO SKIP AT END OF LABEL
 ;LINEMAX IS THE NUMBER OF LINES IN THE LABEL
 ;LINESP IS THE NUMBER OF SPACES TO START AT ON EACH LINE
 ;LINELEN IS THE MAX LENGTH OF A LINE
 ;LINE IS THE NUMBER OF LINES USED
 ;SITEPAR IS PARAMETER TO DECIDE UNDER WHAT CONDITIONS THIS RTN PRINTS FOUND IN APSP CONTROL FILE
 N LASTPCE,THISPCE,I,J,K,L,LINE,NAME,NAMDAT,LINEBEG,LINEEND,LINEMAX,LINESP,LINELEN,RX,RXSTNG,X,NUM,D,SITEPAR,RXN,SKIP,RXSTING
 S:$G(QUIT)="" QUIT=1  ;DEFAULT TO EXIT OUT
 Q:$G(PSOFROM)="EDIT"  ;IT'S COMING FROM EDIT MODE DON'T PRINT IHS/OKCAO/POC 4/19/2001
 Q:QUIT  ;QUIT THE RTN
 D PARM Q:QUIT  D BEGIN   ;IHS/OKCAO/POC 1/9/2001 DON'T NEED TO OPEN DEVICE AS THIS RTN IS INSIDE APSPLBL
 Q
 ;
DEV1 S IOP=$G(PSOLAP) D ^%ZIS Q:POP  U IO
 Q
 ;
PARM ;EP
 D:'$D(PSOPAR) ^PSOLSET   ;IHS/DSD/ENM 11/06/96
 D PARMSET(PSOSITE)
 Q
 ;
PARMSET(SITE) ;EP
 S SITEPAR=$$GET1^DIQ(9009033,SITE,306)  ; Signature Label parameter
 S:$G(SITEPAR)="" SITEPAR="N"
 S LINEBEG=$$GET1^DIQ(9009033,SITE,5)  ;$P(%APSITE,"^",6)
 S LINEEND=$$GET1^DIQ(9009033,SITE,6)  ;$P(%APSITE,"^",7)
 S LINEMAX=$$GET1^DIQ(9009033,SITE,4)  ;$P(%APSITE,"^",5)
 S LINESP=$$GET1^DIQ(9009033,SITE,9)   ;$P(%APSITE,"^",10)
 S LINELEN=$$GET1^DIQ(9009033,SITE,3)  ;$P(%APSITE,"^",4)
 S LINESKIP=$$GET1^DIQ(9009033,SITE,8) ;$P(%APSITE,"^",9)
 S:LINESKIP="" LINESKIP=0
 S:$G(SKIP)="" SKIP=0   ;DEFAULT TO DO NOT PRINT EXTRA BLANK LABELS
 Q
 ;
BEGIN ;
 Q:SITEPAR["N"
 U IO
 I SITEPAR["A" D @WHICH,REST Q
 I SITEPAR["D"&$$MCD^AUPNPAT(DFN,DT) D @WHICH,REST Q
 I SITEPAR["R"&$$MCR^AUPNPAT(DFN,DT) D @WHICH,REST Q
 I SITEPAR["P"&$$PI^AUPNPAT(DFN,DT) D @WHICH,REST Q
 Q
 ;
ONE ;
 S RXSTNG=""
 S X="" F  S X=$O(APSQSTG(X)) Q:X=""  D
 .S APSQSTG=$TR(APSQSTG(X),","," ")
 .S RXSTING=""
 .F I=1:1 S RX=$P(APSQSTG," ",I) Q:RX=""  D
 ..S RXSTING=RXSTING_" "_$P($G(^PSRX(RX,0)),"^",1)
 .S RXSTNG=RXSTNG_RXSTING
 Q
 ;
TWO S RXSTNG=""
 S X="" F  S X=$O(APSQSTG(X)) Q:X=""  D
 .S RXSTNG=RXSTNG_" "_$P(APSQSTG(X),"^",2)
 Q
REST U IO
 S APSQSTG="RX NUMBER(S)"_RXSTNG
 D HDR
 S LASTPCE=""
 F I=1:1 S THISPCE=$P(APSQSTG," ",I) Q:THISPCE=""  D
 .I $L(LASTPCE_" "_THISPCE)>LINELEN D  ;
 ..W !,?LINESP,LASTPCE
 ..S LASTPCE=THISPCE
 ..S LINE=LINE+1
 ..I LINE+2>LINEMAX D SIG,FOOT,HDR
 ..I 1
 .E  S LASTPCE=LASTPCE_" "_THISPCE
 I $L(LASTPCE) W !,?LINESP,LASTPCE S LINE=LINE+1  ;WRITE THE LAST LINE
 D SIG
 D FOOT
 D SKIP
 Q
HDR ;HEADER INFO
 S LINE=0
 F D=1:1:LINEBEG W !   ;S LINE=LINE+1
 S NAME=$P(^DPT(DFN,0),"^",1)
 S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
 S NAMHRN="PT: "_NAME_" ("_$$HRN^AUPNPAT(DFN,DUZ(2))_")"
 I $L(NAMHRN)>LINELEN D
 .S NAME=$E(NAME,1,($L(NAME)-($L(NAMHRN)-LINELEN)))
 .S NAMHRN="PT: "_NAME_" ("_$$HRN^AUPNPAT(DFN,DUZ(2))_")"
 S DATE="DT: "_$$FMTE^XLFDT(DT,"2D")
 S DOB=$$FMTE^XLFDT($$DOB^AUPNPAT(DFN),"2DZ")
 W !,?LINESP,NAMHRN S LINE=LINE+1
 W !,?LINESP,DATE,"  DOB:",DOB S LINE=LINE+1
 Q
 ;
SIG ;
 W !,?LINESP,"SIGNATURE:" S LINE=LINE+1
 Q
 ;
 F L=LINE:1:(LINEMAX-1) W !
 F K=1:1:LINEEND W !
 Q
 ;
SKIP ;LINE FEED THE NUMBER OF LABELS INDICATED IN LINESKIP
 ;THIS PRINTS DEPENDING IF THIS RTN CALLED AT BEGINNING OR END OF PRINTING IN RTN APSPNE4
 Q:'$G(SKIP)  ;SO DON'T PRINT IF NO SKIP
 F I=1:1:LINESKIP D
 .S NUM=LINEBEG+LINEEND+LINEMAX
 .F I=1:1:NUM W !
 Q
 ;
 ;
EN1 ;EP
 ;COME HERE FROM OPTION TO PRINT/REPRINT SIGNATURE LABEL
 ;THIS SUBROUTINE DOES THE PRINTING OF THE SIGNATURE LABEL
 ;TO BE PLACED IN THE PATIENTS CHART IF THIS SITE
 N APSPZZN ;IHS/DSD/ENM 02/24/97
 N RX,RXSTRING,SKIP,PSOSD,APSPZDT,APSPBDT,PSORX,RXN,RXSTING,APSQSTG
 N LASTPCE,THISPCE,I,J,K,L,LINE,NAME,NAMDAT,LINEBEG,LINEEND
 N LINEMAX,LINESP,LINELEN,RX,RXSTNG,X,NUM,D,SITEPAR,PSOLIST
EPAGN ;
 D PARM
 S APSPQFLG=0,APSPEDT=0 K ARRAY,APSPFLG ;IHS/DSD/ENM 01/29/97
 D PAT^APSPNUM Q:APSPQFLG!($G(PSORX("QFLG")))  ;IHS/BAO/DMH dmh added 3/1/2002
 Q:'$D(PSODFN)  ;IHS/MSC/PLS - 08/19/08
 ;
 ;
 S APSPID=1 ;IHS/DSD/ENM 5/3/95 USED IN PSOLIST
 S PSOOPT=-1,PSONUM="LIST" D EN^APSPNUM
 I $G(Y(1))']"" D EMSG,EOJ Q
 G:Y["^" EPAGN
 D DEV
 Q
DEV ;
 S %ZIS="QM"
 ;IHS/CIA/PLS - 08/31/05 - Changed to prompt with either the Signature Label device or the Label device as the default
 S %ZIS("A")="Enter SIGNATURE Device: "  ;,IOP=$G(PSOLAP) D ^%ZIS
 S %ZIS("B")=$S($L($P($G(APSQSGLB),U)):$P(APSQSGLB,U),1:$G(PSOLAP)) D ^%ZIS
 I POP G EOJ
 I $D(IO("Q")),IO=IO(0) W !!,"Sorry, you cannot queue to your screen or to a slave printer.",! K IO("Q") D ^%ZISC G DEV
 ;
 I $D(IO("Q")) D  D EOJ Q
 .;S ZTRTN="EN2^APSQSIGN(.PSOLIST,0,1,""ONE"")",ZTIO=ION
 .S ZTRTN="EN2^APSQSIGN",ZTIO=ION
 .F G="DFN","PSOSITE","PSOPAR","PSONUM","PSOLIST(1)" S:$D(@G) ZTSAVE(G)=""
 .S ZTDESC="Outpatient Pharm SIGNATURE Label"
 .D ^%ZTLOAD
 ;
EN2 ;
 I '$G(PSOLIST(1)) D EOJ Q
 D PARMSET(PSOSITE)
 S SITEPAR="A"  ;default to ALL  ;IHS/MSC/PLS - 08/08/2006
 M APSQSTG=PSOLIST S QUIT=0,SKIP=1,WHICH="ONE"
 D BEGIN
 D ^%ZISC
 D EOJ
 Q
EMSG ;
 W !,"No Rx's found for this date....!" H 2
 Q
EOJ ;
 K APSPID
 Q
UTIL ;WHAT COMES IS FOR HELP AND INPUT TRANSFORM OF NEW FIELD IN APSP CONTROL FILE NOT DONE YET****
 ;PHARMACY 6.0;UTILITY TO SET VARIOUS FIELDS
 ;;
 ;FROM FIELD # OF FILE #
EXPL ;THIS IS THE EXPLANATION
 W !,"THE ENTRY IN THIS FIELD DETERMINES WHETHER A SIGNATURE LABEL IS PRINTED."
 W !,"A COMBINATION OF CODES CAN BE USED EXCEPT FOR 'A' OR 'N'."
 W !
 ;
 F I=1:1 S VAR=$P($T(LIST+I),";;",2) Q:VAR=""  W !,VAR
LIST K VAR Q
 ;;D=MEDICAID PRESCRIPTIONS
 ;;R=MEDICARE PRESCRIPTIONS
 ;;P=PRIVATE INSURANCE PRESCRIPTIONS
 ;;A=ALL PRESCRIPTIONS
 ;;N=NO PRESCRIPTIONS
 ;
 Q
EDIT ;THIS IS THE EDIT
 S X=$TR(X,"BCEFGHIJKLMOQSTUVWXYZ")
 I X'?1.3A K X W "GOT TO BE 1 TO 3 CHARACTERS" Q
 S:X["A" X="A"
 S:X["N" X="N"
 I X["DD"!(X["RR")!(X["PP") K X Q
 W "  "_X
 Q