source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORRN.m@ 1742

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

initial load of WorldVistAEHR

File size: 8.4 KB
Line 
1PSJORRN ;BIR/MV-RETURN INPATIENT ACTIVE MEDS (CONDENSED) NEW SORT ;28 Jan 99 / 12:56 PM
2 ;;5.0; INPATIENT MEDICATIONS ;**134**;16 DEC 97;Build 124
3 ;
4 ;Reference to ^PS(52.6 is supported by DBIA 1231.
5 ;Reference to ^PS(52.7 is supported by DBIA 2173.
6 ;Reference to ^PS(55 is supported by DBIA 2191.
7 ;Reference to ^PS(50.7 is supported by DBIA #2180.
8 ;Reference to ^TMP("PS" is documented in DBIA #2383.
9 ;
10OCL(DFN,BDT,EDT,TFN) ; return condensed list of inpat meds
11 ; MVIEW=2 - This is the new sort with GUI 27
12 ; Execute this section if MVIEW=2
13 N ADM,CNT,DN,DO,F,FON,INFUS,INST,MR,ND,ND0,ND2,ND6,ON,PON,PST,SCH,SIO,STAT,TYPE,UNITS,WBDT,X,Y,PSJCLIN,A,TFN2
14 S TFN2=0
15 ; PON=placer order number (oerr), FON=filler order number
16 S:BDT="" BDT=DT S WBDT=BDT_".000001"
17 S:EDT="" EDT=9999999
18 S:EDT'["." EDT=EDT_".999999"
19 S F="^PS(55,DFN,5," F S WBDT=$O(^PS(55,DFN,5,"AUS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,5,"AUS",WBDT,ON)) Q:'ON D UDTMP
20 S F="^PS(53.1," F PST="P","N" S ON=0 F S ON=$O(^PS(53.1,"AS",PST,DFN,ON)) Q:'ON S X=$P($G(^PS(53.1,+ON,0)),U,4) D @$S(X="U":"UDTMP",1:"IVTMP")
21 S F="^PS(55,"_DFN_",""IV"",",WBDT=BDT-1 F S WBDT=$O(^PS(55,DFN,"IV","AIS",WBDT)) Q:'WBDT S ON=0 F S ON=$O(^PS(55,DFN,"IV","AIS",WBDT,ON)) Q:'ON D IVTMP
22 S X1="" F S X1=$O(^TMP("PSJTMP",$J,X1)) Q:X1="" S X2="" F S X2=$O(^TMP("PSJTMP",$J,X1,X2)) Q:X2="" D
23 .S X3="" F S X3=$O(^TMP("PSJTMP",$J,X1,X2,X3)) Q:X3="" S X4="" F S X4=$O(^TMP("PSJTMP",$J,X1,X2,X3,X4)) Q:X4="" D
24 ..S X5="" F S X5=$O(^TMP("PSJTMP",$J,X1,X2,X3,X4,X5)) Q:X5="" S TFN=$G(TFN)+1 D
25 ...; The merge below sends the proper ^TMP("PS",$J structure back to the calling
26 ...; routine PSJORRE
27 ...M ^TMP("PS",$J,TFN)=^TMP("PSJTMP",$J,X1,X2,X3,X4,X5) S ^TMP("PS",$J,"PC",0)=TFN
28 K ^TMP("PSJTMP",$J)
29 Q
30 ;
31UDTMP ;*** Set ^TMP for Unit dose orders.
32 N PROVIDER,ND8,RNWDT,EDTCMPLX,NDP2,PSJOINM,PSJOI,PSJDDNM,LOC,PRIO,NDDSS
33 S (MR,SCH,INST,PON,NDDSS)="",FON=+ON_$S(F["53.1":"P",1:"U")
34 D TYPE
35 S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT
36 S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8),PRIO=$P(NDP2,"^",4)
37 S ND2=$G(@(F_ON_",2)")) I 'EDTCMPLX I F'["53.1",($P(ND2,U,2)>EDT) Q
38 S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F["53.1",($P(ND0,U,16)>EDT) Q
39 S ND8=$G(@(F_ON_",8)")),NDP2=$P($G(@(F_ON_",.2)")),"^")
40 S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(FON["P":53.1,1:55.06),28)
41 S ND6=$P($G(@(F_ON_",6)")),"^"),INST=$G(@(F_+ON_",.3)"))
42 S FON=+ON_$S(F["53.1":"P",1:"U"),DO=$P($G(@(F_ON_",.2)")),"^",2)
43 D DRGDISP^PSJLMUT1(DFN,FON,40,0,.DN,1)
44 S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(FON["U")&(UNITS="") UNITS=1
45 S:+$P(ND0,U,3) MR=$$MR^PSJORRE1(+$P(ND0,U,3))
46 N NOTGIVEN S NOTGIVEN=$S(FON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"")
47 ;******** GUI 27 new sort for Meds Tab
48 I F[53.1 S NDDSS=$G(@(F_ON_",""DSS"")")),LOC=$P(NDDSS,"^")
49 S:F'[53.1 LOC=$P(ND8,"^") S LOC=$S($P($G(NDDSS),"^",2):LOC,1:"~") I LOC S LOC=$P($G(^SC(LOC,0)),"^")
50 S PSJST=$P(ND0,"^",9)
51 S GP=$S((",A,R,H,RE,")[(","_PSJST_","):1,(",P,N,")[(","_PSJST_","):2,PSJST="E":3,(",D,DE,DR,")[(","_PSJST_","):4,1:0)
52 S PSJST2=$S(PSJST="A":1,PSJST="R":2,PSJST="H":3,PSJST="S":4,PSJST="P":5,PSJST="O":6,PSJST="N":7,PSJST="I":8,PSJST="P":9,GP=4&($G(PRIO)="D"):10,PSJST="E":11,PSJST="D":12,PSJST="DE":13,PSJST="RE":14,PSJST="R":15,1:0)
53 S PSJOI=$P(NDP2,"^"),PSJOINM=$P($G(^PS(50.7,+PSJOI,0)),"^")
54 ;*******
55 S TFN2=$G(TFN2)+1
56 S CNT=0,PSJOINM=$S(PSJOINM]"":PSJOINM,1:"UNKNOWN")
57 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,0)=FON_";I"_U_DN(1)_"^^"_$P(ND2,U,4)_"^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_STAT_U_U_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_$P(ND2,U,2)_U_$G(RNWDT)
58 K ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"CLINIC",0) I PSJCLIN]"" S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"CLINIC",0)=PSJCLIN
59 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2)
60 I PROVIDER S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^")
61 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"MDR",0)=MR]"" S:MR]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"MDR",1,0)=MR
62 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SCH",1,0)=$P(ND2,U)
63 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIG",0)=INST]"" S:INST]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIG",1,0)=INST
64 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"ADM",1,0)=$P(ND2,U,5)
65 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIO",1,0)=ND6
66 Q
67 ;
68IVTMP ;*** Set ^TMP for IV orders.
69 N PROVIDER,START,STOP,EDTCMPLX,NDP2,IVLIM,PRIO,LOC,NDDSS
70 S (PROVIDER,START,STOP,EDTCMPLX,NDP2,IVLIM,PRIO,LOC,NDDSS)=""
71 S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8),PRIO=$P(NDP2,"^",4)
72 S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F'["53.1",($P(ND0,U,2)>EDT) Q
73 D TYPE
74 S FON=+ON_$S(F["53.1":"P",1:"V"),TFN2=TFN2+1,CNT=0
75 S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT
76 ;******** GUI 27 new sort for Meds Tab
77 S NDDSS=$G(@(F_ON_",""DSS"")")),NDP2=$G(@(F_ON_",.2)"))
78 S PSJOI=$P(NDP2,"^")
79 I F[53.1 S PSJST=$P(ND0,"^",9)
80 I F'[53.1 S PSJST=$P(ND0,"^",17)
81 S GP=$S((",A,R,H,RE,")[(","_PSJST_","):1,(",P,N,")[(","_PSJST_","):2,PSJST="E":3,(",D,DE,DR,")[(","_PSJST_","):4,1:0)
82 S PSJST2=$S(PSJST="A":1,PSJST="R":2,PSJST="H":3,PSJST="S":4,PSJST="P":5,PSJST="O":6,PSJST="N":7,PSJST="I":8,PSJST="P":9,GP=4&($G(PRIO)="D"):10,PSJST="E":11,PSJST="D":12,PSJST="DE":13,PSJST="RE":14,PSJST="R":15,1:0)
83 S LOC=$P(NDDSS,"^") S LOC=$S($P(NDDSS,"^",2):LOC,1:"~") I LOC S LOC=$P($G(^SC(LOC,0)),"^")
84 S PSJOINM=$P(^PS(50.7,+PSJOI,0),"^")
85 ;********
86 S CNT=0,PSJOINM=$S(PSJOINM]"":PSJOINM,1:"UNKNOWN")
87 F X=0:0 S X=$O(@(F_ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"A",CNT,0)=Y
88 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"A",0)=CNT,CNT=0
89 F X=0:0 S X=$O(@(F_ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4)
90 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"B",0)=CNT
91 S TYPE=$P(ND0,U,4),(MR,SCH,INST,INFUS)=""
92 I FON["P" S ND2=$G(^PS(53.1,+ON,2)),SCH=$P(ND2,U),START=$P(ND2,U,2),STOP=$P(ND2,U,4),MR=$P(ND0,U,3),INFUS=$P($G(^PS(53.1,+ON,8)),U,5),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28),ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^")
93 I FON'["P" S START=$P(ND0,U,2),STOP=$P(ND0,U,3),SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),MR=$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100),ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^")
94 S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2)
95 S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"")
96 S:MR MR=$$MR^PSJORRE1(+MR),INST=$G(@(F_+ON_",.3)"))
97 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,0)=FON_";I"_U_DN_U_INFUS_U_STOP_"^^"_DO_"^^"_$P(ND0,"^",21)_U_STAT_U_U_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_START_U_$G(RNWDT)
98 K ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"CLINIC",0) I PSJCLIN]"" S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"CLINIC",0)=PSJCLIN
99 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",6)
100 I PROVIDER S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^")
101 S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I $E(IVLIM)="a" S IVLIM="doses"_$P(IVLIM,"a",2)
102 I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM=""
103 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"MDR",0)=MR]"" S:MR]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"MDR",1,0)=MR
104 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIG",0)=INST]"" S:INST]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIG",1,0)=INST
105 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SCH",1,0)=SCH
106 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"ADM",1,0)=ADM
107 S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"SIO",1,0)=SIO
108 I $G(IVLIM)]"" S ^TMP("PSJTMP",$J,GP,PSJST,LOC,PSJOINM,TFN2,"IVLIM",0)=IVLIM
109 Q
110STAT(Y,X) ;* Return the full status instead of just the code for U/D.
111 S X=$P($P(";"_$P(Y,U,3),";"_X_":",2),";")
112 Q X
113TYPE ;determine if this is an IMO order or not
114 S (A,PSJCLIN)="" I F["PS(53.1" S A=$G(^PS(53.1,ON,"DSS"))
115 I F["PS(55" S A=$S(F["IV":$G(^PS(55,DFN,"IV",ON,"DSS")),1:$G(^PS(55,DFN,5,ON,8)))
116 I $P(A,"^",2)'="" S PSJCLIN=+A
117 Q
Note: See TracBrowser for help on using the repository browser.