source: WorldVistAEHR/trunk/r/RADIOLOGY_NUCLEAR_MEDICINE-RA/RAO7UTL.m@ 1579

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

initial load of WorldVistAEHR

File size: 7.5 KB
Line 
1RAO7UTL ;HISC/GJC,SS-Utilities for HL7 messages. ;9/5/97 08:55
2 ;;5.0;Radiology/Nuclear Medicine;**18,45,57,82**;Mar 16, 1998;Build 8
3 ;modified by SS JUN 19,2000 for P18
4EN1 ; Entry point to define some basic HL7 variables
5 N I S RAHLFS="|",RAECH="^~\&"
6 S $P(RAHLFS(0),RAHLFS,51)=""
7 F I=1:1:$L(RAECH) S RAECH(I)=$E(RAECH,I)
8 Q
9 ;
10CMEDIA(IEN,RAPTYPE) ;Called from RAO7MFN when a procedure is updated
11 ;Input: IEN=ien of proc. in file 71
12 ; RAPTYPE=procedure type; broad, parent, series, or detailed.
13 ;Return: J=a string with some combination of the following indicators:
14 ;I for Iodinated ionic, N for Iodinated non-ionic, L for Gadolinium
15 ;C for Oral Cholecystographic, G for Gastrografin, B for Barium or
16 ;NULL if none of the indicators apply to this procedure.
17 ;
18 ;'Broad' procedures have no contrast media definition, return null
19 Q:RAPTYPE="B" ""
20 ;if 'detailed' or 'series' & no contrast media data return null
21 I RAPTYPE'="P",'($O(^RAMIS(71,IEN,"CM",0))) Q ""
22 NEW I,INA,J S J=""
23 I RAPTYPE="P" D
24 .S I=0 F S I=$O(^RAMIS(71,IEN,4,I)) Q:'I D
25 ..S I(0)=+$G(^RAMIS(71,IEN,4,I,0)) Q:'I(0)
26 ..S INA=$P($G(^RAMIS(71,I(0),"I")),"^")
27 ..S INA=$S(INA="":1,INA>DT:1,1:0)
28 ..D:INA NONPAR(I(0))
29 ..Q
30 .Q
31 E D NONPAR(IEN)
32 Q J
33 ;
34NONPAR(IEN) ;obtain contrast media data for a 'detailed' or 'series' proc
35 ; Input: IEN=ien of the non-parent, non-broad procedure
36 ;Return: J=data string (return)
37 ;variable definition: I=ien of sub-file rec
38 NEW H,I S I=0
39 F S I=$O(^RAMIS(71,IEN,"CM",I)) Q:I'>0 D
40 .S H=$P($G(^RAMIS(71,IEN,"CM",I,0)),U) Q:H=""
41 .S:J'[H J=J_H
42 .Q
43 Q
44 ;
45MSH(X) ; Set up the 'MSH' segment.
46 ; 'X' is passed in and identifies the message type.
47 S:X']"" X="Message Type Error"
48 Q "MSH"_RAHLFS_RAECH_RAHLFS_"RADIOLOGY"_RAHLFS_$P($G(^DIC(4,+$G(DUZ(2)),99)),"^")_$$STR(3)_$$HLDATE^HLFNC($$NOW^XLFDT(),"TS")_$$STR(2)_X
49 ;
50MSA(X,Y) ; Set up the 'MSA' segment. P18
51 ; 'X' is passed in and identifies the message ID.
52 ; 'Y' is acknowledgement code
53 S:X']"" X="Message ID Error"
54 Q "MSA"_RAHLFS_Y_RAHLFS_$E(X,1,20)_$$STR(4)
55MFI(X) ; Set up the 'MFI' segment
56 S @(RAVAR_RACNT_")")="MFI"_RAHLFS_RAFNUM
57 S @(RAVAR_RACNT_")")=@(RAVAR_RACNT_")")_RAECH(1)_RAFNAME_RAECH(1)
58 S @(RAVAR_RACNT_")")=@(RAVAR_RACNT_")")_"99DD"_RAHLFS_RAHLFS_X ;P18
59 S @(RAVAR_RACNT_")")=@(RAVAR_RACNT_")")_RAHLFS_RAHLFS_RAHLFS_"ER"
60 X RAINCR ; increment counter
61 Q
62PID(Y) ; Create 'pid' segment
63 Q "PID"_$$STR(3)_+$P(Y,"^")_$$STR(2)_$P($G(^DPT(+$P(Y,"^"),0)),"^")
64 ;
65PV1(Y) ; Create 'pv1' segment
66 ;Input: Y=zero node of the RAD/NUC MED ORDERS (#75.1) file
67 N DFN,RA,RARMBED,RAWARD,VAIP,RAPF
68 S DFN=+$P(Y,"^"),VAIP("D")=$P(Y,"^",21)
69 S RA("PV1",2)="O",RA("PV1",3)=+$P(Y,"^",22)
70 D IN5^VADPT S RAWARD=$G(VAIP(5)),RARMBED=$G(VAIP(6))
71 I RAWARD]"" D
72 . S RA("PV1",2)="I",RAWARD(44)=$P($G(^DIC(42,+RAWARD,44)),"^")
73 . S RA("PV1",3)=+RAWARD(44)_U_$P(RARMBED,"^",2)
74 . Q
75 S RAPF="PV1"_$$STR(2)_RA("PV1",2)_RAHLFS_RA("PV1",3)_$$STR(16) ;_"Visit #" was truncated for P18 ? Req 4
76 D PV1^RABWIBB
77 ; pv1^RABWIBB will redefine RAPF if the PFSS switch is on and there's a valid PFSS Account Reference
78 ; Otherwise, RAPF won't be changed
79 K RACCOUNT ; this variable was set earlier in FB^RABWIBB
80 Q RAPF
81 ;
82PURGE K RAHLFS,RACNT,RAECH,RAFNAME,RAFNUM,RAINCR,RASUB,RATSTMP,RAVAR,RAXIT
83PURGE1 ; kill only whole file update variables
84 K RA71,RA713,RACMCODE,RACMNOR,RACOST,RACPT,RAIEN71,RAIMGAB,RAMFE,RAMULT
85 K RAPHYAP,RAPRCTY,RAXT71
86 Q
87DIAG(X,Y,Z) ; Pass back an "A" if any Dx code has 'Yes' in the 'Generate
88 ; Abnormal Alert' field.
89 N A,AAH,RA7003,RA783 S AAH=""
90 S RA7003=$G(^RADPT(X,"DT",Y,"P",Z,0)),RA7003(13)=+$P(RA7003,"^",13)
91 S RA783(0)=$G(^RA(78.3,RA7003(13),0))
92 S RA783(4)=$$UP^XLFSTR($P(RA783(0),"^",4))
93 S:RA783(4)="Y" AAH="A"
94 Q:AAH]"" AAH
95 S A=0 F S A=$O(^RADPT(X,"DT",Y,"P",Z,"DX",A)) Q:A'>0 D Q:AAH]""
96 . S RA783=+$G(^RADPT(X,"DT",Y,"P",Z,"DX",A,0))
97 . S RA783(0)=$G(^RA(78.3,RA783,0))
98 . S RA783(4)=$$UP^XLFSTR($P(RA783(0),"^",4))
99 . I RA783(4)="Y" S AAH="A"
100 . Q
101 Q AAH
102PROCNDE(X) ; Check if the procedure has both an I-Type & Proc. Type
103 ; assigned. Pass back '1' if either the I-Type -or- Proc. Type
104 ; data is missing. '0' if everything is ok.
105 I $P(X(0),U,6)]"",($P(X(0),U,12)]"") Q 0
106 Q 1
107STR(X) ; Pass back a predetermined # of '|' or other field separator
108 Q:$G(RAHLFS(0))']""!(+X=0) "" ; Quit if parent string i.e, 'RAHLFS(0)'
109 ; does not exist or +X evaluates to null.
110 ;
111 S:X<0 X=$$ABS^XLFMTH(X) ; If passed in negative, take absolute
112 ; value. Quit if 'X' is greater than the
113 ; length of our parent string.
114 ;
115 S:X["." X=X\1 ; If a non-integer, remove mantissa.
116 ;
117 Q:X>($L(RAHLFS(0))) "" ; If parameter greater than length of
118 ; string, pass back null.
119 Q $E(RAHLFS(0),1,X)
120 ;
121CHKUSR(RADUZ) ; Check user status to 'DC' an order.
122 ; pass back '0' if non-active Rad/Nuc Med user
123 ; pass back '1' if active Rad/Nuc Med user
124 N RAINADT S RAINADT=+$P($G(^VA(200,RADUZ,"PS")),"^",4) ;inactivation DT
125 Q $S('($D(RADUZ)#2):0,'$D(^VA(200,RADUZ,0)):0,'$D(^("RAC")):0,'RAINADT:1,'$D(DT):0,DT'>RAINADT:1,1:0)
126 ;
127ERR(RATXT,RAMSG,RAVAR) ; Call CPRS utility to log 'soft' errors.
128 ; Input: RATXT-text description of the error
129 ; RAMSG-HL7 message array
130 ; RAVAR-variables to be saved off
131 D EN^ORERR(RATXT,.RAMSG,.RAVAR)
132 Q
133 ;
134MSG(RAPROTO,RAMSG) ; ship HL7 messages to CPRS from this entry point
135 ; input: RAPROTO - protocol to execute
136 ; RAMSG - message (in HL7 format)
137 D MSG^XQOR(RAPROTO,.RAMSG)
138 Q
139 ;
140UPDATP(RAY) ;update the parent procedure when a descendent is
141 ;updated. Called from RAMAIN2 (procedure entry/edit)
142 ;input: RAY=ien of desc.^name of desc. (if existing record)
143 ; RAY=ien of desc.^name of desc.^1 (if new record)
144 W !!,$P(RAY,U,2)_" is a descendent procedure, updating parent(s)..."
145 N RAPIEN,RAQUIT S (RAPIEN,RAQUIT)=0
146 F S RAPIEN=$O(^RAMIS(71,"ADESC",+RAY,RAPIEN)) Q:'RAPIEN D Q:RAQUIT
147 .S RAPIEN(0)=$G(^RAMIS(71,RAPIEN,0))
148 .W !?2,"Updating parent: "_$E($P(RAPIEN(0),U),1,50)
149 .S RAPIEN("I")=$P($G(^RAMIS(71,RAPIEN,"I")),"^")
150 .S RAPIEN("S")=$S(RAPIEN("I")="":1,RAPIEN("I")>DT:1,1:0)
151 .L +^RAMIS(71,RAPIEN):300
152 .I '$T S RAQUIT=1 D Q
153 ..W !?2,"Parent Procedure: "_$E($P(RAPIEN(0),U),1,50)
154 ..W !?2,"being edited by another user, try again later!",$C(7)
155 ..Q
156 .D PROC^RAO7MFN(0,71,RAPIEN("S")_"^"_RAPIEN("S"),RAPIEN)
157 .L -^RAMIS(71,RAPIEN)
158 .Q
159 Q
160 ;----------------------------
161 ;called from
162 ;-Case # edit START1+16^RAEDCN
163 ;-Edit by patient
164 ;-Tracking
165 ;Saves proc ien before editing, locate the exam by patient, datetime and caseN
166SVBEFOR(RAPATN,RAINVDT,RACIEN) ;P18;send radfn,radti,racni (instead of racn and new sequencing of params
167 ; RAPRIEN() holds "before" values
168 N RADATA,RAX,RA0,RA1,RA2,RA3
169 S RADATA=$G(^RADPT(RAPATN,"DT",RAINVDT,"P",RACIEN,0))
170 Q:RADATA="" ;failure
171 ; don't check parent here, since still need compare Req Phys & Proc Mods
172 S RAPRIEN=$P(RADATA,"^",2) ; procedure ien
173 S RAPRIEN(1)=RAPATN ; dfn
174 S RAPRIEN(2)=RAINVDT ; inverse date exm
175 S RAPRIEN(3)=RACIEN ; case ien
176 S RAPRIEN(4)=$P(RADATA,"^",14) ; req phy
177 D STR70^RAUTL10(.RAX,RAPATN,RAINVDT,RACIEN)
178 S RAPRIEN(5)=RAX ; string of proc mods
179 ; send "XX" if diffcs in Req.Phy &/or Proc Mods
180 ; Next lines are for RA*5*82
181 ; Save CPT modifiers before editing
182 S RAX=0 K RAPRIEN("CMOD")
183 F S RAX=$O(^RADPT(RAPATN,"DT",RAINVDT,"P",RACIEN,"CMOD",RAX)) Q:'RAX S RAPRIEN("CMOD",RAX)=+$G(^(RAX,0))
184 ; Save Tech comments before editing
185 S RAX=0 K RAPRIEN("TCOM")
186 F S RAX=$O(^RADPT(RAPATN,"DT",RAINVDT,"P",RACIEN,"L",RAX)) Q:'RAX S RAPRIEN("TCOM",RAX)=$G(^(RAX,"TCOM"))
187 Q ;OK
Note: See TracBrowser for help on using the repository browser.