source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGROHLU3.m@ 1520

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

initial load of WorldVistAEHR

File size: 5.7 KB
RevLine 
[613]1DGROHLU3 ;DJH/AMA - ROM HL7 BUILD MSA/ERR SEGMENTS ; 02 Jul 2003 5:02 PM
2 ;;5.3;Registration;**533**;Aug 13, 1993
3 ;
4 Q
5 ;
6MSA(DGACK,DGID,DGERR,DGFLD,DGHL) ;MSA Segment API
7 ;This function wraps the data retrieval and segment creation APIs and
8 ;returns a formatted MSA segment.
9 ; Called from BLDORF^DGROHLQ and BLDACK^DGROHLU4
10 ;
11 ; Input:
12 ; DGACK - (required) MSA segment Acknowledgment code
13 ; DGID - (required) Message Control ID
14 ; DGERR - (optional) Error condition
15 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
16 ; to include. Defaults to all required fields (1,2).
17 ; DGHL - (required) HL7 environment array
18 ;
19 ; Output:
20 ; Function Value - MSA segment on success, "" on failure
21 ;
22 N DGMSA
23 N DGVAL
24 ;
25 S DGMSA=""
26 I $G(DGACK)]"",+$G(DGID) D
27 . S DGERR=$G(DGERR)
28 . S DGFLD=$$CKSTR^DGROHLUT("1,2",DGFLD) ;validate field string
29 . I DGERR]"" S DGFLD=DGFLD_",6"
30 . S DGFLD=","_DGFLD_","
31 . I $$MSAVAL(DGFLD,DGACK,DGID,"","","",DGERR,.DGVAL) D
32 . . S DGMSA=$$BLDSEG^DGROHLUT("MSA",.DGVAL,.DGHL)
33 Q DGMSA
34 ;
35MSAVAL(DGFLD,DGACK,DGID,DGTEXT,DGESN,DGDAT,DGERR,DGVAL) ;build MSA value array
36 ;
37 ; Input:
38 ; DGFLD - (required) fields string
39 ; DGACK - (required) MSA segment Acknowledgment code
40 ; DGID - (required) Message Control ID
41 ; DGTEXT - (optional) Text message
42 ; DGESN - (optional) Expected sequence number
43 ; DGDAT - (optional) Delayed acknowledgment type
44 ; DGERR - (optional) Error condition
45 ;
46 ; Output:
47 ; Function Value - 1 on sucess, 0 on failure
48 ; DGVAL - MSA field array [SUB1:field, SUB2:repetition,
49 ; SUB3:component, SUB4:sub-component]
50 ;
51 N DGRSLT ;function value
52 N DGACKS ;array of valid ACK codes
53 N DGCOD ;ACK code string
54 N DGERRSTR ;Error condition string
55 N DGTBL ;VA086 Error code array
56 ;
57 S DGRSLT=0
58 I $G(DGFLD)]"",$G(DGACK)]"",+$G(DGID) D
59 . F DGCOD="AA","AE","AR","CA","CE","CR" S DGACKS(DGCOD)=""
60 . ;
61 . ; seq 1 Acknowledgment Code
62 . I DGFLD[",1," D
63 . . S DGVAL(1)=$S($D(DGACKS(DGACK)):DGACK,1:"")
64 . Q:(DGVAL(1)="") ;required field
65 . ;
66 . ; seq 2 Message Control ID
67 . I DGFLD[",2," D
68 . . S DGVAL(2)=DGID
69 . Q:(DGVAL(2)="") ;required field
70 . ;
71 . ; seq 3 Text Message
72 . I DGFLD[",3," D
73 . . S DGVAL(3)=$G(DGTEXT)
74 . ;
75 . ; seq 4 Expected Sequence Number
76 . I DGFLD[",4," D
77 . . S DGVAL(4)=$G(DGESN)
78 . ;
79 . ; seq 5 Delayed Acknowledgment Type
80 . I DGFLD[",5," D
81 . . S DGDAT=$G(DGDAT)
82 . . S DGVAL(5)=$S(DGDAT="D":DGDAT,DGDAT="F":DGDAT,1:"")
83 . ;
84 . ; seq 6 Error Condition
85 . I DGFLD[",6," D
86 . . D BLDVA086(.DGTBL)
87 . . I $G(DGERR)]"",$D(DGTBL(DGERR))#2 D
88 . . . S DGVAL(6,1,1)=DGERR
89 . . . S DGVAL(6,1,2)=DGTBL(DGERR)
90 . . . S DGVAL(6,1,3)="VA086"
91 . S DGRSLT=1
92 I 'DGRSLT K DGVAL
93 Q DGRSLT
94 ;
95ERR(DGSEG,DGSEQ,DGPOS,DGCOD,DGFLD,DGHL) ;ERR segment API
96 ;Called from BLDERR^DGROHLU4
97 ; Input:
98 ; DGSEG - (required) Segment ID
99 ; DGSEQ - (required) Sequence
100 ; DGPOS - (required) Field position
101 ; DGCOD - (required) Error code from table VA086
102 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
103 ; to include. Defaults to all required fields (1).
104 ; DGHL - (required) HL7 Environment array
105 ;
106 ; Output:
107 ; Function value - ERR segment on success, "" on failure
108 ;
109 N DGERR
110 N DGVAL
111 N DGFLD
112 ;
113 S DGERR=""
114 I $G(DGSEG)]"",+$G(DGSEQ),+$G(DGPOS),$G(DGCOD)]"",$G(DGHL("ECH"))]"" D
115 . S DGFLD=$$CKSTR^DGROHLUT("1",DGFLD) ;validate field string
116 . S DGFLD=","_DGFLD_","
117 . I $$ERRVAL(DGFLD,DGSEG,DGSEQ,DGPOS,DGCOD,.DGVAL) D
118 . . S DGERR=$$BLDSEG^DGROHLUT("ERR",.DGVAL,.DGHL)
119 Q DGERR
120 ;
121ERRVAL(DGFLD,DGSEG,DGSEQ,DGPOS,DGCOD,DGVAL) ;build ERR value array
122 ;
123 ; Input:
124 ; DGFLD - (required) Field string
125 ; DGSEG - (required) Segment ID
126 ; DGSEQ - (required) Sequence
127 ; DGPOS - (required) Field position
128 ; DGCOD - (required) Error code from table VA086
129 ;
130 ; Output:
131 ; Function value - 1 on success, 0 on failure
132 ; DGVAL - ERR field array [SUB1:field, SUB2:repetition,
133 ; SUB3:component, SUB4:sub-component]
134 N DGRSLT
135 N DGTBL
136 ;
137 S DGRSLT=0
138 I $G(DGFLD)]"",$G(DGSEG)]"",+$G(DGSEQ),+$G(DGPOS),$G(DGCOD)]"" D
139 . I DGFLD[",1," D
140 . . D BLDVA086(.DGTBL)
141 . . I $D(DGTBL(DGCOD))#2 D
142 . . . S DGVAL(1,1,1)=DGSEG
143 . . . S DGVAL(1,1,2)=DGSEQ
144 . . . S DGVAL(1,1,3)=DGPOS
145 . . . S DGVAL(1,1,4,1)=DGCOD
146 . . . S DGVAL(1,1,4,2)=DGTBL(DGCOD)
147 . . . S DGVAL(1,1,4,3)="VA086"
148 . S DGRSLT=1
149 Q DGRSLT
150 ;
151BLDVA086(DGTBL) ;build error code/text array for table VA086
152 ;
153 ; Input:
154 ; none
155 ;
156 ; Output:
157 ; DGTBL - error code array subscripted by code containing error text
158 ;
159 N DGI
160 N DGLINE
161 N DGCOD
162 N DGTXT
163 N DGDESC
164 ;
165 F DGI=1:1 S DGLINE=$T(ERRTBL+DGI) Q:DGLINE="" D
166 . S DGCOD=$P(DGLINE,";",3)
167 . S DGTXT=$P(DGLINE,";",4)
168 . S DGDESC=$P(DGLINE,";",5)
169 . S DGTBL(DGCOD)=DGTXT
170 . S DGTBL(DGCOD,"DESC")=DGDESC
171 Q
172 ;
173ERRTBL ;VA086 Error Code Table;error code;error text
174 ;;FE;Filer Error;An error occurred at the remote site when attempting to add or update an assignment.
175 ;;IF;Invalid Patient Record Flag;The transmitted Patient Record Flag is not defined at the remote site.
176 ;;IID;Invalid Observation ID;The transmitted observation ID is not "N"arrative, "S"tatus or "C"omment.
177 ;;IOR;Invalid Originating Site;The originating site of the transmission is not defined at the remote site.
178 ;;IOW;Invalid Owner Site;The transmitted owning site is not defined at the remote site.
179 ;;NM;No Match;No patient was found that correlates to the transmitted ICN, DOB and SSN.
180 ;;UU;Unauthorized Update;The originating site of the transmission is not defined as the owning site of the assignment or an invalid action was transmitted (i.e. Reactivate an already active assignment).
Note: See TracBrowser for help on using the repository browser.