1 | DGQEHLS ;ALB/RPM - VIC REPLACEMENT HL7 SEND DRIVER ; 10/13/05
|
---|
2 | ;;5.3;Registration;**571,679**;Aug 13, 1993
|
---|
3 | ;
|
---|
4 | Q ;no direct entry
|
---|
5 | ;
|
---|
6 | SND(DGRIEN,DGERR) ;Send a single ORM orders message
|
---|
7 | ; This function builds and transmits a General Order (ORM~O01)
|
---|
8 | ; Message used to either release a hold on a Veteran ID Card (VIC)
|
---|
9 | ; request or cancel the VIC request.
|
---|
10 | ;
|
---|
11 | ; Input:
|
---|
12 | ; DGRIEN - pointer VIC REQUEST (#39.6) file
|
---|
13 | ;
|
---|
14 | ; Output:
|
---|
15 | ; Function result - '1' on success; '0' on failure
|
---|
16 | ; DGERR - undefined on success; error message string on failure
|
---|
17 | ;
|
---|
18 | N DGHLEID ;event protocol ID
|
---|
19 | N DGHLRSLT ;result from GENERATE API
|
---|
20 | N DGREQ ;VIC REQUEST data array
|
---|
21 | N DGROOT ;HL7 message text array name
|
---|
22 | N DGRSLT ;function result
|
---|
23 | ;
|
---|
24 | S DGROOT=$NA(^TMP("HLS",$J))
|
---|
25 | K @DGROOT
|
---|
26 | ;
|
---|
27 | S DGRSLT=0
|
---|
28 | ;
|
---|
29 | I $G(DGRIEN)>0 D
|
---|
30 | . ;
|
---|
31 | . ;initialize HL7 environment
|
---|
32 | . S DGHLEID=$$INIT^DGQEHLUT("DGQE VIC ORM/O01 EVENT",.DGHL)
|
---|
33 | . I 'DGHLEID S DGERR="Unable to initialize HL7 environment"
|
---|
34 | . Q:$D(DGERR)
|
---|
35 | . ;
|
---|
36 | . ;retrieve VIC REQUEST file record
|
---|
37 | . I '$$GETREQ^DGQEREQ(DGRIEN,.DGREQ) D
|
---|
38 | . . S DGERR="Unable to retrieve VIC REQUEST data"
|
---|
39 | . Q:$D(DGERR)
|
---|
40 | . ;
|
---|
41 | . ;build ORM message
|
---|
42 | . I '$$BLDORM(.DGREQ,DGROOT,.DGHL) D
|
---|
43 | . . S DGERR="Unable to build ORM message text"
|
---|
44 | . Q:$D(DGERR)
|
---|
45 | . ;
|
---|
46 | . ;transmit the message
|
---|
47 | . D GENERATE^HLMA(DGHLEID,$S(DGROOT["^":"GM",1:"LM"),1,.DGHLRSLT)
|
---|
48 | . I +$P(DGHLRSLT,U,2) S DGERR=$P(DGHLRSLT,U,2)
|
---|
49 | . Q:$D(DGERR)
|
---|
50 | . ;
|
---|
51 | . ;set transmission log
|
---|
52 | . D STOXMIT^DGQEHLL($P(DGHLRSLT,U),DGRIEN)
|
---|
53 | . ;
|
---|
54 | . ;clear transmission required flag
|
---|
55 | . D XMITOFF^DGQEDD(DGRIEN)
|
---|
56 | . ;
|
---|
57 | . S DGRSLT=1
|
---|
58 | ;
|
---|
59 | K @DGROOT
|
---|
60 | ;
|
---|
61 | Q DGRSLT
|
---|
62 | ;
|
---|
63 | BLDORM(DGREQ,DGROOT,DGHL) ;build segments for a single ORM message
|
---|
64 | ;
|
---|
65 | ; Input:
|
---|
66 | ; DGREQ - (required) VIC REQUEST data array
|
---|
67 | ; DGROOT - (required) closed root array name to contain segments
|
---|
68 | ; DGHL - VistA HL7 environment array
|
---|
69 | ;
|
---|
70 | ; Output:
|
---|
71 | ; Function value - "1" on sucess; "0" on failure
|
---|
72 | ;
|
---|
73 | N DGPTID ;Patient ID field 3 of PID segment
|
---|
74 | N DGRSLT ;function result
|
---|
75 | N DGSEG ;segment counter
|
---|
76 | N DGSEGSTR ;formatted segment string
|
---|
77 | N DGSTR ;comma-delimited list of segment fields
|
---|
78 | ;
|
---|
79 | S DGRSLT=0
|
---|
80 | S DGSEG=0
|
---|
81 | I $D(DGREQ),$G(DGROOT)]"",$D(DGHL) D
|
---|
82 | . Q:'$G(DGREQ("DFN"))
|
---|
83 | . Q:'$D(^DPT(DGREQ("DFN")))
|
---|
84 | . Q:$G(DGREQ("CARDID"))']""
|
---|
85 | . ;
|
---|
86 | . ;build PID segment
|
---|
87 | . S DGSTR="1,2,3,5,7,19" ;{3=ICN,5=NAME,7=DOB,19=SSN}
|
---|
88 | . S DGSEGSTR=$$EN^VAFHLPID(DGREQ("DFN"),DGSTR,1,1)
|
---|
89 | . Q:(DGSEGSTR="")
|
---|
90 | . ;set Patient ID field 3 Check Digit component to null
|
---|
91 | . S DGPTID=$P(DGSEGSTR,DGHL("FS"),4)
|
---|
92 | . S $P(DGPTID,$E(DGHL("ECH")),2)=""
|
---|
93 | . S $P(DGSEGSTR,DGHL("FS"),4)=DGPTID
|
---|
94 | . S DGSEG=DGSEG+1,@DGROOT@(DGSEG)=DGSEGSTR
|
---|
95 | . ;
|
---|
96 | . ;build ORC segment
|
---|
97 | . S DGSTR="1"
|
---|
98 | . S DGSEGSTR=$$ORC^DGQEHLOR(.DGREQ,DGSTR,.DGHL)
|
---|
99 | . Q:(DGSEGSTR="")
|
---|
100 | . S DGSEG=DGSEG+1,@DGROOT@(DGSEG)=DGSEGSTR
|
---|
101 | . ;
|
---|
102 | . ;build RQD segment
|
---|
103 | . S DGSTR="1,3"
|
---|
104 | . S DGSEGSTR=$$RQD^DGQEHLRQ(.DGREQ,DGSTR,.DGHL)
|
---|
105 | . Q:(DGSEGSTR="")
|
---|
106 | . S DGSEG=DGSEG+1,@DGROOT@(DGSEG)=DGSEGSTR
|
---|
107 | . ;
|
---|
108 | . ;build NTE segment for POW and PH
|
---|
109 | . S DGSTR="3"
|
---|
110 | . S DGSEGSTR=$$NTE^DGQEHLNT(.DGREQ,DGSTR,.DGHL)
|
---|
111 | . Q:(DGSEGSTR="")
|
---|
112 | . S DGSEG=DGSEG+1,@DGROOT@(DGSEG)=DGSEGSTR
|
---|
113 | . ;
|
---|
114 | . ;success
|
---|
115 | . S DGRSLT=1
|
---|
116 | ;
|
---|
117 | Q DGRSLT
|
---|