source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOPRS2.m@ 1751

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

initial load of FOIAVistA 6/30/08 version

File size: 9.3 KB
Line 
1HLOPRS2 ;ALB/CJM-HL7 - Developer API's for parsing messages(continued) ;02/04/2004
2 ;;1.6;HEALTH LEVEL SEVEN;**131**;Oct 13, 1995;Build 10
3 ;
4GETTS(SEG,VALUE,FIELD,COMP,REP) ;
5 ;Gets a segment value that is a timestamp in HL7 format and converts it
6 ;to FileMan format. IF the segment value included the timezone, it is
7 ;the timestamp is converted to local time. The degree of precision
8 ;is optionally returned.
9 ;
10 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
11 ;
12 ;
13 ;Input:
14 ; SEG - (required, pass by reference) The array returned by a call to $$NEXTSEG^HLOPRS.
15 ; FIELD - The sequence # of the field.
16 ; COMP (optional) If specified, the data type is parsed as a component value.
17 ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
18 ;Output:
19 ; VALUE (required) The date/time in FileMan format.
20 ; VALUE("PRECISION") (optional) If needed, VALUE must be passed by
21 ; reference. Expected values are:
22 ; "S" - second
23 ; "M" - minute
24 ; "H" - hour
25 ; "D" - day
26 ; "L" - month
27 ; "Y" - year
28 ; "" - precision not specified
29 ; Note: FM does not allow greater precision than seconds, so this API will round off to the second.
30 ;
31 N TIME,PREC,VAR
32 Q:'$G(FIELD)
33 I '$G(COMP) D
34 .S VAR="COMP",SUB=1
35 E D
36 .S VAR="SUB"
37 S:'$G(REP) REP=1
38 S @VAR=1,TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
39 S @VAR=2,PREC=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
40 S VALUE=$$HL7TFM^XLFDT(TIME)
41 I '$L(PREC) D
42 .I $L(+TIME)>12 S PREC="S" Q
43 .I $L(+TIME)>10 S PREC="M" Q
44 .I $L(+TIME)>8 S PREC="H" Q
45 .I $L(+TIME)>6 S PREC="D" Q
46 .I $L(+TIME)>4 S PREC="L" Q
47 .I $L(+TIME)=4 S PREC="Y" Q
48 S VALUE("PRECISION")=PREC
49 Q
50 ;
51GETDT(SEG,VALUE,FIELD,COMP,REP) ;
52 ;Gets a segment value that is a date in HL7 format and converts it to FileMan format. The degree of precision is optionally returned.
53 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
54 ;
55 ;Input:
56 ; SEG - (required, pass by reference) The array returned by a call to $$NEXTSEG^HLOPRS.
57 ; FIELD - The sequence # of the field.
58 ; COMP (optional) If specified, the data type is parsed as a component value.
59 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
60 ;Output:
61 ; VALUE (required) The date/time in FileMan format.
62 ; VALUE("PRECISION") (optional) If needed, VALUE must be passed by
63 ; reference. Expected values are:
64 ; "S" - second (not valid for DT)
65 ; "M" - minute (not valid for DT)
66 ; "H" - hour (not valid for DT)
67 ; "D" - day
68 ; "L" - month
69 ; "Y" - year
70 ; "" - not specified
71 ;
72 N TIME,PREC,VAR
73 Q:'$G(FIELD)
74 I '$G(COMP) D
75 .S VAR="COMP",SUB=1
76 E D
77 .S VAR="SUB"
78 S:'$G(REP) REP=1
79 S @VAR=1,TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
80 S VALUE=$$HL7TFM^XLFDT(TIME)
81 S PREC=""
82 D
83 .I $L(+TIME)>12 S PREC="S" Q
84 .I $L(+TIME)>10 S PREC="M" Q
85 .I $L(+TIME)>8 S PREC="H" Q
86 .I $L(+TIME)>6 S PREC="D" Q
87 .I $L(+TIME)>4 S PREC="L" Q
88 .I $L(+TIME)=4 S PREC="Y" Q
89 S VALUE("PRECISION")=PREC
90 Q
91 ;
92GETCE(SEG,VALUE,FIELD,COMP,REP) ;
93 ;Gets an CE data type(Coded Element, HL7 Section Reference 2.9.8) from the specified field.
94 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
95 ;
96 ;Input:
97 ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
98 ; FIELD (required) The sequence # of the field.
99 ; COMP (optional) If specified, the data type is parsed as a component value.
100 ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
101 ;Output:
102 ; VALUE (required, pass-by-reference) These subscripts are returned:
103 ; "ID" - the identifier
104 ; "TEXT" -
105 ; "SYSTEM" - name of the code system
106 ; "ALTERNATE ID" - alternate identifier
107 ; "ALTERNATE TEXT"
108 ; "ALTERNATE SYSTEM" - name of the alternate coding system
109 ;
110 N SUB,VAR
111 Q:'$G(FIELD)
112 S:'$G(REP) REP=1
113 I '$G(COMP) D
114 .S VAR="COMP",SUB=1
115 E D
116 .S VAR="SUB"
117 S @VAR=1,VALUE("ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
118 S @VAR=2,VALUE("TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
119 S @VAR=3,VALUE("SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
120 S @VAR=4,VALUE("ALTERNATE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
121 S @VAR=5,VALUE("ALTERNATE TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
122 S @VAR=6,VALUE("ALTERNATE SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
123 Q
124 ;
125GETHD(SEG,VALUE,FIELD,COMP,REP) ;
126 ;Gets an HD data type (Hierarchic Designator, HL7 Section Reference 2.9.21) from the specified field.
127 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
128 ;
129 ;Input:
130 ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
131 ; FIELD (required) The sequence # of the field.
132 ; COMP (optional) If specified, the data type is parsed as a component value.
133 ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
134 ;Output:
135 ; VALUE (required, pass-by-reference) These subscripts are returned:
136 ; "NAMESPACE ID"
137 ; "UNIVERSAL ID"
138 ; "UNIVERSAL ID TYPE"
139 ;
140 N SUB,VAR
141 Q:'$G(FIELD)
142 S:'$G(REP) REP=1
143 I '$G(COMP) D
144 .S VAR="COMP",SUB=1
145 E D
146 .S VAR="SUB"
147 S @VAR=1,VALUE("NAMESPACE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
148 S @VAR=2,VALUE("UNIVERSAL ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
149 S @VAR=3,VALUE("UNIVERSAL ID TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
150 Q
151 ;
152GETCNE(SEG,VALUE,FIELD,COMP,REP) ;
153 ;Gets an CNE data type (Coded With No Exceptions, HL7 Section Reference 2.9.8) from the specified field.
154 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
155 ;
156 ;Input:
157 ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
158 ; FIELD (required) The sequence # of the field.
159 ; COMP (optional) If specified, the data type is parsed as a component value.
160 ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
161 ;Output:
162 ; VALUE (required, pass-by-reference) These subscripts are returned:
163 ; "ID" - the identifier
164 ; "TEXT" -
165 ; "SYSTEM" - name of the code system
166 ; "ALTERNATE ID" - alternate identifier
167 ; "ALTERNATE TEXT"
168 ; "ALTERNATE SYSTEM" - name of the alternate coding system
169 ; "SYSTEM VERSION" - version ID of the coding system
170 ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
171 ; "ORIGINAL TEXT"
172 ;
173 D GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
174 Q
175 ;
176GETCWE(SEG,VALUE,FIELD,COMP,REP) ;
177 ;Gets an CWE data type (Coded With Exceptions, HL7 Section Reference 2.9.11) from the specified field.
178 ;IF the component is specified, then the component is parsed for the data type rather than at the higher field level.
179 ;
180 ;Input:
181 ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
182 ; FIELD (required) The sequence # of the field.
183 ; COMP (optional) If specified, the data type is parsed as a component value.
184 ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
185 ;Output:
186 ; VALUE (required, pass-by-reference) These subscripts are returned:
187 ; "ID" - the identifier
188 ; "TEXT" -
189 ; "SYSTEM" - name of the code system
190 ; "ALTERNATE ID" - alternate identifier
191 ; "ALTERNATE TEXT"
192 ; "ALTERNATE SYSTEM" - name of the alternate coding system
193 ; "SYSTEM VERSION" - version ID of the coding system
194 ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
195 ; "ORIGINAL TEXT"
196 D GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
197 Q
198 ;
199GETAD(SEG,VALUE,FIELD,COMP,REP) ;
200 ;Gets an AD data type (Address, HL7 Section Reference 2.9.1) from the specified field. It can also be used to get the 1st 8 components of the XAD (Extended Address) data type.
201 ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
202 ;
203 ;Input:
204 ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
205 ; FIELD (required) The sequence # of the field.
206 ; COMP (optional) If specified, the data type is parsed as a component value.
207 ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
208 ;Output:
209 ; VALUE (required, pass-by-reference) These subscripts are returned:
210 ; "STREET1" -street address
211 ; "STREET2" - other designation
212 ; "CITY"
213 ; "STATE" - state or province
214 ; "ZIP" - zip or postal code
215 ; "COUNTRY"
216 ; "TYPE" - address type
217 ; "OTHER" - other geographic designation
218 ;
219 N SUB,VAR
220 Q:'$G(FIELD)
221 I '$G(COMP) D
222 .S VAR="COMP",SUB=1
223 E D
224 .S VAR="SUB"
225 S:'$G(REP) REP=1
226 S @VAR=1,VALUE("STREET1")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
227 S @VAR=2,VALUE("STREET2")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
228 S @VAR=3,VALUE("CITY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
229 S @VAR=4,VALUE("STATE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
230 S @VAR=5,VALUE("ZIP")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
231 S @VAR=6,VALUE("COUNTRY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
232 S @VAR=7,VALUE("TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
233 S @VAR=8,VALUE("OTHER")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
234 Q
Note: See TracBrowser for help on using the repository browser.