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

APSQPMI.m

Go to the documentation of this file.
APSQPMI ;IHS/ASDS/ENM/POC - PRINTS THE PATIENT MEDICATION SHEETS ;09-Oct-2008 11:27;SM
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1007**;Sep 23, 2004
 ; Modified - IHS/CIA/PLS - 01/21/04
 ;            IHS/MSC/PLS - 08/19/08 - Line EN1+8
EN ;EP - NORMAL ENTRY POINT
 S PSNDFN=DFN
 I ('$D(APSPCPP))!($G(APSPCPP)=ION) G PMI
TSK F I="PPL","APSPCPP","PSNDFN" S ZTSAVE(I)=""
 S ZTRTN="PMI^APSQPMI"
 S ZTDESC="PRINTS PATIENT MED SHEETS"
 S ZTDTH=$H
 S ZTIO=APSPCPP
 S ZTREQ="@"
 D ^%ZTLOAD
 Q
 ;
EN1 ;ENTRY FROM PATIENT NAME
 N PPL,PSOSD,DFN,APSQRXN,APSQIEN,APSQDRG,APSQ
 N PSRX,PSNDFN,NAM,APSDNAM,APSDOC,APSPNDC,CR,DFN,ED,ED1,ED2,ED3,NDC,NUM
 N P2,PG,PPI,PPL,PS,PSODFN,SSN,SEX,VA,VADM,XNDC
 N Z,PSCNT,PSOCT,PSODTCUT,PSOERR,PSOLIST,PSOOPT,PSOSTA,RXN,STP,STR
 N J,JJ,IEN,DIWI,DIW,DIWT,DN,APSPIRN,APSPZDT
 N POP,VAERR,CNT,DIR,DIWTC,DOB,DRG,IOHG,DIWX,IOBS
 D PAT^APSPNUM   ;IHS/CIA/PLS - 01/21/04
 Q:'$D(PSODFN)  ; IHS/MSC/PLS - 08/19/08
 S PSONUM="LIST"
 D EN^APSPNUM
 G:'$D(PSOLIST) END
 S PPL=PSOLIST(1) ;BETTER WATCH THIS AS IT CAN BE TOO LONG
 G EN
 ;
PMI ;SET UP AND PRINT
 I $E(IOST)="P" S APSQCOM=$P($G(^%ZIS(2,IOST(0),12.1)),"^"),APSQRSET=$P($G(^(6)),"^") W:APSQCOM]"" @APSQCOM ;COMPRESS IF A PRINTER TO 16 PITCH
 Q:'$D(PPL)  ;NO RXS TO PRINT SO NO MED SHEETS TO PRINT EITHER
 F I=1:1 S APSQIEN=$P(PPL,",",I) Q:'APSQIEN  D
 .S APSQDRG=$P(^PSRX(APSQIEN,0),"^",6)
 .Q:$$TEST(APSQDRG)
 .S APSQRXN=+^PSRX(APSQIEN,0)
 .S PPI=^PSDRUG(APSQDRG,"ND")
 .S PPI=$P(^PSNDF(+PPI,5,$P(PPI,"^",3),0),"^",7)
 .S APSQ(I)=PPI_"^"_APSQDRG_"^"_APSQRXN ;SO ONLY GET ONE OF SHEET EVEN IF TWO DRUGS POINT TO SAME PATIENT INFORMATION SHEET
 .Q
 S TYPE=$S($G(APSQTYPE):APSQTYPE,1:2) ;IHS/OKCAO/POC APSQTYPE IS IN APSPCONTROL FILE FIELD 301
 S NUM=1
PRINT S JJ=0 F  S JJ=$O(APSQ(JJ)) Q:'JJ  S PPI=+APSQ(JJ),DRG=$P(APSQ(JJ),"^",2),PSRX=$P(APSQ(JJ),"^",3) D DOONE^PSNPPIP
END Q
TEST(N) ;TEST FOR ENTRY OF PATIENT MED SHEET IN ^PSPPI GLOBAL
 N TEST S TEST=$G(^PSDRUG(N,"ND"))
 S TEST=$P($G(^PSNDF(+TEST,5,+$P(TEST,"^",3),0)),"^",7)
 I TEST,$D(^PSPPI(+TEST)),$S('$G(^PSDRUG(+N,"I")):1,DT'>^("I"):1,1:0) Q 0
 E  Q 1 ;1=NO GO