source: FOIAVistA/tag/r/AUTOMATED_LAB_INSTRUMENTS-LA/LA7DVM.m@ 628

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

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1LA7DVM ;SFCIOFO/MJM/DALOI/PWC - EXTRACTION ROUTINE FOR VERIFIED "MI" LAB RESULTS TO CAREVUE&LIFELOG;01/14/2000
2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**53,58,62**;Sep 27, 1994
3 ;
4 ; Reference to ^DPT( supported by DBIA #10035
5 ; Reference to ^%DTC supported by DBIA #10000
6 ; Reference to ^DIC supported by DBIA #10006
7 ; Reference to INIT^HLFNC2 supported by DBIA #2161
8 ; Reference to GENERATE^HLMA supported by DBIA #2164
9 ; Reference to DEM^VADPT supported by DBIA #10061
10 ; Reference to $$EN^VAFHLPID supported by DBIA #263
11 ; Reference to $$FMTHL7^XLFDT supported by DBIA #10103
12 ; Reference to ^XMD supported by DBIA #10070
13 ;
14EN ;ENTRY POINT FROM VERIFICATION PROCESS
15 N I
16 S DFN=$P(^LR(LRDFN,0),"^",3)
17 S GMTS1=9999999-LRIDT,GMTS2=9999999-LRIDT,VFLAG=1 D DEM^VADPT
18 D INIT,RR^LR7OR1(DFN,,GMTS1,GMTS2,"MI"),HL7
19 K ^TMP("LRRR",$J),DFN,EXPAND,NXREC,MAX,SEX
20 Q
21 ;
22INIT ;Set up needed variables
23 S NXREC=0,MAX=75,EXPAND=1,SEX=$P(VADM(5),"^",1)
24 Q
25 ;
26HL7 ; Build the HL7 message and send to the Ward.
27 K HL,HLA,HLP,HLRESLT ; Clean the enviroment
28 S DIC="^ORD(101,",DIC(0)="MNOZ",X="LA7D CARELIFE SERVER" D ^DIC
29 I Y=-1 S TEXT="Unable to send out test result to CAREVUE, Protocol Server is not setup" K Y,DIC D ERROR Q
30 S LA7DVEID=+Y ; Server Protocol IEN
31 K Y,DIC
32 D INIT^HLFNC2(LA7DVEID,.HL)
33 I $G(HL) S TEXT="Unable to send out test result to CAREVUE, Protocol Server is downed" D ERROR Q
34 N COUNT
35 S LA7DVTYP="LM",LA7DVFMT=1
36 S HLFS=$E(HL("FS")),Z=$E(HL("ECH"),1),COUNT=1,S=HLFS
37 S HLA("HLS",COUNT)=$$EN^VAFHLPID(DFN,"2,3,5,7,8,19")
38 S HOLD=COUNT+1 ; Hold the space for OBR segment
39 S COUNT=COUNT+2,LA7DVTXT=""
40 ; Start the NTE segment
41 F S LA7DVTXT=$O(^TMP("LRRR",$J,DFN,"MI",LRIDT,"N",LA7DVTXT)) Q:LA7DVTXT="" D
42 . S HLA("HLS",COUNT)="NTE"_HLFS_HLFS_"L"_HLFS_^TMP("LRRR",$J,DFN,"MI",LRIDT,"N",LA7DVTXT)
43 . S COUNT=COUNT+1
44 ; Start the OBX segment
45 S (OBX,LA7DVSCR)=""
46 F S OBX=$O(^TMP("LRRR",$J,DFN,"MI",LRIDT,OBX)) Q:+OBX=0 D
47 . S LA7DVOBX=^TMP("LRRR",$J,DFN,"MI",LRIDT,OBX)
48 . S LINE1="OBX"_HLFS_HLFS_"TX"_HLFS_"TX"_HLFS_HLFS_$P(LA7DVOBX,"^",2)_HLFS_HLFS
49 . S HLA("HLS",COUNT)=LINE1_HLFS_HLFS_HLFS_HLFS
50 . S COUNT=COUNT+1
51 . K LINE1
52 ; Start the OBR segment
53 S LA7DVTMP=0,LA7DVTMP=$O(^LR(LRDFN,"MI",LA7DVTMP)) ; Get the first entry of this collection
54 S SITE=$P(^LR(LRDFN,"MI",LA7DVTMP,0),"^",5),LA7DVSCR=$P(^LAB(61,SITE,0),"^",1)
55 ; change all $$HLDATE^HLFNC calls to $$FMTHL7^XLFDT pwc-10/6/2000
56 S LA7DVCOL=$$FMTHL7^XLFDT($P(^LR(LRDFN,"MI",LA7DVTMP,0),"^")) ; Get theCollection date/time
57 S LA7DVRCV=$$FMTHL7^XLFDT($P(^LR(LRDFN,"MI",LA7DVTMP,0),"^",10)) ; Get the Specimen Received Date/time
58 S LA7DVRCP=$$FMTHL7^XLFDT($P(^LR(LRDFN,"MI",LA7DVTMP,0),"^",3)) ; Get the Report Complete Date/time
59 S LA7DVACC=$P(^LR(LRDFN,"MI",LA7DVTMP,0),"^",6) ; Get the Accession #
60 S HLA("HLS",HOLD)="OBR"_HLFS_HLFS_HLFS_LA7DVACC_HLFS_"MI"
61 S $P(HLA("HLS",HOLD),HLFS,8)=LA7DVCOL
62 S $P(HLA("HLS",HOLD),HLFS,15,16)=LA7DVRCV_HLFS_LA7DVSCR
63 S $P(HLA("HLS",HOLD),HLFS,23,29)=LA7DVRCP_S_S_"LAB"_S_S_S_S_LA7DVL
64 S HLP("NAMESPACE")="LA"
65 D GENERATE^HLMA(LA7DVEID,LA7DVTYP,LA7DVFMT,.HLRESLT,"",.HLP)
66 I $P(HLRESLT,"^",2) D ERROR
67 K LA7DVRCP,LA7DVSCR,HOLD,LA7DVCOL,LA7DVACC,LA7DVTMP,LA7DVOBX,COUNT
68 K LA7DVTXT,LA7DVFMT,LA7DVEID,LA7DVTYP,OBX,GMTS1,GMTS2,HLFS,HLP,HLRESLT
69 K LA7DVRCV,LRSPEC,S,SITE,SPEC,TEXT,VADM,VAIN,VFLAG,XMDT
70 K XMDUZ,XMSUB,XMTEXT,XMY,Z
71 Q
72ERROR ; Send out error message when HL7 fail to build the message
73 D INP^VADPT
74 S XMSUB="ERROR IN SENDING LAB RESULTS TO "_$P(VAIN(4),"^",2)_" WARD"
75 D NOW^%DTC S XMDT=X K X
76 S XMDUZ=.5,XMY("G.CARELIFE RESULT ERROR")=""
77 S A(1)="There was an error in building an HL7 Lab Result Message for accession"
78 I LA7DVACC'="" D
79 . S A(2)=" # "_LA7DVACC_"of patient name: "_$P(^DPT(DFN,0),"^")_" at "_$P(VAIN(4),"^",2)_" Ward."
80 . S A(3)="The error was "_$P(HLRESLT,"^",3)_"."
81 E D
82 . S A(2)="The error was "_TEXT_"."
83 . S A(3)=""
84 S A(4)="Please make a note of it and take any actions that necessary"
85 S XMTEXT="A(" D ^XMD
86 K A
87 Q
Note: See TracBrowser for help on using the repository browser.