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

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

initial load of WorldVistAEHR

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