source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOSUPAT.m@ 1489

Last change on this file since 1489 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.1 KB
Line 
1PSOSUPAT ;BIR/RTR-Pull all Rx's from suspense for a patient ;03/01/96
2 ;;7.0;OUTPATIENT PHARMACY;**8,130,185**;DEC 1997
3 ;External reference to ^PS(55 supported by DBIA 2228
4 ;External reference to ^PSSLOCK supported by DBIA 2789
5PAT N PSOALRX,PSOALRXS S POP=0 K RXP,RXRR,RXFL,RXRP,RXPR,ASKED,BC,DELCNT,WARN,PSOAL,PSOPROFL,PSOQFLAG,PSOPULL,PSOWIN,PSOWINEN,PPLHOLD,PPLHOLDX W ! S DIR("A")="Are you entering the patient name or barcode",DIR(0)="SBO^P:Patient Name;B:Barcode"
6 S DIR("?")="Enter P if you are going to enter the patient name. Enter B if you are going to enter or wand the barcode."
7 D ^DIR K DIR G:$D(DIRUT) ^PSOSUPRX S BC=Y D NOW^%DTC S TM=$E(%,1,12),TM1=$P(TM,".",2)
8BC S (OUT,POP)=0 I BC="B" W ! S DIR("A")="Enter/wand barcode",DIR(0)="FO^5:20",DIR("?")="Enter or wand a prescription barcode for the patient you wish to pull all Rx's for" D ^DIR K DIR G:$G(DIRUT) PAT S BCNUM=Y D
9 .D PSOINST Q:OUT S RX=$P(BCNUM,"-",2) K RTE S MW="" D:$D(^PSRX(RX,0))
10 ..S (DFN,PSODFN)=$P(^PSRX(RX,0),"^",2) W " ",$P($G(^DPT(DFN,0)),"^")
11 ..D ICN^PSODPT(DFN)
12 .I '$D(^PSRX(RX,0)) W !,$C(7),"NO PRESCRIPTION RECORD FOR THIS BARCODE." S OUT=1
13 G:OUT BC
14NAM I BC="P" W ! S DIC(0)="AEMZQ",DIC="^DPT(",DIC("S")="I $D(^PS(52.5,""AC"",+Y))!($D(^PS(52.5,""AG"",+Y)))" D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT))!(Y<0) PAT S (DFN,PSODFN)=+Y K RTE S MW=""
15 S PSOLOUD=1 D:$P($G(^PS(55,PSODFN,0)),"^",6)'=2 EN^PSOHLUP(PSODFN) K PSOLOUD
16 S (ASKED,DELCNT,WARN)=0 F CBD=0:0 S CBD=$O(^PS(55,DFN,"P",CBD)) Q:CBD'>0 D TEST
17 I $G(PSOQFLAG) D RESET G EXIT
18 ;S HOLDPROF=$G(PSOPROFL) K PSOPROFL
19 ;I $D(PSOPART) S (PSOPULL,PSODBQ)=1 F RR=0:0 S RR=$O(PSOPART(RR)) Q:'RR S PDUZ=DUZ,PPL=RR,RXP=PSOPART(RR) D Q^PSORXL
20 ;S PSOPROFL=HOLDPROF I $D(ZTSK),'$G(PPLHOLD) W !!,"LABEL(S) ARE QUEUED TO PRINT",!
21 F GGGG=0:0 S GGGG=$O(RXPR(GGGG)) Q:'GGGG K:'$G(RXPR(GGGG)) RXPR(GGGG)
22 K RXP,PPL S PDUZ=DUZ,PSONOPRT=1
23 I $G(PPLHOLD)'="" S PPL=PPLHOLD S:$G(SUSROUTE) BBRX(1)=PPL S HOLDPPL=PPL,PSOPULL=1,PSODBQ=1,RXLTOP=1 D WIND^PSOSUPRX D Q^PSORXL I '$G(PSOQFLAG) W !!,"LABEL(S) ARE QUEUED TO PRINT",! S PPL=$P(HOLDPPL,",") D PRF D:'$G(PSOQFLAG) S PSOQFLAG=0
24 .I $P(PSOPAR,"^",8),$G(PSOPROFL) W !!,"PROFILE(S) ARE QUEUED TO PRINT"
25 ;call to bingo board
26 I $G(PPLHOLDX),'$G(PSOQGLAG),$G(SUSROUTE) S BBRX(2)=PPLHOLDX
27 D:$G(BINGRTE)&($D(DISGROUP))&('$G(PSOQFLAG)) ^PSOBING1 K BINGRTE,BBRX
28 I $G(PPLHOLDX),'$G(PSOQFLAG) D S PDUZ=DUZ,PPL=PPLHOLDX,PSNP=0,(PSODBQ,PSOPULL)=1 D Q^PSORXL
29 .F XXX=0:0 S XXX=$O(RXPR1(XXX)) Q:'XXX S RXPR(XXX)=$P(RXPR1(XXX),"^",2)
30 .F WWWW=0:0 S WWWW=$O(RXRP1(WWWW)) Q:'WWWW S:$D(RXRP1(WWWW)) RXRP(WWWW)=1
31 I $G(PSOQFLAG) D RESET
32EXIT K ACT,BCNUM,CBD,CNT,COM,DA,DEAD,DEL,DELCNT,DFN,DIRUT,DR,DTOUT,DUOUT,DTTM,GG,HOLD,HOLDPPL,HDSFN,OUT,PSOPULL,PSOWIN,PSOWINEN,PSODBQ,PPLHOLD,PPLHOLDX,HOLDPROF,RR,ZZZZ,PSDNAME,PSDDDATE,ZTSK,WWWW,RXRP,RXRP1,PSONOPRT,RXFL,RXRR
33 S PSOALRX="" F S PSOALRX=$O(PSOALRXS(PSOALRX)) Q:PSOALRX="" D PSOUL^PSSLOCK(PSOALRX)
34 K MW,PDUZ,PPL,PRF,PSPOP,PSOPROFL,RF,RFCNT,RX,RXPR,RXPR1,RXREC,SFN,GGGG,STOP,SUB,VADM,WARN,X,Y,Y(0),%,%W,%Y,%Y1,RXLTOP,PSOGET,PSOGETF,PSOGETFN Q
35TEST I $D(^PS(55,DFN,"P",CBD,0)) S RXREC=+^(0) I +$P($G(^PSRX(RXREC,"STA")),"^")=5,$D(^PS(52.5,"B",RXREC)) S SFN=+$O(^(RXREC,0)) Q:SFN'>0!($G(PSOQFLAG))!('$D(^PS(52.5,SFN,0))) S PSPOP=0 D:$G(PSODIV) DIV I 'PSPOP D CHKDEAD Q:DEAD D BEG
36 Q
37CHKDEAD D DEM^VADPT S PSDNAME=$G(VADM(1)) I VADM(1)="" W !?10,"PATIENT NAME UNKNOWN" S DEAD=0 Q
38 I VADM(6)="" S DEAD=0 Q
39 S PSDDDATE=$P(VADM(6),"^",2) F ZZZZ=0:0 S ZZZZ=$O(^PS(55,DFN,"P",ZZZZ)) Q:'ZZZZ I $D(^PS(55,DFN,"P",ZZZZ,0)),$P($G(^(0)),"^") S (DA,RXREC)=$P(^(0),"^") I $O(^PS(52.5,"B",DA,0)) D DEAD
40 Q
41DEAD S HOLD=DA,REA="C",COM="Died ("_$G(PSDDDATE)_")",DA=RXREC,DEAD=1 D CAN^PSOCAN W:'$G(WARN) !!,?10,$G(PSDNAME)," DIED ",$G(PSDDDATE) S WARN=1,DA=HOLD K HOLD,REA Q
42DIV I $D(^PS(52.5,SFN,0)),$D(^PSRX(+$P(^PS(52.5,SFN,0),"^"),2)),$P(^PS(52.5,SFN,0),"^",6)'=$G(PSOSITE) S RXREC=+$P(^PS(52.5,SFN,0),"^") D CKDIV
43 Q
44CKDIV I '$P($G(PSOSYS),"^",2) W !!?10,$C(7),"Rx # ",$P(^PSRX(RXREC,0),"^")," is not a valid choice. (Different Division)" S PSPOP=1 Q
45 I $P($G(PSOSYS),"^",3) W !!?10,$C(7) S DIR("A")="Rx # "_$P(^PSRX(RXREC,0),"^")_" is from another division. Continue",DIR(0)="Y",DIR("B")="Y" D ^DIR K DIR I $G(DIRUT)!('Y) S PSPOP=1
46 Q
47BEG I $P($G(^PSRX(RXREC,2)),"^",6)<DT,$P($G(^("STA")),"^")<11 D S DIE=52,DA=RXREC,DR="100///"_11 D ^DIE S DA=SFN,DIK="^PS(52.5," D ^DIK K DIE,DA,DIK W !!,"Rx #"_$P(^PSRX(RXREC,0),"^")_" has expired!" D PAUSE Q
48 .D EX^PSOSUTL
49 I '$D(^PS(52.5,SFN,0)) K PSOAL Q
50 I +$G(^PS(52.5,SFN,"P")) W !!,$C(7),">>> Rx #",$P(^PSRX(+$P(^(0),"^"),0),"^")_" has already been printed from suspense.",!,?5,"Use the reprint routine under the rx option to produce a label." D PAUSE Q
51 S PSOALRX=$P($G(^PS(52.5,SFN,0)),"^") I PSOALRX D PSOL^PSSLOCK(PSOALRX) I '$G(PSOMSG) D D PAUSE K PSOMSG,PSOALRX Q
52 .I $P($G(PSOMSG),"^",2)'="" W !!,"Rx: "_$P($G(^PSRX(PSOALRX,0)),"^")_" cannot be pulled from suspense.",!,$P($G(PSOMSG),"^",2),! Q
53 .W !!,"Another person is editing Rx "_$P($G(^PSRX(PSOALRX,0)),"^"),!,"It cannot be pulled from suspense.",!
54 S PSOALRXS(+$G(PSOALRX))=""
55 K PSOMSG,PSOALRX
56 S DA=$P(^PS(52.5,SFN,0),"^"),RXPR(DA)=+$P(^(0),"^",5),RXFL(DA)=$P($G(^(0)),"^",13)
57 I $L($G(PPLHOLD))<240 S PPLHOLD=$S($G(PPLHOLD)="":$P(^PS(52.5,SFN,0),"^"),1:$G(PPLHOLD)_","_+^PS(52.5,SFN,0)) S:$P(^PS(52.5,SFN,0),"^",12) RXRP(DA)=1 G STR
58 S PPLHOLDX=$S($G(PPLHOLDX)="":$P(^PS(52.5,SFN,0),"^"),1:$G(PPLHOLDX)_","_+^PS(52.5,SFN,0)) S:$G(RXPR(DA)) RXPR1(DA)=DA_"^"_RXPR(DA) S:$P(^PS(52.5,SFN,0),"^",12) RXRP1(DA)=1 K RXPR(DA)
59STR I '$D(^PSRX(RXREC,1)),'$G(RXPR(RXREC)),'$G(RXPR1(RXREC)) S PSOPROFL=1
60QUES S HDSFN=SFN D QUES^PSOSUPRX Q
61PRF I $P(PSOPAR,"^",8),'$D(PRF(DFN)),$G(PSOPROFL) S HOLD=DFN D ^PSOPRF S DFN=HOLD,PRF(DFN)=""
62 Q
63PSOINST I '$D(^PSRX(+$P(Y,"-",2),0)) W !!,$C(7),"Non-existent prescription" S OUT=1 Q
64 I $P(Y,"-")'=PSOINST W !!,$C(7),"The prescription is not from this institution." S OUT=1 Q
65 Q
66MAIL I $D(PSOWINEN),$G(PSOWIN) S ^PSRX(RXREC,"MP")=$S(PSOWINEN'="":PSOWINEN,1:"")
67MAILS I $G(RXPR(RXREC)) S DA(1)=RXREC,DA=RXPR(RXREC),DIE="^PSRX("_DA(1)_",""P"",",DR=".02///"_MW D ^DIE K DIE Q
68 S RFCNT=0 F RR=0:0 S RR=$O(^PSRX(RXREC,1,RR)) Q:'RR S RFCNT=RR
69 I 'RFCNT,'$G(RXPR(RXREC)) S DA=RXREC,DIE=52,DR="11///"_MW D ^DIE
70 I RFCNT,'$G(RXPR(RXREC)) S DA(1)=RXREC,DA=RFCNT,DIE="^PSRX("_DA(1)_",1,",DR="2///"_MW D ^DIE
71 K DIE,RFCNT,RR Q
72RESET ;
73 N PRSDA,PRSP,PRMW,PRMP,PRFILL,PRFILLN,PRPSRX,DA
74 F PRSDA=0:0 S PRSDA=$O(RXRR(PRSDA)) Q:'PRSDA D
75 .S PRSP=$O(^PS(52.5,"B",PRSDA,0)) Q:'PRSP
76 .Q:'$D(^PS(52.5,PRSP,0))
77 .S PRMW=$S($P($G(RXRR(PRSDA)),"^")="":"M",1:$P($G(RXRR(PRSDA)),"^")),PRMP=$P($G(RXRR(PRSDA)),"^",2),PRFILL=$P($G(RXRR(PRSDA)),"^",3),PRFILLN=$P($G(RXRR(PRSDA)),"^",4),PRPSRX=$S($P($G(RXRR(PRSDA)),"^",5)="":"M",1:$P($G(RXRR(PRSDA)),"^",5))
78 .I PRMW'="" S $P(^PS(52.5,PRSP,0),"^",4)=PRMW D
79 ..I PRFILL="P" D Q
80 ...I $D(^PSRX(PRSDA,"P",+$G(PRFILLN),0)) S $P(^PSRX(PRSDA,"P",+$G(PRFILLN),0),"^",2)=$G(PRPSRX),$P(^PSRX(PRSDA,"MP"),"^")=PRMP
81 ..I PRFILL="R",$G(PRFILLN) S DA(1)=PRSDA,DA=PRFILLN,DIE="^PSRX("_DA(1)_",1,",DR="2////"_PRPSRX D ^DIE K DIE
82 ..I PRFILL="O" S DA=PRSDA,DIE="^PSRX(",DR="11////"_PRPSRX D ^DIE K DIE
83 ..S $P(^PSRX(PRSDA,"MP"),"^")=PRMP
84 Q
85PAUSE ;
86 W ! K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
87 Q
Note: See TracBrowser for help on using the repository browser.