[613] | 1 | PSJHL4 ;BIR/RLW-DECODE HL7 /MESSSAGE FROM OE/RR ;16 Mar 99 / 4:55 PM
|
---|
| 2 | ;;5.0; INPATIENT MEDICATIONS ;**1,12,27,34,40,42,55,47,50,56,58,98,85,105,107,110,111,154,134**;16 DEC 97;Build 124
|
---|
| 3 | ; Reference to $$EN^PSOHLNEW is supported by DBIA# 2188.
|
---|
| 4 | ; Reference to ^PS(50.7 is supported by DBIA 2180.
|
---|
| 5 | ; Reference to ^PS(51.2 is supported by DBIA 2178.
|
---|
| 6 | ; Reference to ^PS(55 is supported by DBIA 2191.
|
---|
| 7 | ; Reference to ^PS(59.7 supported by DBIA 2181.
|
---|
| 8 | ; Reference to ^ORHLESC is supported by DBIA 4922.
|
---|
| 9 | ;
|
---|
| 10 | EN(PSJMSG) ; Start
|
---|
| 11 | K ^TMP("PSJNVO",$J)
|
---|
| 12 | N ADCNT,SOLCNT,OCCNT
|
---|
| 13 | N ACKDATE,ADDITIVE,ADMINSTR,APPL,COMMENT,PSJHLDFN,DISPENSE,DOSE,DURATION,II,INSTR,J,JJ,JJJ,K,LOGIN,NEWORDER,NURSEACK,OBXFL,OCNARR,OCPROV,OCRSN,ORDER,PRIORITY,PSITEM,ORDCON,PROCOM,PSJORDER,PSREASON
|
---|
| 14 | N LOC,PROVIDER,PSPR,PSOC,PTR,QQ,REQST,ROUTE,RXON,RXORDER,SCHEDULE,SEGMENT,SOLUTION,STPDT,STRENGTH,TEXT,CLERK,INFRT,IVTYP,SCHTYP,PREON,NOO,ROC,FREQ,CLASS,PSJHLMTN,UNIT,UNITS,QFLG,VOLUME,TVOLUME,PSGP
|
---|
| 15 | N PSJASTP,FLDATE,FLCMNT,PSJFLAG,PSJYN,PRNTON,APPT,IVLIMIT,IVCAT,INTRMT
|
---|
| 16 | S (ADCNT,SOLCNT,OCCNT,II,TVOLUME)="",(OBXFL,QFLG)=0,PSJHLMTN="ORR" F S II=$O(PSJMSG(II)) Q:'II D DECODE Q:QFLG D @FIELD(0) Q:$G(CLASS)="O" Q:QFLG
|
---|
| 17 | I ($G(CLASS)'="I")!(QFLG) G END
|
---|
| 18 | I ($G(PSOC)="NW")!($G(PSOC)="XO") N DIK,DA S DIK="^PS(53.1,",DA=NEWORDER D EN1^DIK L -^PS(53.1,NEWORDER)
|
---|
| 19 | I ($G(PSOC)="NW")!($G(PSOC)="XO") D EN1^PSJHL2(PSJHLDFN,$S(PSOC="NW":"OK",1:"XR"),NEWORDER_"P")
|
---|
| 20 | END ;
|
---|
| 21 | K ^TMP("PSJNVO",$J)
|
---|
| 22 | I (",S,A,")[(","_$G(PRIORITY)_",")!($G(SCHEDULE)="NOW")!($G(SCHEDULE)["STAT") D
|
---|
| 23 | . I $G(PRIORITY)="ZD",$G(PSGORD) D NOTIFY(PSGORD_$S(PSGORD["V":"V",PSGORD["U":"U",1:""),PSJHLDFN,$G(PRIORITY),$G(SCHEDULE))
|
---|
| 24 | . I $G(NEWORDER) D NOTIFY(NEWORDER_"P",PSJHLDFN,$G(PRIORITY),$G(SCHEDULE))
|
---|
| 25 | Q
|
---|
| 26 | DECODE ; Parse into fields
|
---|
| 27 | K FIELD
|
---|
| 28 | N PSJCTR1 S PSJCTR1=""
|
---|
| 29 | S SEGMENT=$G(PSJMSG(II))
|
---|
| 30 | I $D(PSJMSG(II,1)),$P(SEGMENT,"|",1)="ORC" F S PSJCTR1=$O(PSJMSG(II,PSJCTR1)) Q:PSJCTR1="" D
|
---|
| 31 | . S SEGMENT=SEGMENT_PSJMSG(II,PSJCTR1) ;Handle CPRS "overflow" ORC nodes
|
---|
| 32 | S J=0
|
---|
| 33 | F Q:$G(SEGMENT)="" D
|
---|
| 34 | .I SEGMENT["|" S FIELD(J)=$P(SEGMENT,"|"),SEGMENT=$E(SEGMENT,$L(FIELD(J))+2,$L(SEGMENT)),J=J+1 Q
|
---|
| 35 | .I SEGMENT'["|" S FIELD(J)=SEGMENT,SEGMENT="" Q
|
---|
| 36 | K PSJCTR1
|
---|
| 37 | Q
|
---|
| 38 | NOTIFY(ORDER,PSJHLDFN,PRIO,PSJSCHED) ; Send msg
|
---|
| 39 | N NTFYREAS,WARD,MGROUP,NTFSTAT,DRUG,DRIEN,PNAME,ORDATE,DO,PSG,XMY,VADPT,LASTFOUR,PSJSOK
|
---|
| 40 | Q:($G(PRIO)=""&($G(PSJSCHED)=""))
|
---|
| 41 | S DFN=PSJHLDFN D DEM^VADPT S LASTFOUR=$P($P(VADM(2),"^",2),"-",3)
|
---|
| 42 | S NTFYREAS=$S((",S,A,")[(","_PRIO_","):1,($G(PSJSCHED)="NOW"):2,($G(PSJSCHED)="STAT"):3,1:0) Q:'NTFYREAS
|
---|
| 43 | S PSJSOK=1
|
---|
| 44 | I ORDER["P" D PND
|
---|
| 45 | I ORDER["U" D UD
|
---|
| 46 | I ORDER["V" D IV
|
---|
| 47 | Q:PSJSOK=1
|
---|
| 48 | D XMD^PSJHL4A
|
---|
| 49 | Q
|
---|
| 50 | PND ; Pending
|
---|
| 51 | N WARD,WDPARM,MGRP
|
---|
| 52 | Q:'$D(^PS(53.1,+ORDER,0))
|
---|
| 53 | S WARD=$G(^DPT(PSJHLDFN,.1)) I WARD]"" D
|
---|
| 54 | .N DIC,X,Y S DIC="^DIC(42,",DIC(0)="BOXZ",X=WARD D ^DIC S WARD=+Y Q:WARD=0
|
---|
| 55 | .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0
|
---|
| 56 | .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD)
|
---|
| 57 | .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0
|
---|
| 58 | .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0
|
---|
| 59 | S:'$$SNDTSTP^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW PENDING ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0
|
---|
| 60 | S NTFSTAT="PENDING"
|
---|
| 61 | N NDP2,ND0 S NDP2=$G(^PS(53.1,+ORDER,.2)),ND0=$G(^PS(53.1,+ORDER,0))
|
---|
| 62 | S DRIEN=+$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(ND0,"^",3),ORDATE=$P(ND0,"^",14)
|
---|
| 63 | S SCHED=$P($G(^PS(53.1,+ORDER,2)),"^")
|
---|
| 64 | Q
|
---|
| 65 | UD ; UD
|
---|
| 66 | N WARD,WDPARM,MGRP
|
---|
| 67 | Q:'$D(^PS(55,PSJHLDFN,5,+ORDER,0))
|
---|
| 68 | S WARD=$P($G(^PS(55,PSJHLDFN,5,+ORDER,0)),"^",23) I +WARD D
|
---|
| 69 | .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0
|
---|
| 70 | .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD)
|
---|
| 71 | .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0
|
---|
| 72 | .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0
|
---|
| 73 | S:'$$SNDTSTA^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW ACTIVE ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0
|
---|
| 74 | S NTFSTAT="ACTIVE"
|
---|
| 75 | N ND2,ND0 S ND0=$G(^PS(55,PSJHLDFN,5,+ORDER,0)),ND2=$G(^PS(55,PSJHLDFN,5,+ORDER,2)),NDP2=$G(^PS(55,PSJHLDFN,5,+ORDER,.2))
|
---|
| 76 | S DRIEN=+$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(ND0,"^",3),ORDATE=$P(ND0,"^",14)
|
---|
| 77 | S SCHED=$P(ND2,"^")
|
---|
| 78 | Q
|
---|
| 79 | IV ; IV
|
---|
| 80 | N WARD,WDPARM,MGRP
|
---|
| 81 | Q:'$D(^PS(55,PSJHLDFN,"IV",+ORDER,0))
|
---|
| 82 | S WARD=$P($G(^PS(55,PSJHLDFN,"IV",+ORDER,0)),"^",22) I +WARD D
|
---|
| 83 | .S WARD=$O(^PS(59.6,"B",WARD,0)) Q:+WARD=0
|
---|
| 84 | .Q:$$SNDTSTW^PSJHL4A(PRIO,PSJSCHED,WARD)
|
---|
| 85 | .S WDPARM=$G(^PS(59.6,+WARD,0)),MGRP=$P(WDPARM,"^",30) Q:+MGRP=0
|
---|
| 86 | .S MGRP=$$GET1^DIQ(3.8,MGRP,.01) I MGRP]"" S XMY("G."_MGRP_"@"_$G(^XMB("NETNAME")))="",PSJSOK=0
|
---|
| 87 | S:'$$SNDTSTA^PSJHL4A(PRIO,PSJSCHED) MGROUP="G.PSJ STAT NOW ACTIVE ORDER@"_$G(^XMB("NETNAME")),XMY(MGROUP)="",PSJSOK=0
|
---|
| 88 | S NTFSTAT="ACTIVE"
|
---|
| 89 | N ND2,NDP2,ND0 S ND0=$G(^PS(55,PSJHLDFN,"IV",+ORDER,0)),ND2=$G(^PS(55,PSJHLDFN,"IV",+ORDER,2))
|
---|
| 90 | S NDP2=$G(^PS(55,PSJHLDFN,"IV",+ORDER,.2))
|
---|
| 91 | S DRIEN=$P(NDP2,"^"),DO=$P(NDP2,"^",2),RTE=$P(NDP2,"^",3)
|
---|
| 92 | S ORDATE=$P(ND2,"^"),SCHED=$P(ND0,"^",9)
|
---|
| 93 | Q
|
---|
| 94 | MSH ; Header
|
---|
| 95 | S PSOC=FIELD(8)
|
---|
| 96 | Q
|
---|
| 97 | PID ; ID
|
---|
| 98 | S PSJHLDFN=$$UNESC^ORHLESC(FIELD(3))
|
---|
| 99 | Q
|
---|
| 100 | PV1 ; Visit
|
---|
| 101 | N A
|
---|
| 102 | S CLASS=FIELD(2),LOC=$P(FIELD(3),"^"),APPT="" I $G(FIELD(44))]"" S APPT=+$$HL7TFM^XLFDT(FIELD(44))
|
---|
| 103 | I "IO"'[CLASS S PSREASON="Invalid patient class" Q
|
---|
| 104 | N QQ K PSJNVA S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ D Q:$G(PSJNVA)
|
---|
| 105 | .S X=$G(PSJMSG(QQ))
|
---|
| 106 | .I $P(X,"|")="ZRN" S PSJNVA=1,CLASS="O" D EN^PSOHLNEW(.PSJMSG)
|
---|
| 107 | I $G(PSJNVA) K PSJNVA Q
|
---|
| 108 | I CLASS="O" N QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="OBR" D Q:$P(PSJMSG(QQ),"|")="OBR"
|
---|
| 109 | .S RXON=$P(PSJMSG(QQ),"|",4) I RXON]"" S RXON=$P(RXON,"^") I "ABNPUV"[$E(RXON,$L(RXON)) S CLASS="I"
|
---|
| 110 | I CLASS="O" N QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="ORC" D Q:$P(PSJMSG(QQ),"|")="ORC"
|
---|
| 111 | .S RXON=$P(PSJMSG(QQ),"|",4) I RXON]"" S RXON=$P(RXON,"^") I "ABNPUV"[$E(RXON,$L(RXON)) S CLASS="I"
|
---|
| 112 | I CLASS="O" N CHK,QQ S QQ=II F S QQ=$O(PSJMSG(QQ)) Q:'QQ I $P(PSJMSG(QQ),"|")="RXO" D Q:$P(PSJMSG(QQ),"|")="RXO"
|
---|
| 113 | .S CHK=$P(PSJMSG(QQ),"|",2),CHK=$S($P(CHK,"^",5)="IV":"IV",1:$P(CHK,"^",4))
|
---|
| 114 | .I CHK="IV" S CLASS="I" Q
|
---|
| 115 | .I 'CHK S PSREASON="Missing or Invalid Orderable Item",CLASS="I" Q
|
---|
| 116 | .I $P($G(^PS(50.7,CHK,0)),"^",3)=1 S CLASS="I" Q
|
---|
| 117 | D:CLASS="O" EN^PSOHLNEW(.PSJMSG)
|
---|
| 118 | Q
|
---|
| 119 | ORC ; Order
|
---|
| 120 | S TMPAT=""
|
---|
| 121 | S PSOC=FIELD(1)
|
---|
| 122 | S ORDER=FIELD(2)
|
---|
| 123 | I $G(PSREASON)]"" D ERROR^PSJHL9 Q
|
---|
| 124 | S PSJORDER=$P(FIELD(2),"^"),RXON=$P(FIELD(3),"^"),RXORDER=$S((RXON["N")!(RXON["P"):"^PS(53.1,"_+RXON_",",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+RXON_",",1:"^PS(55,"_PSJHLDFN_",5,"_+RXON_",")
|
---|
| 125 | I PSOC="NA" D ASSIGN^PSJHL5 Q
|
---|
| 126 | S CLERK=+$G(FIELD(10))
|
---|
| 127 | S PROVIDER=+$G(FIELD(12)) D:PSOC="NW"
|
---|
| 128 | .I PROVIDER=0 S PSREASON="Invalid Provider" D ERROR^PSJHL9 Q
|
---|
| 129 | .I PROVIDER>0 S PSPR=$G(^VA(200,+PROVIDER,"PS")) I '$D(PSPR)!'(PSPR)!$S($P(PSPR,"^",4)="":0,1:$P(PSPR,"^",4)'>DT) S PSREASON="Invalid Provider" D ERROR^PSJHL9 Q
|
---|
| 130 | S UNITS=$P(FIELD(7),"^"),INSTR=$$UNESC^ORHLESC($P(FIELD(7),"^",8))
|
---|
| 131 | S:UNITS["&" DOSE=$P(UNITS,"&"),UNIT=$P(UNITS,"&",2),UNITS=$P(UNITS,"&",3) S:UNITS]"" UNITS=$$UNESC^ORHLESC(UNITS) S:$G(DOSE)]"" DOSE=$$UNESC^ORHLESC(DOSE)
|
---|
| 132 | S SCHEDULE=$P(FIELD(7),"^",2),PRIORITY=$P(FIELD(7),"^",6) S:SCHEDULE["PRN" SCHTYP="P"
|
---|
| 133 | I SCHEDULE["&" S ADMINS=$P(SCHEDULE,"&",2),SCHEDULE=$P(SCHEDULE,"&") S ADMINS=$TR(ADMINS," ","") S ADMINS=$S(ADMINS:ADMINS,1:"")
|
---|
| 134 | S SCHEDULE=$$UNESC^ORHLESC(SCHEDULE)
|
---|
| 135 | I SCHEDULE["@" S TMPAT=$$TMPAT^PSJHL4A(SCHEDULE)
|
---|
| 136 | I $G(TMPAT) S $P(SCHEDULE,"@",2)=TMPAT,ADMINS=TMPAT
|
---|
| 137 | S DURATION=$P(FIELD(7),"^",3),REQST=$P(FIELD(7),"^",4) S:REQST'="" REQST=+$E(+$$HL7TFM^XLFDT(REQST),1,12) S REQST=$$DATE2^PSJUTL2(REQST)
|
---|
| 138 | S PRIORITY=$S($G(PRIORITY)]"":PRIORITY,1:"R")
|
---|
| 139 | I $E(SCHEDULE,1)=" " S:$TR(SCHEDULE," ")="PRN" SCHEDULE="PRN" I '(SCHEDULE="PRN") S PSREASON="Invalid Schedule" D ERROR^PSJHL9 Q
|
---|
| 140 | S SCHTYP=$P(FIELD(7),"^",7)
|
---|
| 141 | I $G(SCHTYP)="D" S SCHTYP="C" ;Makes CPRS Day of Week consistent in behavior with backdoor order of Day of Week
|
---|
| 142 | S PRNTON=$P(FIELD(8),"^")
|
---|
| 143 | S NURSEACK=$G(FIELD(11))
|
---|
| 144 | S LOGIN=$G(FIELD(15)) S:LOGIN'="" LOGIN=+$E(+$$HL7TFM^XLFDT(FIELD(15)),1,12) S LOGIN=$$DATE2^PSJUTL2(LOGIN)
|
---|
| 145 | S:$G(NURSEACK)]"" ACKDATE=LOGIN
|
---|
| 146 | S ORDCON=$P($G(FIELD(16)),U) I ORDCON="A" S PSJASTP=$G(FIELD(9)) S:$G(PSJASTP)'="" PSJASTP=+$E(+$$HL7TFM^XLFDT(PSJASTP),1,12) S PSJASTP=$$DATE2^PSJUTL2(PSJASTP)
|
---|
| 147 | I (PSOC="CA")!(PSOC="DC") D CANCEL^PSJHL6 Q
|
---|
| 148 | I PSOC="HD" D HOLD^PSJHL6 Q
|
---|
| 149 | I PSOC="RL" D UNHOLD^PSJHL6 Q
|
---|
| 150 | I PSOC="ZV" D NURSEACK^PSJHL5 Q
|
---|
| 151 | I PSOC="SS" D STATUS^PSJHL5 Q
|
---|
| 152 | I PSOC="Z@" N X S X="PSJHL8" X ^%ZOSF("TEST") I D PURGE^PSJHL8 Q
|
---|
| 153 | I PSOC="DE" S QFLG=1 Q
|
---|
| 154 | Q
|
---|
| 155 | OBR ; Flagging from CPRS.
|
---|
| 156 | S ORDER=FIELD(2)
|
---|
| 157 | S PSJORDER=$P(FIELD(2),"^"),RXON=$P(FIELD(3),"^"),RXORDER=$S((RXON["N")!(RXON["P"):"^PS(53.1,"_+RXON_",",RXON["V":"^PS(55,"_PSJHLDFN_",""IV"","_+RXON_",",1:"^PS(55,"_PSJHLDFN_",5,"_+RXON_",")
|
---|
| 158 | S PSJFLAG=FIELD(4)
|
---|
| 159 | S FLDATE=$G(FIELD(7)) S:FLDATE'="" FLDATE=+$E(+$$HL7TFM^XLFDT(FIELD(7)),1,12) S FLDATE=$$DATE2^PSJUTL2(FLDATE)
|
---|
| 160 | S CLERK=+$G(FIELD(16))
|
---|
| 161 | S PSJYN=$G(FIELD(24))
|
---|
| 162 | S FLCMNT=$$UNESC^ORHLESC($G(FIELD(13)))
|
---|
| 163 | I PSOC="ORU" D FLAG^PSJHL5
|
---|
| 164 | Q
|
---|
| 165 | RXC ; IV
|
---|
| 166 | D RXC^PSJHL4A
|
---|
| 167 | Q
|
---|
| 168 | RXO ; OP
|
---|
| 169 | D RXO^PSJHL4A
|
---|
| 170 | Q
|
---|
| 171 | RXR ; Route
|
---|
| 172 | S ROUTE=$P(FIELD(1),"^",4)
|
---|
| 173 | Q
|
---|
| 174 | OBX ; Obs.
|
---|
| 175 | D OBX^PSJHL4A
|
---|
| 176 | Q
|
---|
| 177 | NTE ; Note
|
---|
| 178 | D NTE^PSJHL4A
|
---|
| 179 | Q
|
---|
| 180 | ZRX ; Custom
|
---|
| 181 | D ZRX^PSJHL4A
|
---|
| 182 | Q
|
---|
| 183 | ZSC ;Service Connected - Not Used
|
---|
| 184 | Q
|
---|
| 185 | ZRN ;Non-VA Med (Herbal/OTC)
|
---|
| 186 | S CLASS="O" D EN^PSOHLNEW(.PSJMSG)
|
---|
| 187 | Q
|
---|
| 188 | DG1 ;Billing Awareness - Not used
|
---|
| 189 | Q
|
---|