source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDGSRV.m@ 1608

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

initial load of WorldVistAEHR

File size: 4.7 KB
Line 
1PSDGSRV ;BIR/JPW-Review and Complete Green Sheet ; 6 July 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**28,30**;13 Feb 97
3 ;References to ^PSDRUG( are covered by DBIA221
4 ;Reference to PSD(58.8 supported by DBIA # 2711
5 ;Reference to PSD(58.81 supported by DBIA # 2808
6 ;Reference to VA(200 supported by DBIA # 10060
7 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
8 S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
9 I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to complete",!,?12,"Green Sheets. PSJ RPHARM or PSJ PHARM TECH security key required.",! K OK Q
10 I $P($G(^VA(200,DUZ,20)),U,4)']"" N XQH S XQH="PSD ESIG" D EN^XQH Q
11 N X,X1 D SIG^XUSESIG Q:X1=""
12ASKD ;ask disp location
13 S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
14 G:$P(PSDSITE,U,5) GS
15 K DIC,DA S DIC=58.8,DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
16 S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=PSDSN
17 D ^DIC K DIC G:Y<0 END
18 S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
19GS ;select green sheet #
20 W !!,"Complete a Green Sheet" S PSDUZ=DUZ,PSDUZN=$P($G(^VA(200,PSDUZ,0)),"^")
21 W ! K DA,DIC S DIC("A")="Select the Green Sheet #: ",DIC("S")="I $P(^(0),""^"",3)=+PSDS,$P(^(0),""^"",11)<10!($P(^(0),U,11)=13)!($P(^(0),U,11)=12)",DIC=58.81,DIC(0)="QEASZ",D="D"
22 D IX^DIC K DIC G:Y<0 END S PSDA=+Y,NODE=Y(0)
23 S STAT=+$P(NODE,"^",11),PSDPN=$P(NODE,"^",17),STATN="" I STAT S STATN=$P($G(^PSD(58.82,STAT,0)),"^")
24 I (STAT<4)!(STAT>8)!(STAT=7)&(STAT'=13)&(STAT'=12) W !!,"This order has a status of "_$S(STATN]"":STATN,1:"UNKNOWN")_".",! D MSG G END
25 I STAT=4 D QUES G:NOK GS
26 S ORD=+$P(NODE,"^",20),NAOU=+$P(NODE,"^",18),PSDR=+$P(NODE,"^",5),PSDRN=$P($G(^PSDRUG(PSDR,0)),"^"),(COMP,OCOMP)=+$P(NODE,"^",12),QTY=+$P(NODE,"^",6)
27 S CPBY=+$P($G(^PSD(58.81,PSDA,1)),"^",14)
28 I $D(^PSD(58.81,PSDA,4)),+$P(^(4),"^",3) S QTY=$P(^(4),"^",3)
29 S NBKU=$P($G(^PSD(58.8,+PSDS,1,+PSDR,0)),"^",8)
30START ;start processing
31 S PSDOUT=0
32 W ! K DA,DIC S DIC=58.83,DIC(0)="QEA",DIC("A")="Select Completion Status: " S:COMP DIC("B")=COMP S:'$D(^XUSEC("PSJ RPHARM",PSDUZ)) DIC("S")="I $S(Y=2:0,Y=3:0,1:1)"
33 D ^DIC K DIC I Y<0 G END
34 S COMP=+Y,CSTAT=$S(COMP=1:7,COMP=2:7,COMP=3:7,1:8)
35 ;perpetual inventory?
36 S:$G(COMP)=1&($P($G(^PSD(58.8,$G(NAOU),2)),U,5))&('$P($G(^PSD(58.8,+PSDS,1,+PSDR,7)),U,3)) CSTAT=13
37 K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Is this OK",DIR("?",1)="Answer 'YES' to update the status",DIR("?")="or 'NO' to select another status."
38 S DIR("B")="YES" D ^DIR K DIR G:$D(DIRUT) END I 'Y G START
39 I (COMP=3)!(COMP=2) G ^PSDGSRV1
40UPDATE ;up 58.81
41 W !!,"Accessing Green Sheet information...",!
42 D NOW^%DTC S (RECDT,Y)=+%
43 ;
44 ;PSD*3*30 (DAVE B) added next part to reset global if user
45 ;up-arrows or times out.
46 S PSD10=$P($G(^PSD(58.81,PSDA,0)),"^",11) ;Order Status
47 S PSD11=$P($G(^PSD(58.81,PSDA,0)),"^",12) ;Completion Status
48 S NURSE=$P($G(^PSD(58.81,PSDA,1)),"^",10)
49 K DA,DIE,DR S DA=PSDA,DIE=58.81,DR="I NURSE S Y=22;29;22////"_+$E(RECDT,1,12)_";33////"_PSDUZ_";10////"_CSTAT_";11////"_COMP_";I X'=6 S Y=""@1"";72;@1"
50 D ^DIE K DA,DIE,DR S PSDDT=$P($G(^PSD(58.81,PSDA,0)),"^",19)
51 I $D(Y)!$D(DTOUT) W $C(7),!!,"*** THIS GREEN SHEET HAS NOT BEEN COMPLETED ***",!!,"The status remains "_STATN,! D S PSDOUT=1 G END
52 .;PSD*3*28 (Dave B. 19jun00) If up-arrowed on a referred, remove
53 .;completion status that was set in PSD(58.8
54 .K DR S DIE=58.81,DA=PSDA,DR="I NURSE S Y=22///@"_";29///@"_";33///@"_";10///"_$S($G(PSD10)'="":$G(PSD10),1:"@")_";11///"_$S($G(PSD11)'="":$G(PSD11),1:"@") D ^DIE
55ORDER ;update drug balance & order info in 58.8
56 W !!,"Updating your records now..."
57 K DA,DIE,DR S DA=ORD,DA(1)=PSDR,DA(2)=NAOU,DIE="^PSD(58.8,"_DA(2)_",1,"_DA(1)_",3,",DR="10////"_CSTAT_";11////"_COMP_";12////"_PSDDT D ^DIE K DA,DIE,DR
58 I STAT=8 W "completion log..." S TYPE=4 D ^PSDCOR3
59 W "done.",!!
60 S STAT=$P($G(^PSD(58.81,PSDA,0)),"^",11) W ?2,"*** The status of your Green Sheet #"_PSDPN_" *** ",!
61 S CSTAT=$P($G(^PSD(58.81,PSDA,0)),"^",12) W ?6,$S($P($G(^PSD(58.82,STAT,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN"),!,?6,$P($G(^PSD(58.83,CSTAT,0)),"^")
62 G GS
63END K %,%DT,%H,%I,C,COMP,CPBY,CSTAT,D,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT
64 K NAOU,NBKU,NODE,NOK,NURSE,OCOMP,OK,ORD,PSDA,PSDDT,PSDEV,PSDOUT,PSDPN,PSDR,PSDRN,PSDS,PSDSN,PSDUZ,PSDUZN,QTY,RECD,RECDT,STAT,STATN,SUB,TYPE,X,Y
65 Q
66QUES ;ask ok if still active
67 S NOK=0
68 W ! K DA,DIR,DIRUT S DIR(0)="Y",DIR("A",1)="This Green Sheet is still ACTIVE on the NAOU.",DIR("A")="Do you want to continue"
69 S DIR("?",1)="Answer 'YES' to continue completing this Green Sheet",DIR("?")="or 'NO' to abort processing and select another Green Sheet."
70 D ^DIR K DIR I $D(DIRUT) S NOK=1 G MSG
71 Q:Y
72 I 'Y S NOK=1
73MSG W !!,"** No action taken. **",!
74 Q
Note: See TracBrowser for help on using the repository browser.