source: FOIAVistA/trunk/r/LAB_SERVICE-LR-LS/LRVER1.m@ 1334

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

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1LRVER1 ;DALOI/FHS/JAH - LAB ROUTINE DATA VERIFICATION ;8/10/04
2 ;;5.2;LAB SERVICE;**42,153,201,215,239,240,263,232,286,291**;Sep 27, 1994
3 ;
4VER ; from LRGVP
5 N LRBEY
6 S LRLLOC=0,LRCW=8,LROUTINE=$P(^LAB(69.9,1,3),U,2) I $D(^LRO(69,LRODT,1,LRSN,0)) S LRLLOC=$P(^(0),U,7) S:'$L(LRLLOC) LRLLOC=0 W !,$P(^LRO(69,LRODT,1,LRSN,1),U,6)
7 S LRCDT=$S($D(^LRO(68,LRAA,1,LRAD,1,LRAN,3)):$P(^(3),U,1,2),1:$P(^(0),U,3)_U),LREAL=$P(LRCDT,U,2)
8 S LRCDT=+LRCDT,LRSAMP=$S($D(^LRO(69,LRODT,1,LRSN,0)):$P(^(0),U,3),1:"")
9 S LRIDT=$S($P($G(^LRO(68,LRAA,1,LRAD,1,LRAN,3)),U,5):$P(^(3),U,5),1:"")
10 S:'LRIDT LRIDT=9999999-LRCDT
11 D EXP
12LD S LRSS="CH" ;ONLY WORKS FOR 'CH'
13 S LRMETH=LRSS IF $D(^LR(LRDFN,LRSS,LRIDT,0)) S LRMETH=$P($P(^(0),U,8),";",1)
14 W:$D(^LAB(62,+LRSAMP,0)) !,"Sample: ",$P(^(0),U)
15 K ^TMP("LR",$J,"TMP"),LRORD,LRM
16 D ^LRVER2
17 K LRDL
18 Q
19 ;
20 ;
21EXP ; Get the list of tests for this ACC. from LRGVG1
22 ; Do not process tests which have been "NP" (not performed).
23 N I,N,IX,LRNLT,T1,X
24 K LRTEST,LRNAME,LRSM60
25 S LRALERT=LROUTINE,N=0,I=0,IX=+$G(^LRO(68,LRAA,1,LRAD,1,LRAN,5,1,0))
26 F S I=$O(^LRO(68,LRAA,1,LRAD,1,LRAN,4,I)) Q:I<.5 D
27 . S X=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,4,I,0))
28 . I 'X Q
29 . I $P(X,"^",6)="*Not Performed" Q
30 . S N=N+1,LRTEST(N)=I,LRNLT=$S($P(X,"^",2)>50:$P(X,U,9),1:$P(X,"^"))
31 . S LRTEST(N,"P")=LRNLT_U_$$NLT(LRNLT)
32 . S LRAL=$P(X,U,2)#50
33 . I LRAL S LRALERT=$S(LRAL<LRALERT:LRAL,1:LRALERT)
34 ;
35 S LRNTN=N
36 F T1=1:1:N I $D(^LAB(60,+LRTEST(T1),0)) D
37 . S LRTEST(T1)=LRTEST(T1)_U_^(0)
38 . S LRNAME(T1)=$P(LRTEST(T1),U,2),LRNAME(T1,+LRTEST(T1))=""
39 . S:$G(^(1,IX,3)) LRSM60(+$P(LRTEST(T1),";",2))=^(3)
40 . D EX1
41 K IX
42 N X1,X
43 S X=$P($H,","),X(1)=$P($H,",",2),I=0
44 F S I=$O(LRSM60(I)) Q:'I S X1=X-LRSM60(I)_","_X(1),LRSM60(I)=9999999-$$HTFM^XLFDT(X1)
45 Q
46 ;
47 ;
48EX1 ; Expand the list of tests to edit.
49 Q:'$D(LRTEST(T1))
50 S X=LRTEST(T1),^TMP("LR",$J,"VTO",+X)=$P($P(X,U,6),";",2)
51 S ^TMP("LR",$J,"VTO",+X,"P")=LRTEST(T1,"P"),S1=0,J=0
52 D EX2
53 K S1,J
54 Q
55 ;
56EX2 ;
57 S:'$D(LRCFL) LRCFL=""
58 S LRSUB=$P(X,U,6)
59 I $D(^LAB(60,+X,4)),$P(^(4),"^",2) S LRCFL=LRCFL_$P(^(4),"^",2)_U
60 ;
61 ; If atomic test then setup and quit
62 I LRSUB'="" D Q
63 . S S2=$P(LRSUB,";",2)
64 . D:'$D(^TMP("LR",$J,"TMP",S2)) ORD
65 ;
66 ; Explode panel tests
67 ; Do not process tests which have been "NP" (not performed).
68 S S1=S1+1,S1(S1)=X,S1(S1,1)=J
69 S J=0
70 F S J=$O(^LAB(60,+S1(S1),2,J)) Q:J<1 D
71 . S Y=+^(J,0),X=Y_U_^LAB(60,Y,0)
72 . I $P($G(^LRO(68,+$G(LRAA),1,+$G(LRAD),1,+$G(LRAN),4,Y,0)),"^",6)="*Not Performed" Q
73 . D EX2
74 S X=S1(S1),J=S1(S1,1),S1=S1-1
75 Q
76 ;
77 ;
78ORD ;
79 ; LRNX is set by caller
80 S LRNX=+$G(LRNX)+1,LRORD(LRNX)=S2
81 S LRBEY($P(LRTEST(T1),U,1),S2)="" ; CIDC
82 S ^TMP("LR",$J,"TMP",S2)=+X
83 ; If panel being exploded then set parent("P" node)
84 ; to file #60 test being exploded
85 I $G(LRTEST(T1,"P")) D
86 . I +LRTEST(T1)=+LRTEST(T1,"P") S ^TMP("LR",$J,"TMP",S2,"P")=LRTEST(T1,"P")_"!"_$$RNLT(+X)
87 . E S ^TMP("LR",$J,"TMP",S2,"P")=+LRTEST(T1)_U_$$NLT(+LRTEST(T1))_"!"_$$RNLT(+X)
88 ;
89 I $P(X,U,18) D
90 . S LRM(S2)=+X
91 . S LRM(S2,"P")=$G(^TMP("LR",$J,"TMP",S2,"P"))
92 . S LRMX(+X)=""
93 Q
94 ;
95 ;
96NLT(X) ;
97 N Y
98 S Y=$S($P($G(^LAM(+$G(^LAB(60,+X,64)),0)),U,2):$P(^(0),U,2),1:"")
99 Q Y
100 ;
101 ;
102RNLT(X) ;
103 I 'X Q ""
104 N Y
105 S Y(1)=+$P($G(^LAB(60,X,64)),U,2)
106 S Y=$S($P($G(^LAM(Y(1),0)),U,2):$P(^(0),U,2),1:"")
107 I Y S $P(Y,"!",2)=$$LNC(Y,$G(LRCDEF),$G(LRSPEC))
108 S $P(Y,"!",3)=$G(LRCDEF),$P(Y,"!",6)=X
109 Q Y
110 ;
111 ;
112LNC(LRNLT,LRCDEF,LRSPEC) ;reture the LOINC code for WKLD Code/Specimen
113 ; Call with (nlt code,method suffix,test specimen)
114 ; TA = Time Aspect
115 N X,N,Y,LRSPECN,VAL,ERR,TA S X=""
116 Q:'LRNLT X
117 K LRMSGM
118 S:$G(LRCDEF)="" LRCDEF="0000"
119 I $P(LRCDEF,".",2) S LRCDEF=$P(LRCDEF,".",2)
120 S LRCDEF=$S($P(LRNLT,".",2):$P(LRNLT,".",2),1:LRCDEF)
121 I $L(LRCDEF)'=4 S LRCDEF=LRCDEF_$E("0000",$L(LRCDEF),($L(LRCDEF-4)))
122 S LRCDEF=LRCDEF_" "
123 S LRSPEC=+LRSPEC
124 ;Get time aspect from 61
125 S TA=$$GET1^DIQ(61,LRSPEC_",",.0961,"I")
126 S LRSPECN=$S($D(^LAB(61,LRSPEC,0))#2:$$GET1^DIQ(61,LRSPEC_",",.01),1:"Unknown")
127 S LRNLT=$P(LRNLT,".")_"."
128 ;Check for WKLD CODE_LOAD/WORK LIST method suffix
129 S VAL(1)=LRNLT_LRCDEF
130 S N=$$FIND1^DIC(64,"","X",.VAL,"C","","ERR")
131 ;Looking for specimen specific LOINC
132 I N,LRSPEC D I X D MSG(1) Q X
133 . I TA S X=$$GET1^DIQ(64.02,TA_","_LRSPEC_","_N_",",4,"I") Q:X
134 . S TA=$O(^LAM(N,5,LRSPEC,1,0)) ; get time aspect
135 . I TA S X=$$GET1^DIQ(64.02,TA_","_LRSPEC_","_N_",",4,"I") Q:X
136 ;Looking LOINC default
137 I N S X=$$LDEF(N) I X D MSG(2) Q X
138 I LRCDEF="0000 " Q ""
139 ;Looking for WKLD CODE_GENERIC suffix
140 K VAL
141 S VAL(1)=LRNLT_"0000 "
142 S N=$$FIND1^DIC(64,"","X",.VAL,"C","","ERR")
143 I 'N Q ""
144 ;Looking for WKLD CODE_GENERIC specimen specific LOINC
145 I LRSPEC D I X D MSG(3) Q X
146 . I TA S X=$$GET1^DIQ(64.02,TA_","_LRSPEC_","_N_",",4,"I") Q:X
147 . S TA=$O(^LAM(N,5,LRSPEC,1,0)) ; get time aspect
148 . I TA S X=$$GET1^DIQ(64.02,TA_","_LRSPEC_","_N_",",4,"I") Q:X
149 ;Looking for WKLD CODE_GENERIC default LOINC
150 I 'X,N S X=$$LDEF(N) I X D MSG(4)
151 I 'X S X=""
152 Q X
153 ;
154 ;
155LDEF(Y) ;Find the default LOINC code for WKLD CODE
156 I 'Y Q ""
157 S X=$$GET1^DIQ(64,Y_",",25,"I")
158 I 'X S X=""
159 Q X
160 ;
161 ;
162TMPSB(LRSB) ; Get LOINC code from ^TMP("LR",$J,"TMP",LRSB,"P")
163 S NODE=$G(^TMP("LR",$J,"TMP",LRSB,"P"))
164 I 'NODE Q ""
165 S $P(NODE,"!",3)=$$LNC($P(NODE,"!",2),$G(LRCDEF),$G(LRSPEC))
166 S $P(NODE,"!",4)=$G(LRCDEF)
167 Q $P(NODE,U,2)
168 ;
169 ;
170MSG(VAL) ;Set output message
171 Q:'$G(LRMSG)
172 S LRMSGM="0-No LOINC Code Defined for "_LRNLT_LRCDEF
173 N TANAME
174 I $G(TA) S TANAME=$$GET1^DIQ(64.061,TA_",",.01,"E") ;TA Name
175 I VAL=1 S LRMSGM="1-"_LRNLT_$E(LRCDEF,1,4)_" - "_LRSPECN
176 I VAL=2 S LRMSGM="2-"_LRNLT_$E(LRCDEF,1,4)_" - Default LOINC"
177 I VAL=3 S LRMSGM="3-"_LRNLT_"0000 - "_LRSPECN
178 I VAL=4 S LRMSGM="4-"_LRNLT_"0000 - Default LOINC"
179 I $G(TA) S LRMSGM=LRMSGM_" Time Aspect "_TANAME
180 W:$G(LRDBUG) !,LRMSGM,!
181 Q
Note: See TracBrowser for help on using the repository browser.