source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOORRL3.m@ 1042

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

initial load of WorldVistAEHR

File size: 5.0 KB
Line 
1PSOORRL3 ;BHAM ISC/SJA - returns patient's outpatient meds-new sort ;02/02/07
2 ;;7.0;OUTPATIENT PHARMACY;**225**;DEC 1997;Build 29
3 ;External reference to ^PS(55 supported by DBIA 2228
4 ;External reference to ^PSDRUG supported by DBIA 221
5 ;External reference to ^VA(200 supported by DBIA 10060
6 ;External reference to ^PS(51.2 supported by DBIA 2226
7 ;External reference to ^PS(50.7 supported by DBIA 2223
8 ;External reference to ^PS(50.606 supported by DBIA 2174
9 ;External reference to OCL^PSJORRE supported by DBIA 2383
10OCL ;entry point to return condensed list
11 ;BHW;PSO*7*159;New SD* Variables
12 N SD,SDT,SDT1,PSG,PST,PSD,DRUG,PSOSTA
13 D:$P($G(^PS(55,DFN,0)),"^",6)'=2 EN^PSOHLUP(DFN)
14 K ^TMP("PS",$J),^TMP("PSO",$J),^TMP("PS1",$J)
15 S TFN=0,PSBDT=$G(BDT),PSEDT=$G(EDT) I +$G(PSBDT)<1 S X1=DT,X2=-120 D C^%DTC S PSBDT=X
16 S EXDT=PSBDT-1,IFN=0
17 F S EXDT=$O(^PS(55,DFN,"P","A",EXDT)) Q:'EXDT F S IFN=$O(^PS(55,DFN,"P","A",EXDT,IFN)) Q:'IFN D:$D(^PSRX(IFN,0))
18 .S PSOSTA=$P($G(^PSRX(IFN,"STA")),"^") Q:'(PSOSTA=0!(PSOSTA=11)!(PSOSTA=5))
19 .S TFN=TFN+1,RX0=^PSRX(IFN,0),RX2=$G(^(2)),RX3=$G(^(3)),STA=+$G(^("STA")),TRM=0,LSTFD=$P(RX2,"^",2),LSTRD=$P(RX2,"^",13),LSTDS=$P(RX0,"^",8)
20 .F I=0:0 S I=$O(^PSRX(IFN,1,I)) Q:'I S TRM=TRM+1,LSTFD=$P(^PSRX(IFN,1,I,0),"^"),LSTDS=$P(^(0),"^",10) S:$P(^(0),"^",18)]"" LSTRD=$P(^(0),"^",18)
21 .S ST0=STA,ST=$P("ERROR^ACTIVE^^^^^ACTIVE/SUSP^^^^^^EXPIRED^^^^^^","^",ST0+2)
22 .S DRUG=$P($G(^PSDRUG(+$P(RX0,"^",6),0)),"^")
23 .S ^TMP("PSO",$J,DRUG,ST,TFN,0)=IFN_"R;O"_"^"_DRUG_"^^"_$P(RX2,"^",6)_"^"_($P(RX0,"^",9)-TRM)_"^^^"_$P($G(^PSRX(IFN,"OR1")),"^",2)
24 .S ^TMP("PSO",$J,DRUG,ST,TFN,"P",0)=$P(RX0,"^",4)_"^"_$P($G(^VA(200,+$P(RX0,"^",4),0)),"^")
25 .S ^TMP("PSO",$J,DRUG,ST,TFN,0)=^TMP("PSO",$J,DRUG,ST,TFN,0)_"^"_ST_"^"_LSTFD_"^"_$P(RX0,"^",8)_"^"_$P(RX0,"^",7)_"^^^"_$P(RX0,"^",13)_"^"_LSTRD_"^"_LSTDS
26 .S ^TMP("PSO",$J,DRUG,ST,TFN,"SCH",0)=0
27 .S (SCH,SC)=0 F S SC=$O(^PSRX(IFN,"SCH",SC)) Q:'SC S SCH=SCH+1,^TMP("PSO",$J,DRUG,ST,TFN,"SCH",SCH,0)=$P(^PSRX(IFN,"SCH",SC,0),"^"),^TMP("PSO",$J,DRUG,ST,TFN,"SCH",0)=^TMP("PSO",$J,DRUG,ST,TFN,"SCH",0)+1
28 .S ^TMP("PSO",$J,DRUG,ST,TFN,"MDR",0)=0,(MDR,MR)=0 F S MR=$O(^PSRX(IFN,"MEDR",MR)) Q:'MR D
29 ..Q:'$D(^PS(51.2,+^PSRX(IFN,"MEDR",MR,0),0)) S MDR=MDR+1
30 ..I $P($G(^PS(51.2,+^PSRX(IFN,"MEDR",MR,0),0)),"^",3)]"" S ^TMP("PSO",$J,DRUG,ST,TFN,"MDR",MDR,0)=$P(^PS(51.2,+^PSRX(IFN,"MEDR",MR,0),0),"^",3)
31 ..I $D(^PS(51.2,+^PSRX(IFN,"MEDR",MR,0),0)),$P($G(^(0)),"^",3)']"" S ^TMP("PSO",$J,DRUG,ST,TFN,"MDR",MDR,0)=$P(^PS(51.2,+^PSRX(IFN,"MEDR",MR,0),0),"^")
32 ..S ^TMP("PSO",$J,DRUG,ST,TFN,"MDR",0)=^TMP("PSO",$J,DRUG,ST,TFN,"MDR",0)+1
33 .S PSOELSE=0 I $D(^PSRX(IFN,"SIG")),'$P(^PSRX(IFN,"SIG"),"^",2) S PSOELSE=1 S X=$P(^PSRX(IFN,"SIG"),"^") D SIG1^PSOORRL1
34 .I '$G(PSOELSE) S ITFN=1 D
35 ..S ^TMP("PSO",$J,DRUG,ST,TFN,"SIG",ITFN,0)=$G(^PSRX(IFN,"SIG1",1,0)),^TMP("PSO",$J,DRUG,ST,TFN,"SIG",0)=+$G(^TMP("PSO",$J,DRUG,ST,TFN,"SIG",0))+1
36 ..F I=1:0 S I=$O(^PSRX(IFN,"SIG1",I)) Q:'I S ITFN=ITFN+1,^TMP("PSO",$J,DRUG,ST,TFN,"SIG",ITFN,0)=^PSRX(IFN,"SIG1",I,0),^TMP("PSO",$J,DRUG,ST,TFN,"SIG",0)=+$G(^TMP("PSO",$J,DRUG,ST,TFN,"SIG",0))+1
37 K PSOELSE D NVA
38 S PSG="",J=1 F S PSG=$O(^TMP("PSO",$J,PSG)) Q:PSG="" S PST="" F S PST=$O(^TMP("PSO",$J,PSG,PST)) Q:PST="" S I=0 F S I=$O(^TMP("PSO",$J,PSG,PST,I)) Q:'I D
39 .M ^TMP("PS",$J,J)=^TMP("PSO",$J,PSG,PST,I) S J=J+1
40 S PSG="" F S PSG=$O(^TMP("PS1",$J,PSG)) Q:PSG="" S PST="" F S PST=$O(^TMP("PS1",$J,PSG,PST)) Q:PST="" S I=0 F S I=$O(^TMP("PS1",$J,PSG,PST,I)) Q:I="" D
41 .M ^TMP("PS",$J,J)=^TMP("PS1",$J,PSG,PST,I) S J=J+1
42 K ^TMP("PSO",$J),^TMP("PS1",$J)
43 D OCL^PSJORRE(DFN,BDT,EDT,.TFN,+$G(VIEW)) D END^PSOORRL1
44 K SDT,SDT1,ST,DRUG,PSG,PST,PSD,EDT,EDT1,BDT,DBT1,X
45 Q
46NVA ; Set Non-VA Med Orders in the ^TMP Global
47 ;BHW;PSO*7*159;New SDT,SDT1 Variables
48 N SDT,SDT1
49 F I=0:0 S I=$O(^PS(55,DFN,"NVA",I)) Q:'I S X=$G(^PS(55,DFN,"NVA",I,0)) D
50 .Q:'$P(X,"^")!($P(X,"^",7))
51 .S DRG=$S($P(X,"^",2):$P($G(^PSDRUG($P(X,"^",2),0)),"^"),1:$P(^PS(50.7,$P(X,"^"),0),"^")_" "_$P(^PS(50.606,$P(^PS(50.7,$P(X,"^"),0),"^",2),0),"^"))
52 .S SDT=$P(X,"^",9) I 'SDT D TMPBLD Q
53 .I $E(SDT,4,5),$E(SDT,6,7) D
54 ..;I $P(X,"^",9) D Q
55 ..I $G(BDT),SDT<BDT Q
56 ..I $G(EDT),SDT>EDT Q
57 ..I $G(BDT),$P(X,"^",7),$P(X,"^",7)<BDT Q
58 ..D TMPBLD
59 .I $E(SDT,4,5),'$E(SDT,6,7) D
60 ..S SDT1=$E(SDT,1,5),BDT1=$E(+$G(BDT),1,5),EDT1=$E(+$G(EDT),1,5)
61 ..I $G(BDT1),SDT1<BDT1 Q
62 ..I $G(EDT1),SDT1>EDT1 Q
63 ..I $G(BDT1),$P(X,"^",7),$E($P(X,"^",7),1,5)<BDT1 Q
64 ..D TMPBLD
65 .I '$E(SDT,4,5),'$E($P(X,"^",9),6,7) D
66 ..;I $P(X,"^",9) D Q
67 ..S SDT1=$E(SDT,1,3),BDT1=$E(+$G(BDT),1,3),EDT1=$E(+$G(EDT),1,3)
68 ..I $G(BDT1),SDT1<BDT1 Q
69 ..I $G(EDT1),SDT1>EDT1 Q
70 ..I $G(BDT1),$P(X,"^",7),$E($P(X,"^",7),1,3)<BDT1 Q
71 ..D TMPBLD
72 Q
73TMPBLD S TFN=$G(TFN)+1,ST="ACTIVE"
74 S ^TMP("PS1",$J,DRG,ST,TFN,0)=I_"N;O^"_DRG
75 S $P(^TMP("PS1",$J,DRG,ST,TFN,0),"^",8)=$P(X,"^",8)_"^"_$S($P(X,"^",7):"DISCONTINUED",1:"ACTIVE")
76 S ^TMP("PS1",$J,DRG,ST,TFN,"SCH",0)=1,^TMP("PS1",$J,DRG,ST,TFN,"SCH",1,0)=$P(X,"^",5)
77 S ^TMP("PS1",$J,DRG,ST,TFN,"SIG",0)=1,^TMP("PS1",$J,DRG,ST,TFN,"SIG",1,0)=$P(X,"^",3)_" "_$P(X,"^",4)_" "_$P(X,"^",5)
78 Q
Note: See TracBrowser for help on using the repository browser.