1 | LRPXSXRA ; SLC/PKR - Build indexes for Lab Anatomic Path. ;10/9/03 14:24
|
---|
2 | ;;5.2;LAB SERVICE;**295**;Sep 27, 1994
|
---|
3 | Q
|
---|
4 | ;===============================================================
|
---|
5 | AP ; from LRPXSXRL
|
---|
6 | ;Build the indexes for LAB DATA - ANATOMIC PATHOLOGY.
|
---|
7 | N ANUMS,DATE,DFN,END,ENTRIES,ETIOL,GLOBAL,I,II,III,ICD,ICDX,IND,ITEM
|
---|
8 | N LRDFN,ORGAN,NE,NERROR,NODE,SNOMED,SPEC,START,SUB,SUBS,TEMP,TENP,TEXT
|
---|
9 | K ANUMS
|
---|
10 | ;Dont leave any old stuff around.
|
---|
11 | S GLOBAL=$$GET1^DID(63,"","","GLOBAL NAME")_"""AP"")"
|
---|
12 | S ENTRIES=$P(^LR(0),U,4)
|
---|
13 | S TENP=ENTRIES/10
|
---|
14 | S TENP=+$P(TENP,".",1)
|
---|
15 | I TENP<1 S TENP=1
|
---|
16 | D BMES^XPDUTL("Building indexes for LAB DATA - ANATOMIC PATH")
|
---|
17 | S TEXT="There are "_ENTRIES_" entries to process."
|
---|
18 | D MES^XPDUTL(TEXT)
|
---|
19 | S START=$H
|
---|
20 | S (IND,NE,NERROR)=0
|
---|
21 | D AANUMS^LRPXSXRB(.ANUMS)
|
---|
22 | S LRDFN=.9
|
---|
23 | F S LRDFN=$O(^LR(LRDFN)) Q:LRDFN<1 D
|
---|
24 | . S TEMP=$G(^LR(LRDFN,0))
|
---|
25 | . I $P(TEMP,U,2)'=2 Q
|
---|
26 | . S DFN=+$P(TEMP,U,3)
|
---|
27 | . I LRDFN'=$$LRDFN^LRPXAPIU(DFN) Q
|
---|
28 | . S IND=IND+1
|
---|
29 | . I IND#TENP=0 D
|
---|
30 | .. S TEXT="Processing entry "_IND
|
---|
31 | .. D MES^XPDUTL(TEXT)
|
---|
32 | . D CYEMSP(LRDFN,DFN,.ANUMS) ; cytology, electron microscopy, sugrical path
|
---|
33 | . S DATE=$$DOD^LRPXAPIU(DFN) I 'DATE Q ; date of death
|
---|
34 | . I '+$G(^LR(LRDFN,"AU")) Q ; date of autopsy
|
---|
35 | . I '($P(^LR(LRDFN,"AU"),U,3)&($P(^("AU"),U,15))) Q ; autopsy comp/released
|
---|
36 | . S SPEC=0
|
---|
37 | . F S SPEC=$O(^LR(LRDFN,33,SPEC)) Q:SPEC<1 D
|
---|
38 | .. I '$L($P($G(^LR(LRDFN,33,SPEC,0)),U)) Q
|
---|
39 | .. S ITEM="A;S;1."_$$UP($P(^LR(LRDFN,33,SPEC,0),U))
|
---|
40 | .. S NODE=LRDFN_";33;"_SPEC_";0"
|
---|
41 | .. D APSET(DFN,ITEM,DATE,NODE)
|
---|
42 | . S ICD=0
|
---|
43 | . F S ICD=$O(^LR(LRDFN,80,ICD)) Q:ICD<1 D
|
---|
44 | .. S ICDX=+$G(^LR(LRDFN,80,ICD,0))
|
---|
45 | .. I 'ICDX Q
|
---|
46 | .. S ITEM="A;I;"_ICDX
|
---|
47 | .. S NODE=LRDFN_";80;"_ICD_";0"
|
---|
48 | .. D APSET(DFN,ITEM,DATE,NODE)
|
---|
49 | . S I=0
|
---|
50 | . F S I=$O(^LR(LRDFN,"AY",I)) Q:I<1 D
|
---|
51 | .. S ORGAN=+$G(^LR(LRDFN,"AY",I,0))
|
---|
52 | .. I 'ORGAN Q
|
---|
53 | .. S ITEM="A;O;"_ORGAN
|
---|
54 | .. S NODE=LRDFN_";AY;"_I_";0"
|
---|
55 | .. D APSET(DFN,ITEM,DATE,NODE)
|
---|
56 | .. F SUBS="1D","2M","3F","4P" D
|
---|
57 | ... S SUB=+SUBS
|
---|
58 | ... S II=0
|
---|
59 | ... F S II=$O(^LR(LRDFN,"AY",I,SUB,II)) Q:II<1 D
|
---|
60 | .... S SNOMED=+$G(^LR(LRDFN,"AY",I,SUB,II,0))
|
---|
61 | .... I 'SNOMED Q
|
---|
62 | .... S ITEM="A;"_$E(SUBS,2)_";"_SNOMED
|
---|
63 | .... S NODE=LRDFN_";AY;"_I_";"_SUB_";"_II_";0"
|
---|
64 | .... D APSET(DFN,ITEM,DATE,NODE)
|
---|
65 | .... I SUB'=2 Q
|
---|
66 | .... S III=0
|
---|
67 | .... F S III=$O(^LR(LRDFN,"AY",I,SUB,II,1,III)) Q:III<1 D
|
---|
68 | ..... S ETIOL=+$G(^LR(LRDFN,"AY",I,SUB,II,1,III,0))
|
---|
69 | ..... I 'ETIOL Q
|
---|
70 | ..... S ITEM="A;E;"_ETIOL
|
---|
71 | ..... S NODE=LRDFN_";AY;"_I_";"_SUB_";"_II_";1;"_III_";0"
|
---|
72 | ..... D APSET(DFN,ITEM,DATE,NODE)
|
---|
73 | S TEXT=NE_" LAB DATA (AP) results indexed."
|
---|
74 | D MES^XPDUTL(TEXT)
|
---|
75 | S END=$H
|
---|
76 | D DETIME^PXRMSXRM(START,END) ; dbia 4113
|
---|
77 | ;If there were errors send a message.
|
---|
78 | I NERROR>0 D ERRMSG^PXRMSXRM(NERROR,GLOBAL) ; dbia 4113
|
---|
79 | ;Send a MailMan message with the results.
|
---|
80 | D COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR) ; dbia 4113
|
---|
81 | Q
|
---|
82 | ;
|
---|
83 | CYEMSP(LRDFN,DFN,ANUMS) ;
|
---|
84 | N ACC,APSUB,DATE,ERR,I,ICD,ICDX,ITEM,LRIDT,NODE,ORGAN,PREP,SPEC
|
---|
85 | N TEST,TESTS K TESTS
|
---|
86 | F APSUB="CY","EM","SP" D
|
---|
87 | . I '$D(^LR(LRDFN,APSUB,0)) Q
|
---|
88 | . S LRIDT=0
|
---|
89 | . F S LRIDT=$O(^LR(LRDFN,APSUB,LRIDT)) Q:LRIDT<1 D
|
---|
90 | .. S DATE=+$G(^LR(LRDFN,APSUB,LRIDT,0))
|
---|
91 | .. I 'DATE Q
|
---|
92 | .. S DATE=9999999-LRIDT ; use for multiple entries on a date
|
---|
93 | .. I '($P(^LR(LRDFN,APSUB,LRIDT,0),U,3)&($P(^(0),U,11))) Q
|
---|
94 | .. S SPEC=0
|
---|
95 | .. F S SPEC=$O(^LR(LRDFN,APSUB,LRIDT,.1,SPEC)) Q:SPEC<1 D
|
---|
96 | ... I '$L($P($G(^LR(LRDFN,APSUB,LRIDT,.1,SPEC,0)),U)) Q
|
---|
97 | ... S ITEM="A;S;1."_$$UP($P(^LR(LRDFN,APSUB,LRIDT,.1,SPEC,0),U))
|
---|
98 | ... S NODE=LRDFN_";"_APSUB_";"_LRIDT_";.1;"_SPEC_";0"
|
---|
99 | ... D APSET(DFN,ITEM,DATE,NODE)
|
---|
100 | ... S PREP=0
|
---|
101 | ... F S PREP=$O(^LR(LRDFN,APSUB,LRIDT,.1,SPEC,1,PREP)) Q:PREP<1 D
|
---|
102 | .... S TEST=0
|
---|
103 | .... F S TEST=$O(^LR(LRDFN,APSUB,LRIDT,.1,SPEC,1,PREP,1,TEST)) Q:TEST<1 D
|
---|
104 | ..... S TEST=+$G(^LR(LRDFN,APSUB,LRIDT,.1,SPEC,1,PREP,1,TEST,0))
|
---|
105 | ..... I 'TEST Q
|
---|
106 | ..... S ITEM="A;T;"_TEST
|
---|
107 | ..... S NODE=LRDFN_";"_APSUB_";"_LRIDT_";.1;"_SPEC_";1;"_PREP_";1;"_TEST_";0"
|
---|
108 | ..... D APSET(DFN,ITEM,DATE,NODE)
|
---|
109 | .. ; S ACC=$P(^LR(LRDFN,APSUB,LRIDT,0),U,6) ; do not use tests from acc
|
---|
110 | .. ; I $L(ACC) D
|
---|
111 | .. ; . S NODE=LRDFN_";"_APSUB_";"_LRIDT_";0"
|
---|
112 | .. ; . D ACC^LRPXSXRB(.TESTS,ACC,DATE,.ANUMS,.ERR)
|
---|
113 | .. ; . I 'ERR D
|
---|
114 | .. ; .. S TEST=0
|
---|
115 | .. ; .. F S TEST=$O(TESTS(TEST)) Q:TEST<1 D
|
---|
116 | .. ; ... S ITEM="A;T;"_TEST
|
---|
117 | .. ; ... D APSET(DFN,ITEM,DATE,NODE)
|
---|
118 | .. S ICD=0
|
---|
119 | .. F S ICD=$O(^LR(LRDFN,APSUB,LRIDT,3,ICD)) Q:ICD<1 D
|
---|
120 | ... S ICDX=+$G(^LR(LRDFN,APSUB,LRIDT,3,ICD,0))
|
---|
121 | ... I 'ICDX Q
|
---|
122 | ... S ITEM="A;I;"_ICDX
|
---|
123 | ... S NODE=LRDFN_";"_APSUB_";"_LRIDT_";3;"_ICD_";0"
|
---|
124 | ... D APSET(DFN,ITEM,DATE,NODE)
|
---|
125 | .. S I=0
|
---|
126 | .. F S I=$O(^LR(LRDFN,APSUB,LRIDT,2,I)) Q:I<1 D
|
---|
127 | ... S ORGAN=+$G(^LR(LRDFN,APSUB,LRIDT,2,I,0))
|
---|
128 | ... I 'ORGAN Q
|
---|
129 | ... S ITEM="A;O;"_ORGAN
|
---|
130 | ... S NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";0"
|
---|
131 | ... D APSET(DFN,ITEM,DATE,NODE)
|
---|
132 | ... D SNOMED(LRDFN,DFN,LRIDT,DATE,APSUB,I)
|
---|
133 | Q
|
---|
134 | ;
|
---|
135 | SNOMED(LRDFN,DFN,LRIDT,DATE,APSUB,I) ;
|
---|
136 | N ETIOL,II,III,ITEM,NODE,SNOMED,SUB,SUBS
|
---|
137 | F SUBS="1D","2M","3F","4P" D
|
---|
138 | . S SUB=+SUBS
|
---|
139 | . S II=0
|
---|
140 | . F S II=$O(^LR(LRDFN,APSUB,LRIDT,2,I,SUB,II)) Q:II<1 D
|
---|
141 | .. S SNOMED=+$G(^LR(LRDFN,APSUB,LRIDT,2,I,SUB,II,0))
|
---|
142 | .. I 'SNOMED Q
|
---|
143 | .. S ITEM="A;"_$E(SUBS,2)_";"_SNOMED
|
---|
144 | .. S NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";"_SUB_";"_II_";0"
|
---|
145 | .. D APSET(DFN,ITEM,DATE,NODE)
|
---|
146 | .. I SUB'=2 Q
|
---|
147 | .. S III=0
|
---|
148 | .. F S III=$O(^LR(LRDFN,APSUB,LRIDT,2,I,SUB,II,1,III)) Q:III<1 D
|
---|
149 | ... S ETIOL=+$G(^LR(LRDFN,APSUB,LRIDT,2,I,SUB,II,1,III,0))
|
---|
150 | ... I 'ETIOL Q
|
---|
151 | ... S ITEM="A;E;"_ETIOL
|
---|
152 | ... S NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";"_SUB_";"_II_";1;"_III_";0"
|
---|
153 | ... D APSET(DFN,ITEM,DATE,NODE)
|
---|
154 | Q
|
---|
155 | ;
|
---|
156 | UP(X) Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
---|
157 | ;
|
---|
158 | APSET(DFN,ITEM,DATE,NODE) ;
|
---|
159 | I '$P(ITEM,";",3) D
|
---|
160 | . N ETEXT
|
---|
161 | . S ETEXT=NODE_" missing test"
|
---|
162 | . D ADDERROR^PXRMSXRM("LR(AP",ETEXT,.NERROR) ; dbia 4113
|
---|
163 | E D
|
---|
164 | . D SLAB^LRPX(DFN,DATE,ITEM,NODE)
|
---|
165 | . S NE=NE+1
|
---|
166 | Q
|
---|
167 | ;
|
---|