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

APSPCP2.m

Go to the documentation of this file.
APSPCP2 ;IHS/OHPRD/JCM - CHRONIC MED PROFILE;27-Dec-2004 07:31;PLS
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1002**;09/03/97
 ;THIS ROUTINE PRINTS A SUMMARY PROFILE OF ALL CURRENT CHRONIC
 ;MEDICATIONS TO PUT IN THE PATIENT'S CHART
 ;This routine is called by APSPNE4, APSPCP1 is called by option
 ; Modified - IHS/CIA/PLS - 03/14-04
 ;                          12/27/04 - Line BUILD+7
 Q
 ;
 ;INPUT VARIABLES- DFN
 ;
INIT ;EP
 ;NOTE: THIS EP IS CALLED BY CPCK^APSPNE4+1
 S PSOZCP("COPIES")=$G(PSOZCP("COPIES",1))
 S APSP("XSTAT")=""
 D FMTO
 G:$D(PSOZCP("FLG")) EXIT1
 S:'$D(APSP1(DFN)) APSP1(DFN)=""
 S %ZIS="QM"
 S %ZIS("A")="Please enter PROFILE device: " D ^%ZIS
 G:POP EXIT1
 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 INIT
 I IO=IO(0)!('$D(IO("Q"))) G EN
 S ZTRTN="EN^APSPCP2",ZTIO=ION ;IHS/DSD/ENM 06/14/99
 F G="PSOZCP(","APSPBD","APSPED","APSP(","APSP1(","PSOSITE" S ZTSAVE(G)="" ;IHS/DSD/LWJ 9/22/99 - changed APSP to be an open array reference, added PSOSITE and APSP1 open array
 S ZTDESC="CHRONIC MEDICATION PROFILE"
 D ^%ZTLOAD
EXIT ;
 D ^%ZISC
EXIT1 K SIG,DA,DFN,DOB,I,ISDZ,J,LRXD,PSZNAME,RFZ,RXNZ,TMP,DIC
 K PSOZCP,X,POP,IO("Q"),ZTSAVE,ZTRTN,ZTDESC,ZTIO,ZTSK,Y
 K ^TMP("PSOZCP",$J),DX,DY,APSPBD,APSPED,APSPASS,APSP("LAST FILL"),APSP("XSTAT"),APSPTDFN ;IHS/DSD/ENM 02/08/99
 Q
 ;
FMTO ;EP
 ; Get From/To date
 S X1=DT,X2=-PSOZZCP("DAYS") D C^%DTC S APSPBD=X-1_".2359",APSPED=DT_".2359"
CMEDX Q
EMPRT ;EP CALLED BY CPCK^APSPNE4+2
 ; NON-QUEUE PRINT MODULE
 S:'$D(^TMP("PSOZCP",$J)) ^TMP("PSOZCP",$J,DFN)=""
 D FMTO
 I $G(APSPCPP)']"" W ! K POP,ZTSK S %ZIS="M",%ZIS("A")="Enter Profile Device: " D ^%ZIS K %ZIS("A") G:POP EXIT S APSPCPP=ION
 S IOP=APSPCPP D ^%ZIS G:POP EXIT
EN ;
 I $G(PSOSITE)]"" S APSPZITE=$P(^PS(59,PSOSITE,0),"^")
 F PSOZCP("I")=1:1:$G(PSOZCP("COPIES"),1) D PATIENT
 D EXIT
 Q
 ;
PATIENT ;
 S (DX,DY)=1 X:$D(^%ZOSF("XY"))#2 ^("XY")
 U IO
 S DA=""
 D GETMP K APSPTDFN
 F I=0:0 S DA=$O(^TMP("PSOZCP",$J,DA)) Q:DA'=+DA  D START W:$E(IOST,1,2)="P-" @IOF
 I PSOZCP("I")=PSOZCP("COPIES"),$D(ZTSK) K ZTSK,IO("Q")
 Q
GETMP ;CREATE TMP DATA - NEW MODULE 07/30/99
 S APSPTDFN=0
 F  S APSPTDFN=$O(APSP1(APSPTDFN)) Q:'APSPTDFN  S ^TMP("PSOZCP",$J,APSPTDFN)=""
 Q
START ;
 K TMP("PSOZCP")
 S PSOZCP("PAGE")=0
 D HEADER
 ;
 ;PRESCRIPTION DFN NUMBER
 S J=""
 F I=0:0 S J=$O(^PS(55,DA,"P","CP",J)) Q:J'=+J  D BUILD
 ;
 ;START OF PRINTING
 I $D(TMP("PSOZCP"))>0 D PRINT
 Q
