source: WorldVistAEHR/trunk/r/HEALTH_SUMMARY-GMTS/GMTSRAE.m@ 619

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

initial load of WorldVistAEHR

File size: 9.3 KB
Line 
1GMTSRAE ; SLC/JER,KER HIN/GJC Selected Radiology Extract ; 04/19/2002
2 ;;2.7;Health Summary;**14,25,30,37,40,47,49,51,84**;Oct 20, 1995;Build 6
3 ;
4 ; External References
5 ; DBIA 3125 ^RADPT( file 70
6 ; DBIA 501 ^RARPT( file 74, fields 5, 200, 300 and 400
7 ; DBIA 3417 ^RA(72, file 72, field 3 pending
8 ; DBIA 502 ^RAMIS(71, file 71, field 9
9 ; DBIA 10015 EN^DIQ1
10 ; DBIA 2056 $$GET1^DIQ (files 71, 72, and 74)
11 ; DBIA 2056 GETS^DIQ (file 70, subfile 70.03)
12 ; DBIA 1995 $$CPT^ICPTCOD
13 ; DBIA 10103 $$DT^XLFDT
14 ; DBIA 10104 $$UP^XLFSTR
15 ; DBIA 1996 $$MOD^ICPTMOD
16 ; DBIA 10011 ^DIWP
17 ;
18MAINSEL(MODE,TEST) ; Entry for Selection Items
19 N GMTSIDT,GMTSIDT2,GMTSCNT,GMTSPN,GMTSMAX K ^TMP("RAE",$J) S GMTSCNT=0,GMTSMAX=$S(+$G(GMTSNDM)>0:GMTSNDM,1:999)
20 S GMTSIDT=+GMTS1,GMTSIDT2=+($P(+GMTS2,".",1))_".999999"
21 S:+($G(GMTSPXGO))=0 GMTSIDT=$P(GMTS1,".",1),GMTSIDT2=$P(GMTS2,".",1)_".999999"
22 F S GMTSIDT=$O(^RADPT(DFN,"DT","AP",TEST,GMTSIDT)) Q:GMTSIDT'>0!(GMTSIDT>GMTSIDT2)!(GMTSCNT=GMTSMAX) D
23 . Q:'$D(^RADPT(DFN,"DT",GMTSIDT,0)) N GMTS7002,GMTSPSET,GMTSXSET
24 . S GMTS7002=$G(^RADPT(DFN,"DT",GMTSIDT,0))
25 . S GMTSXSET=+$P(GMTS7002,"^",5)
26 . S GMTSPN=0 F S GMTSPN=$O(^RADPT(DFN,"DT","AP",TEST,GMTSIDT,GMTSPN)) Q:GMTSPN'>0!(GMTSCNT=GMTSMAX) D
27 . . S GMTSCNT=GMTSCNT+1 D GET
28 Q
29MAIN(MODE) ; Main Entry
30 N GMTSIDT,GMTSCNT,GMTSPN,GMTSMAX
31 K ^TMP("RAE",$J) S GMTSCNT=0,GMTSMAX=$S(+$G(GMTSNDM)>0:GMTSNDM,1:999)
32 S GMTSIDT=+GMTS1,GMTSIDT2=+($P(+GMTS2,".",1))_".999999"
33 S:+($G(GMTSPXGO))=0 GMTSIDT=$P(GMTS1,".",1),GMTSIDT2=$P(GMTS2,".",1)_".999999"
34 F S GMTSIDT=$O(^RADPT(DFN,"DT",GMTSIDT)) Q:GMTSIDT'>0!(GMTSIDT>GMTSIDT2)!(GMTSCNT=GMTSMAX) D
35 . Q:'$D(^RADPT(DFN,"DT",GMTSIDT,0)) N GMTS7002,GMTSPSET,GMTSXSET
36 . S GMTS7002=$G(^RADPT(DFN,"DT",GMTSIDT,0))
37 . S GMTSXSET=+$P(GMTS7002,"^",5)
38 . S GMTSPN=0 F S GMTSPN=$O(^RADPT(DFN,"DT",GMTSIDT,"P",GMTSPN)) Q:GMTSPN'>0!(+GMTSCNT'<GMTSMAX) D
39 . . S GMTSCNT=GMTSCNT+1 D GET
40 Q
41 ;
42GET ; Gets data associated with study and sets global array
43 ; ^TMP("RAE",$J, where:
44 ;
45 ; GMTSIDT = inverse exam date/time
46 ; GMTSPN = Case IEN
47 ;
48 ; ^TMP("RAE",$J,GMTSIDT,GMTSPN,0)= <exam date> ^
49 ; <procedure> ^ <exam status> ^ <report status> ^
50 ; <prim interpret resident> ^ <prim interpret staff> ^
51 ; <CPT code> ^ <technologist> ^ <case number> ^
52 ; < exam status order >
53 ;
54 ; ^TMP("RAE",$J,GMTSIDT,"EXAMSET") Indicates if all
55 ; exams for this date/time are part of an exam set
56 ;
57 ; ^TMP("RAE",$J,GMTSIDT,"PRINTSET") Indicates if all
58 ; exams for this exam set share the same report
59 ;
60 ; Only if the report is verified -OR- released will
61 ; these nodes be set
62 ;
63 ; ^TMP("RAE",$J,IDT,PN,"D",seq #) = Dx codes
64 ; Sequence # = 1 Primary Dx
65 ; Sequence # > 1 Secondary Dx
66 ; ^TMP("RAE",$J,IDT,PN,"H",line #)= Clinical History line #
67 ; ^TMP("RAE",$J,IDT,PN,"S",line #)= Reason for Study line #
68 ; ^TMP("RAE",$J,IDT,PN,"I",line #)= Impression Text line #
69 ; ^TMP("RAE",$J,IDT,PN,"R",line #)= Report Text line #
70 ;
71 N DA,DIC,DIQ,%,D0,DIW,DIWI,DIWT,DIWTC,DIWX,DIWF,DIWL,DIWR,DN,DR
72 N I,J,Y,Z,GMTSCPT,GMTSED,GMTSCN,GMTSRP,GMTSRPI,GMTSST,GMTSPTR
73 N GMTSTA,GMTSTAI,GMTSI,GMTSRAD,GMTSRRAD,GMTSSRAD,GMTSTC,GMTSSTO
74 N GMTSIMGO,GMTSRA27 S GMTSRA27=$$PROK^GMTSU("RAUTL9",27)
75 S GMTSED=+$P(GMTS7002,"^")
76 S:GMTSXSET&('$D(^TMP("RAE",$J,GMTSIDT,"EXAMSET"))) ^TMP("RAE",$J,GMTSIDT,"EXAMSET")=""
77 ; Get
78 ; Exam Date $P($G(^RADPT(DFN,"DT",GMTSIDT,0)),"^",1)
79 ; Exam Set $P($G(^RADPT(DFN,"DT",GMTSIDT,0)),"^",5)
80 ; Case Number 70.03 .01 GMTSCN
81 ; Procedure 70.03 2 GMTSRP/GMTSRPI
82 ; Exam Status 70.03 3 GMTSST
83 ; Imaging Order 70.03 11 GMTSIMGO
84 ; Prim Interpret Resident 70.03 12 GMTSRRAD
85 ; Prim Diagnostic Code 70.03 13 GMTSDX
86 ; Prim Interpreting Staff 70.03 15 GMTSSRAD
87 ; Report Text 70.03 17
88 ; Member of Set 70.03 25
89 ; Exam Status Order 72 3 GMTSSTO
90 ;
91 S DIC="^RADPT("_DFN_",""DT"","_GMTSIDT_",""P"",",DA=GMTSPN,DIQ="GMTSRAD("
92 S DIQ(0)="IE",DR=".01;2;3;11;12;13;15;17;25" D TECH
93 D EN^DIQ1
94 S GMTSCN=$G(GMTSRAD(70.03,GMTSPN,.01,"E"))
95 S GMTSRP=$G(GMTSRAD(70.03,GMTSPN,2,"E"))
96 S GMTSRPI=$G(GMTSRAD(70.03,GMTSPN,2,"I"))
97 S GMTSST=$G(GMTSRAD(70.03,GMTSPN,3,"E"))
98 S GMTSSTO=$G(GMTSRAD(70.03,GMTSPN,3,"I"))
99 S GMTSSTO=$$GET1^DIQ(72,+GMTSSTO,3,"I")
100 S GMTSIMGO=$G(GMTSRAD(70.03,GMTSPN,11,"I")) ;Img Order # IEN
101 I GMTSTC S GMTSTC(0)=$E($G(GMTSRAD(70.12,GMTSTC,.01,"E")),1,18)
102 S GMTSRRAD=$E($G(GMTSRAD(70.03,GMTSPN,12,"E")),1,18)
103 S GMTSSRAD=$E($G(GMTSRAD(70.03,GMTSPN,15,"E")),1,18)
104 S GMTSPTR=$G(GMTSRAD(70.03,GMTSPN,17,"I"))
105 ; Exam Set/Report
106 ;
107 ; If GMTSPSET = "" single exam
108 ; If GMTSPSET = 1 exam set, single report
109 ; If GMTSPSET = 2 exam set, combined report
110 ;
111 S GMTSPSET=$G(GMTSRAD(70.03,GMTSPN,25,"I"))
112 D PMOD,CMOD I +GMTSPTR>0 S DIC="^RARPT(",DA=GMTSPTR,DIQ="GMTSRAD(",DIQ(0)="IE",DR="5" D EN^DIQ1
113 S GMTSTA=$G(GMTSRAD(74,+GMTSPTR,5,"E"))
114 S GMTSTAI=$G(GMTSRAD(74,+GMTSPTR,5,"I"))
115 I $L(GMTSTAI),("VR"[$E(GMTSTAI)) D GETDX(GMTSPN_","_GMTSIDT_","_DFN_",")
116 S GMTSCPT=$$GET1^DIQ(71,+GMTSRPI,9,"I")
117 S GMTSCPT=$S(+GMTSCPT>0:$P($$CPT^ICPTCOD(+GMTSCPT),"^",2),1:"")
118 S ^TMP("RAE",$J,GMTSIDT,GMTSPN,0)=GMTSED_U_GMTSRP_U_GMTSST_U_GMTSTA_U_GMTSRRAD_U_GMTSSRAD_U_GMTSCPT_U_$G(GMTSTC(0))_U_GMTSCN_U_$G(GMTSSTO)
119 S GMTSI=0 F S GMTSI=$O(GMTSRAD(70.1,GMTSI)) Q:+GMTSI'>0 D
120 . S ^TMP("RAE",$J,GMTSIDT,GMTSPN,"M",GMTSI)=$G(GMTSRAD(70.1,GMTSI,.01,"E"))
121 S GMTSI=0 F S GMTSI=$O(GMTSRAD(70.1,GMTSI)) Q:+GMTSI'>0 D
122 . S ^TMP("RAE",$J,GMTSIDT,GMTSPN,"M",GMTSI)=$G(GMTSRAD(70.1,GMTSI,.01,"E"))
123 S GMTSI=0 F S GMTSI=$O(GMTSRAD(70.3135,GMTSI)) Q:+GMTSI'>0 D
124 . Q:'$L($G(GMTSRAD(70.3135,GMTSI,.01,"M"))) Q:'$L($G(GMTSRAD(70.3135,GMTSI,.01,"N"))) N I S I=+($G(^TMP("RAE",$J,GMTSIDT,GMTSPN,"CM",0)))+1
125 . S ^TMP("RAE",$J,GMTSIDT,GMTSPN,"CM",I)=$G(GMTSRAD(70.3135,GMTSI,.01,"M"))_"^"_$$UP^XLFSTR($G(GMTSRAD(70.3135,GMTSI,.01,"N")))_"^"_$G(GMTSRAD(70.3135,GMTSI,.01,"N")),^TMP("RAE",$J,GMTSIDT,GMTSPN,"CM",0)=I
126 ; Only verified reports can be printed
127 I GMTSTAI'="V",($E(IOST)="P") D Q
128 . S:GMTSPSET=2 ^TMP("RAE",$J,GMTSIDT,"PRINTSET")=""
129 ; Only verified & Released/Unverified can viewed
130 I $S(GMTSTAI="V":0,GMTSTAI="R":0,1:1) D Q
131 . S:GMTSPSET=2 ^TMP("RAE",$J,GMTSIDT,"PRINTSET")=""
132 Q:$D(^TMP("RAE",$J,GMTSIDT,"PRINTSET"))
133 D GETIMP D:$G(MODE)=2 GETHIS^GMTSRAE1,GETR4S^GMTSRAE1,GETADD,GETREP
134 S:GMTSPSET=2 ^TMP("RAE",$J,GMTSIDT,"PRINTSET")=""
135 Q
136 ;
137GETIMP ; Gets Radiologist's Impression
138 N X,GMTSLN S X=$$GET1^DIQ(74,GMTSPTR,300,,"GMTST")
139 K ^UTILITY($J,"W") N X,GMTSI S GMTSI=0 F S GMTSI=$O(GMTST(GMTSI)) Q:+GMTSI=0 S X=$G(GMTST(GMTSI)) D FORMAT
140 I $D(^UTILITY($J,"W")) F GMTSLN=1:1:^UTILITY($J,"W",3) S ^TMP("RAE",$J,GMTSIDT,GMTSPN,"I",GMTSLN)=^UTILITY($J,"W",3,GMTSLN,0)
141 K ^UTILITY($J,"W"),GMTST
142 Q
143GETADD ; Gets Additional Clinical History (#74)
144 Q:+($G(GMTSRA27))'>0 N X,GMTSLN S X=$$GET1^DIQ(74,GMTSPTR,400,,"GMTST")
145 K ^UTILITY($J,"W") N X,GMTSI S GMTSI=0 F S GMTSI=$O(GMTST(GMTSI)) Q:+GMTSI=0 S X=$G(GMTST(GMTSI)) D FORMAT
146 I $D(^UTILITY($J,"W")) F GMTSLN=1:1:^UTILITY($J,"W",3) D
147 . S ^TMP("RAE",$J,GMTSIDT,GMTSPN,"A",GMTSLN)=^UTILITY($J,"W",3,GMTSLN,0)
148 K ^UTILITY($J,"W"),GMTST
149 Q
150GETREP ; Gets Radiologist's Report
151 N X,GMTSLN S X=$$GET1^DIQ(74,GMTSPTR,200,,"GMTST")
152 K ^UTILITY($J,"W") N X,I S GMTSI=0 F S GMTSI=$O(GMTST(GMTSI)) Q:+GMTSI=0 S X=$G(GMTST(GMTSI)) D FORMAT
153 I $D(^UTILITY($J,"W")) F GMTSLN=1:1:^UTILITY($J,"W",3) S ^TMP("RAE",$J,GMTSIDT,GMTSPN,"R",GMTSLN)=^UTILITY($J,"W",3,GMTSLN,0)
154 K ^UTILITY($J,"W"),GMTST
155 Q
156PMOD ; Procedure Modifiers
157 N GMTS,GMTSI S GMTS=$G(DIC) Q:'$L(DIC) S GMTSI=+($G(DA)) Q:+GMTSI=0
158 N DIC,DA,DR S DIC=GMTS_GMTSI_",""M"","
159 S DA=0 F S DA=$O(@(DIC_DA_")")) Q:+DA'>0 S DR=".01" D
160 . D EN^DIQ1
161 Q
162CMOD ; CPT Modifiers
163 N GMTS,GMTSI,GMTSC,GMTSCM,GMTSCN S GMTS=$G(DIC) Q:'$L(DIC) S GMTSI=+($G(DA)) Q:+GMTSI=0
164 S DT=$$DT^XLFDT,U="^" N DIC,DA,DR S DIC=GMTS_GMTSI_",""CMOD"","
165 S DA=0 F S DA=$O(@(DIC_DA_")")) Q:+DA'>0 S DR=".01" D EN^DIQ1
166 S GMTSI=0 F S GMTSI=$O(GMTSRAD(70.3135,GMTSI)) Q:+GMTSI=0 D
167 . S GMTSC=$G(GMTSRAD(70.3135,GMTSI,.01,"I")) Q:+GMTSC=0
168 . S GMTSCM=$$MOD^ICPTMOD(GMTSC,"I",)
169 . S GMTSCN=$P(GMTSCM,"^",3),GMTSCM=$P(GMTSCM,"^",2)
170 . S GMTSRAD(70.3135,GMTSI,.01,"M")=GMTSCM
171 . S GMTSRAD(70.3135,GMTSI,.01,"N")=$$EN2^GMTSUMX(GMTSCN)
172 Q
173TECH ; Technician
174 S GMTSTC=+$O(^RADPT(DFN,"DT",GMTSIDT,"P",GMTSPN,"TC",0))
175 I GMTSTC S DR=$G(DR)_";175",DR(70.12)=.01,DA(70.12)=GMTSTC F Q:$E(DR,1)'=";" S DR=$E(DR,2,$L(DR))
176 Q
177FORMAT ; Calls ^DIWP to format each line of text
178 N DIWL,DIWR,DIWF S DIWL=3,DIWR=($S(MODE=1:76,1:80))
179 D ^DIWP Q
180 ;
181GETDX(GMTSIEN) ; Set the data node with diagnostic code info.
182 ;
183 ; Input: GMTSIEN = Case IEN_","_exam date_","_DFN_","
184 ; Output: ^TMP("RAE",$J,GMTSIDT,GMTSPN,"D",seq #) = Dx codes
185 ;
186 ; Sequence # = 1 Primary Dx
187 ; Sequence # > 1 Secondary Dx
188 S ^TMP("RAE",$J,$P(GMTSIEN,",",2),$P(GMTSIEN,","),"D",1)=$G(GMTSRAD(70.03,$P(GMTSIEN,","),13,"E"))
189 N GMTSI,GMTSII,GMTSDX S GMTSI=1 D GETS^DIQ(70.03,GMTSIEN,"13.1*","E","GMTSDX")
190 S GMTSII="" F S GMTSII=$O(GMTSDX(70.14,GMTSII)) Q:GMTSII="" D
191 . S GMTSI=GMTSI+1 S ^TMP("RAE",$J,$P(GMTSIEN,",",2),$P(GMTSIEN,","),"D",GMTSI)=$G(GMTSDX(70.14,GMTSII,.01,"E"))
192 Q
Note: See TracBrowser for help on using the repository browser.