source: ccr/trunk/p/C0CLA7Q.m@ 434

Last change on this file since 434 was 434, checked in by George Lilly, 16 years ago

rollback of Lab for RPMS code

File size: 3.3 KB
Line 
1C0CLA7Q ;WV/JMC - CCD/CCR Lab HL7 Query Utility ;Apr 13, 2009
2 ;;n.n;;****;
3 ;
4 ;
5 Q
6 ;
7 ;
8LAB(C0CPTID,C0CSDT,C0CEDT,C0CSC,C0CSPEC,C0CERR,C0CDEST,C0CHL7) ; Entry point for Lab Result Query
9 ;
10 ;
11 K ^TMP("C0C-VLAB",$J)
12 ;
13 ; Check and retrieve lab results from LAB DATA file (#63)
14 D GCPR^LA7QRY($G(C0CPTID),$G(C0CSDT),$G(C0CEDT),.C0CSC,.C0CSPEC,.C0CERR,$G(C0CDEST),$G(C0CHL7))
15 ;
16 ; If V LAB file present then check for lab results that are only in this file
17 ; If results found in V Lab file then build results and add to above results.
18 I $D(^AUPNVLAB) D
19 . D VCHECK
20 . I $D(^TMP("C0C-VLAB",$J,3)) D VBUILD
21 ;
22 ;K ^TMP("C0C-VLAB",$J)
23 ;
24 Q C0CDEST
25 ;
26 ;
27VCHECK ; If V LAB file present then check for lab results that are only in this file.
28 ;
29 N C0CDA,C0CEND,C0CROOT,C0CVLAB,LA7PTID,LA7SCRC,LA7SPEC,TMP
30 ;
31 S LA7PTID=C0CPTID
32 D PATID^LA7QRY2
33 I $D(LA7ERR) Q
34 ;
35 ; Resolve search codes to lab datanames
36 S LA7SCSRC=$G(C0CSC)
37 S TMP=$$SCLIST^LA7QRY2(LA7SCSRC)
38 Q:$D(LA7ERR) ""
39 S LA7SC=TMP D:LA7SC'="*" CHKSC^LA7QRY1
40 ;
41 ; Convert specimen codes to file #61 Topography entries
42 S LA7SPEC=$G(C0CSPEC)
43 I LA7SPEC'="*" D SPEC^LA7QRY1
44 ;
45 S C0CROOT="^AUPNVLAB(""ALR4"",DFN,COCSDT)",C0CEND=0
46 ;
47 F S C0CROOT=$Q(@C0CROOT) Q:C0CROOT="" D Q:C0CEND
48 . I $QS(C0CROOT,1)'="ALR4"!($QS(C0CROOT,2)'=DFN) S C0CEND=1 Q ; Left x-ref or patient
49 . I $QS(C0CROOT,3)>C0CEDT S C0CEND=1 Q ; Exceeded end date/time
50 . S C0CDA=$QS(C0CROOT,6)
51 . I $D(^TMP("C0C-VLAB",$J,1,C0CDA)) Q ; Already checked during scan of file #63
52 . D VCHK1
53 ;
54 ;
55 Q
56 ;
57 ;
58VBUILD ; Build results found only in V LAB file into HL7 structure.
59 ;
60 ;
61 Q
62 ;
63 ;
64LNCHK ; Check for corresponding entry in V LAB file and related LOINC code for a result in file #63.
65 ; Call from LA7QRY2
66 ;
67 N DFN,C0C60,C0C63,C0CACC,C0CDA,C0CDT,C0CLN,X
68 ;
69 S DFN=$P(^LR(LRDFN,0),"^",3)
70 S C0C63(0)=^LR(LRDFN,LRSS,LRIDT,0)
71 S C0CDT=$P(C0C63(0),"^"),C0CACC=$P(C0C63(0),"^",6)
72 ;
73 ; ^AUPNVLAB("ALR1",5380,3080307.211055,"EKT 0307 48",188,5427202)=""
74 ;
75 S C0C60=0,C0CLN=""
76 F S C0C60=$O(^LAB(60,"C",LRSS_";"_LRSB_";1",C0C60)) Q:'C0C60 D Q:C0CLN'=""
77 . S C0CDA=$O(^AUPNVLAB("ALR1",DFN,C0CDT,C0CACC,C0C60,0))
78 . I C0CDA<1 Q
79 . S C0CLN=$P($G(^AUPNVLAB(C0CDA,11)),"^",13)
80 . S ^TMP("C0C-VLAB",$J,1,C0CDA)=""
81 . S ^TMP("C0C-VLAB",$J,2,LRDFN,LRSS,LRIDT,LRSB)=C0CLN_"^"_C0CDA
82 ;
83 ; If LOINC found then update variable with LN code
84 I C0CLN'="" D
85 . S X=$P(LA7X,"^",3)
86 . I $P(X,"!",3)="" S $P(X,"!",3)=C0CLN
87 . S $P(LA7X,"^",3)=X
88 ;
89 Q
90 ;
91 ;
92VCHK1 ; Check the entry in V Lab to determine if it meets criteria
93 ;
94 N C0CVLAB,I
95 ;
96 F I=0,12 S C0CVLAB(I)=^AUPNVLAB(C0CDA,I)
97 ;
98 ; JMC 04/13/09 - Store anything for now that meets date criteria.
99 D VSTORE
100 ;
101 Q
102 ;
103 ;
104VSTORE ; Store entry for building in HL7 message when parent is from V LAB file.
105 ;
106 N PARENT
107 ;
108 ; Determine parent test to use for OBR segment
109 S PARENT=$P(C0CVLAB(12),"^",8)
110 I PARENT="" S PARENT=$P(C0CVLAB(0),"^")
111 ;
112 ; patient ien
113 ; | collection date/time
114 ; | | parent test (ordered test)
115 ; | | | ien of entry in V LAB file
116 ; | | | |
117 S ^TMP("C0C-VLAB",$J,3,$P(C0CVLAB(0),"^",2),$P(C0CVLAB(12),"^"),PARENT,C0CDA)=""
118 ;
119 Q
Note: See TracBrowser for help on using the repository browser.