source: FOIAVistA/trunk/r/AUTOMATED_MED_INFO_EXCHANGE-DVBA-DVBC/DVBCHLR.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1DVBCHLR ;ALB/JLU-Processes the results from the ORU ;1/28/93
2 ;;2.7;AMIE;**9**;Apr 10, 1995
3 ;
4BEG D INIT
5 F D @$S(DVBCX="PID"&'$D(HLERR):"PID",DVBCX="OBR"&'$D(HLERR):"OBR",DVBCX="OBX"&'$D(HLERR):"OBX",1:"ACK") Q:DVBCX="QUIT"
6 D EXIT
7 Q
8 ;
9EXIT K %,DA,DFN,DIE,DR,DVBC,HLERR,DVBCNT2,DVBCOBR,DVBCOBX,DVBCOBXV,DVBCPAT,DVBCPDFN,DVBCPID,DVBCRPDT,DVBCSAV,DVBCSSN,DVBCUEX,DVBCUEXT,DVBCUNIV,DVBCURQ,DVBCX,DVBCX1,DVBX,VADM,VAERR,DVBCEXAM,DVBCST,DVBCELCT,DVBCUEX1
10 Q
11 ;
12INIT ;initializes and checks variables
13 S DVBCX="PID",DVBC=1
14 I '$D(HLESIG) S HLERR="No Electronic Signature code present, updating cannot be allowed."
15 I $S('$D(HLDUZ):1,HLDUZ']"":1,1:0) S HLERR="Not a valid DHCP user number."
16 Q
17 ;
18PID ;Brake apart the PID section
19 K HLERR,DVBCPID,DVBCSSN,DVBCPDFN,DVBCPAT,DFN,VAERR,VADM
20 S DVBC=$O(^HL(772,HLDA,"IN",DVBC))
21 I 'DVBC S HLERR="Missing PID Segment" Q
22 S DVBCPID=^(DVBC,0) ;NAKE FROM ^HL(772,HLDA,IN PID+2
23 I $P(DVBCPID,HLFS,1)'="PID" S HLERR="Incorrect PID Segment indicator" Q
24 I $P(DVBCPID,HLFS,4)']"" S HLERR="Internal Patient ID Missing" Q
25 I $P(DVBCPID,HLFS,6)']"" S HLERR="Patient Name Invalid" Q
26 I $P(DVBCPID,HLFS,20)']"" S HLERR="Patient SSN Invalid" Q
27 S DVBCSSN=$P(DVBCPID,HLFS,20)
28 S DVBCPDFN=+$P(DVBCPID,HLFS,4)
29 S DVBCPAT=$$FMNAME^HLFNC($P(DVBCPID,HLFS,6))
30 S DFN=DVBCPDFN
31 D DEM^VADPT
32 I VAERR S HLERR="Incorrect Patient Identifier" Q
33 I DVBCSSN'=$P(VADM(2),U,1) S HLERR="Invalid SSN" Q
34 S DVBCX="OBR"
35 Q
36 ;
37OBR ;Parsing the OBR segment.
38 K DVBCOBR,DVBCUNIV
39 F S DVBC=$O(^HL(772,HLDA,"IN",DVBC)) Q:DVBC="" S DVBCOBR=^(DVBC,0) Q:$P(DVBCOBR,HLFS,1)="OBR"
40 I DVBC="" S HLERR="Missing OBR Segment" Q
41 I $P(DVBCOBR,HLFS,5)']"" S HLERR="Missing Universal Identifier" Q
42 I $P(DVBCOBR,HLFS,21)']"" S HLERR="Missing Exam Type" Q
43 I $P(DVBCOBR,HLFS,23)']"" S HLERR="Missing Report Date" Q
44 S DVBCUNIV=$P(DVBCOBR,HLFS,5)
45 S DVBCUEXT=$P(DVBCOBR,HLFS,21)
46 S DVBCRPDT=$$FMDATE^HLFNC($P(DVBCOBR,HLFS,23))
47 S DVBCURQ=$P(DVBCUNIV,$E(HLECH),1)
48 S DVBCUEX=$P(DVBCUNIV,$E(HLECH),2)
49 I '$D(^DVB(396.3,DVBCURQ,0)) S HLERR="Request No longer Exists" Q
50 I "PS"'[$P(^(0),U,18) S HLERR="Status of Request will not allow for down loading" Q ;NAKED FROM LINE BEFORE
51 I '$D(^DVB(396.4,DVBCUEX,0)) S HLERR="Exam No longer Exists" Q
52 S DVBCUEX1=^DVB(396.4,DVBCUEX,0)
53 I "RXT"[$P(DVBCUEX1,U,4) S HLERR="Exam status not open, no down loading allow* ed" Q
54 D HASH^DVBCHLUT
55 I '$D(DVBCELCT) S HLERR="Bad electronic signature code." Q
56 I $P(DVBCUEX1,U,4)="C",$P(DVBCUEX1,U,10)'=DVBCELCT S HLERR="Electronic signature codes do not match, no down loading allowed" Q
57 S DVBCX="OBX"
58 Q
59 ;
60OBX ;looping through the OBX segment
61 K DVBCSAV
62 S DVBCNT2=0,DVBCSAV=DVBC
63 I '$$LOCK^DVBCHLUT(DVBCURQ,DVBCUEX) Q
64 D DEL
65 F S DVBC=$O(^HL(772,HLDA,"IN",DVBC)) S:DVBC="" DVBCX="ACK" Q:DVBC="" S DVBCOBX=^(DVBC,0) D OBX1 Q:DVBCX'="OBX" S DVBCSAV=DVBC
66 S DVBC=DVBCSAV
67 I 'DVBCNT2 S HLERR="Invalid OBX Segment" D UNLOCK^DVBCHLUT(DVBCURQ,DVBCUEX) Q
68 I DVBCNT2 D CLOSE
69 D UNLOCK^DVBCHLUT(DVBCURQ,DVBCUEX)
70 Q
71 ;
72OBX1 ;
73 S DVBCOBXV=$P(DVBCOBX,HLFS,1)
74 I DVBCOBXV="NTE" Q
75 I $S(DVBCOBXV="PID":1,DVBCOBXV="OBR":1,1:0) S DVBCX=DVBCOBXV Q
76 I DVBCOBXV'="OBX" S DVBCX="ACK" Q
77 S DVBCNT2=DVBCNT2+1
78 S ^DVB(396.4,DVBCUEX,"RES",DVBCNT2,0)=$P(DVBCOBX,HLFS,6)
79 Q
80 ;
81CLOSE ;sets exam fields and quits
82 D NOW^%DTC
83 S ^DVB(396.4,DVBCUEX,"RES",0)="^^"_DVBCNT2_"^"_DVBCNT2_"^"_%
84 S DIE="^DVB(396.4,",DA=DVBCUEX
85 S DR=".04///C;.06///^S X=DVBCRPDT;.07///^S X=$P(^VA(200,HLDUZ,0),U,1);.1///^S X=DVBCELCT"
86 D ^DIE
87 S DVBCEXAM=^DVB(396.4,DVBCUEX,0)
88 I $P(DVBCEXAM,U,4)'="C"!($P(DVBCEXAM,U,6)']"")!$P(DVBCEXAM,U,7)']"" S HLERR="Results added but request and exam status not updated." Q
89 D COMPL
90 Q
91 ;
92ACK ;setting up the acknowledgment segment.
93 I $D(HLERR) S DVBCX1=HLSDATA(1) K HLSDATA S HLSDATA(1)=DVBCX1
94 S HLSDATA(2)="MSA"_HLFS_$S($D(HLERR):"AE",1:"AA")_HLFS_HLMID_HLFS_$S($D(HLERR):HLERR,1:"")
95 S DVBCX="QUIT"
96 I $D(HLTRANS) D EN1^HLTRANS
97 Q
98 ;
99COMPL ;This subroutine will search the other exams and set the request's
100 ;status to transcribed if able.
101 ;This should become a callable subroutine because ^dvbcedit does the same
102 ;
103 K DVBCOPN
104 F DVBC=0:0 S DVBC=$O(^DVB(396.4,"C",DVBCURQ,DVBC)) Q:'DVBC S DVBCST=$P(^DVB(396.4,DVBC,0),U,4) I DVBCST="O"!(DVBCST="T") S DVBCOPN=1 Q
105 Q:$D(DVBCOPN)
106 S XMDUZ="Kurzweil"
107 S XMB="DVBA C 2507 EXAM READY"
108 S XMB(1)=DVBCPAT,XMB(2)=DVBCSSN
109 S Y=$P(^DVB(396.3,DVBCURQ,0),U,2)
110 X ^DD("DD")
111 S XMB(3)=Y
112 D ^XMB
113 K XMDUZ,XMB,Y
114 S DIE="^DVB(396.3,",DA=DVBCURQ
115 S DR="11///NOW;17////T"
116 D ^DIE
117 I $P(^DVB(396.3,DVBCURQ,0),U,12)']""!($P(^(0),U,18)'="T") S HLERR="Results added and exam status updated but request status not updated."
118 Q
119 ;
120DEL ;to delete the results from an exam if it is being resent.
121 I $P(DVBCUEX1,U,10)]"" K ^DVB(396.4,DVBCUEX,"RES")
122 Q
Note: See TracBrowser for help on using the repository browser.