BUILD ;
 ;BUILDS PRESCRIPTION DATA
 ;IHS/DSD/LWJ 9/21/99 - eliminate the cross reference if the
 ;prescription no longer exists - added next line of code
 I (('$D(^PSRX(J,0)))&('$D(^PSRX(J,3)))) K ^PS(55,DA,"P","CP",J) G ENDBLD   ;IHS/DSD/LWJ 9/21/99
 I $D(^PSRX(J,0)),$D(^PSRX(J,3)) S APSP("LAST FILL")=$P(^PSRX(J,3),"^",1) ;IHS/DSD/ENM 02/08/99
 Q:APSP("LAST FILL")<APSPBD!(APSP("LAST FILL")>APSPED)  ;IHS/DSD/ENM 02/08/99
 ; Modified - IHS/CIA/PLS - 12/27/04 - Status field has moved
 ;I $D(^PSRX(J,0)) S APSP("XSTAT")=$P(^PSRX(J,0),"^",15) ;IHS/DSD/ENM 02/11/99
 I $D(^PSRX(J,0)) S APSP("XSTAT")=$G(^PSRX(J,"STA"))
 Q:APSP("XSTAT")=13  ;IHS/DSD/ENM 05/12/99 STATUS CHECK
 Q:APSP("XSTAT")=12  ;IHS/DSD/ENM 06/14/99 STATUS CHECK
 I $D(^PSRX(J,0)),$D(^PSDRUG(+$P(^(0),"^",6),0)) S TMP("PSOZCP",$P(^(0),"^",1))=J_"^"_^PSRX(J,0)
 ;
ENDBLD Q
PRINT ;
 S PSZNAME=0
 F I=0:0 S PSZNAME=$O(TMP("PSOZCP",PSZNAME)) Q:PSZNAME=""  D PRINT1 I $Y+4>IOSL,IOST["C-" S DIR("A")="ENTER '^' TO HALT",DIR(0)="FO" D ^DIR Q:$D(DTOUT)!($D(DUOUT))!($D(DIROUT))  W @IOF
 Q
PRINT1 ;
 I $E(IOST,1,2)="P-",$Y+6>IOSL W @IOF D HEADER
 S RXNZ=$P(TMP("PSOZCP",PSZNAME),"^",2) ;SETS PRESCRIPTION(RX) NUMBER
 W !?60,"|     |     |     |"
 W !,RXNZ
 W ?8,PSZNAME ;DRUG NAME AND STRENGTH
 W ?42,$P(TMP("PSOZCP",PSZNAME),"^",8) ;QUANTITY
 S LRXD=^PSRX($P(TMP("PSOZCP",PSZNAME),"^",1),3) ;SETS LAST ISSUE DATE
 W ?50,$E(LRXD,4,5),"-",$E(LRXD,6,7),"-",$E(LRXD,2,3),"  "
 F I=1:1:3 W "|_____"
 W "|"
 S SIG="" S X=$P(TMP("PSOZCP",PSZNAME),"^",11) D:X]"" ^APSPSIG
 W !,?10,SIG
 I $D(^PSRX($P(TMP("PSOZCP",PSZNAME),"^",1),1,0)) W !,"FILLED:  " D FILL ;CHECKS FOR REFILLS
 Q
FILL ;
 S ISDZ=$P(TMP("PSOZCP",PSZNAME),"^",14) ;SETS ORIGINAL ISSUE DATE
 W $E(ISDZ,4,5),"-",$E(ISDZ,6,7),"-",$E(ISDZ,2,3)
 F RFZ=0:0 S RFZ=$O(^PSRX($P(TMP("PSOZCP",PSZNAME),"^",1),1,RFZ)) Q:'RFZ  W " ",$E(^(RFZ,0),4,5),"-",$E(^(0),6,7),"-",$E(^(0),2,3)
 Q
 ;
 S PSOZCP("PAGE")=PSOZCP("PAGE")+1
 W !!!!,?27,"CHRONIC MEDICATION PROFILE"
 W ?60,"DATE : ",$E(DT,4,5),"-",$E(DT,6,7),"-",$E(DT,2,3)
 W !,?27,"SITE: ",APSPZITE ;IHS/DSD/ENM 09/06/96
 W !!,$P(^DPT(DA,0),"^",1) ;PATIENTS NAME
 W ?40,"CHART #  ",$P(^AUPNPAT(DA,41,DUZ(2),0),"^",2) ;CHART NO.
 W ?70,"Page ",PSOZCP("PAGE")
 S DOB=$S($L(+$P(^DPT(DA,0),"^",3)):+$P(^DPT(DA,0),"^",3),1:"") ;DATE OF BIRTH
 W !,?40,"DOB:  ",$S(DOB:$E(DOB,4,5)_"-"_$E(DOB,6,7)_"-"_$E(DOB,2,3),1:"UNKNOWN")
 ;GET ALLERGY DATA
 D GMR
 W !!,"RX#      DRUG",?42,"QTY",?50,"LAST FILLED",!!
 Q
 ;
COPIES ;EP
 K PSOZP("FLG"),DIRUT,DTOUT
 S DIR(0)="NO^1:10:0"
 S DIR("B")=1,DIR("A")="Number of Chronic Med Profile copies"
 D ^DIR
 I $D(DIRUT)!($D(DTOUT)) S PSOZCP("FLG")="" G COPIESX
 S PSOZCP("COPIES")=$S(+Y>0:+Y,1:1)
COPIESX ;
 Q
GMR X "N X S X=""GMRADPT"" X ^%ZOSF(""TEST"") Q" I $T D:'$D(PSOPTPST) GMRA
Q K SC,I1,VAROOT,Y,AL,I,X,Y,PSCNT,PSLC,PSDIS Q
GMRA W !,"REACTIONS: " D ^GMRADPT S I1=0 F I=0:0 S I=$O(GMRAL(I)) Q:I'>0  W:I1 ", " S AL=$P(GMRAL(I),"^",2) W:$X+$L(AL)>75 !?5 W AL S I1=1
 K GMRA,GMRAL Q