[433] | 1 | C0CLA7Q ;WV/JMC - CCD/CCR Lab HL7 Query Utility ;Apr 12, 2009
|
---|
| 2 | ;;5.2;;****;Sep 27, 1994
|
---|
| 3 | ;
|
---|
| 4 | ;
|
---|
| 5 | Q
|
---|
| 6 | ;
|
---|
| 7 | ;
|
---|
| 8 | LAB(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(C0CPTID,C0CSDT,C0CEDT,.C0CSC,.C0CSPEC,.C0CERR,C0CDEST,C0CHL7)
|
---|
| 15 | ;
|
---|
| 16 | ; If V LAB file present then check for lab results that are only in this file
|
---|
| 17 | I $D(^AUPNVLAB) D VCHECK
|
---|
| 18 | ;
|
---|
| 19 | ; If results found in V Lab file then build results and add to above results.
|
---|
| 20 | I $D(^TMP("C0C-VLAB",$J,3)) D VBUILD
|
---|
| 21 | ;
|
---|
| 22 | ;K ^TMP("C0C-VLAB",$J)
|
---|
| 23 | ;
|
---|
| 24 | Q C0CDEST
|
---|
| 25 | ;
|
---|
| 26 | ;
|
---|
| 27 | VCHECK ; 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 | ;
|
---|
| 58 | VBUILD ; Build results found only in V LAB file into HL7 structure.
|
---|
| 59 | ;
|
---|
| 60 | ;
|
---|
| 61 | Q
|
---|
| 62 | ;
|
---|
| 63 | ;
|
---|
| 64 | LNCHK ; 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 | . S $P(X,"!",3)=C0CLN
|
---|
| 87 | . S $P(LA7X,"^",3)=X
|
---|
| 88 | ;
|
---|
| 89 | Q
|
---|
| 90 | ;
|
---|
| 91 | ;
|
---|
| 92 | VCHK1 ; 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 | D VSTORE
|
---|
| 99 | ;
|
---|
| 100 | Q
|
---|
| 101 | ;
|
---|
| 102 | ;
|
---|
| 103 | VSTORE ; Store entry for building in HL7 message when parent is from V LAB file.
|
---|
| 104 | ;
|
---|
| 105 | S ^TMP("C0C-VLAB",$J,3,$P(C0CVLAB(12),"^"),$P(C0CVLAB,"^",2))=""
|
---|
| 106 | Q
|
---|