source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOAPI4.m@ 1593

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

initial load of WorldVistAEHR

File size: 9.5 KB
Line 
1HLOAPI4 ;ALB/CJM-HL7 - Developer API's for sending & receiving messages(continued) ;12/11/2006
2 ;;1.6;HEALTH LEVEL SEVEN;**131,134**;Oct 13, 1995;Build 30
3 ;
4SETTS(SEG,VALUE,FIELD,COMP,REP) ;
5 ;Sets a value that is a timestamp in FM format into the segment in HL7
6 ;format. The degree of precision may be optionally specified. The
7 ;inserted value will include the timezone if the input included the time.
8 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
9 ;
10 ;Input:
11 ; SEG - (required, pass by reference) The array where the seg is being built.
12 ; VALUE (required)to be set into the segment
13 ; VALUE("PRECISION") (optional) If included, VALUE must be passed by
14 ; reference. Allowed values are:
15 ; "S" - seconds (default value)
16 ; "M" - minutes
17 ; "H" - hours
18 ; "D" - days
19 ; FIELD - the sequence # of the field
20 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
21 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating.
22 ;Output:
23 ; SEG array
24 ;
25 ;Example:
26 ; D SETTS^HLOAPI4(.SEG,$$NOW^XLFDT,1) will place the current date/time into the segment in the 1st field,1st occurence. The timezone is included.
27 ;
28 ;
29 N TIME
30 Q:'$G(FIELD)
31 Q:'$G(VALUE)
32 S:'$G(REP) REP=1
33 S:'$G(COMP) COMP=1
34 S TIME=$$FMTHL7^XLFDT(VALUE)
35 I $D(VALUE("PRECISION")) D
36 .N TZ
37 .S TZ=""
38 .I TIME["+" S TZ="+"_$P(TIME,"+",2)
39 .E I TIME["-" S TZ="-"_$P(TIME,"-",2)
40 .I VALUE("PRECISION")="D" D
41 ..S TIME=$E(TIME,1,8)_TZ
42 .E I VALUE("PRECISION")="H" D
43 ..S TIME=$E($$LJ^XLFSTR(+TIME,10,0),1,10)_TZ
44 .E I VALUE("PRECISION")="M" D
45 ..S TIME=$E($$LJ^XLFSTR(+TIME,12,0),1,12)_TZ
46 .E I VALUE("PRECISION")="S" D
47 ..S TIME=$E($$LJ^XLFSTR(+TIME,14,0),1,14)_TZ
48 S SEG(FIELD,REP,COMP,1)=TIME
49 Q
50 ;
51SETDT(SEG,VALUE,FIELD,COMP,REP) ;
52 ;Sets a value that is a date in FM format into the segment in HL7 format. The degree of precision may be optionally specified.
53 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
54 ;
55 ;Input:
56 ; SEG - (required, pass by reference) The array where the seg is being built.
57 ; VALUE (required)the date to be set into the segment
58 ; VALUE("PRECISION") (optional) If included, VALUE must be passed by
59 ; reference. Allowed values are:
60 ; "D" - day (default value)
61 ; "L" - month
62 ; "Y" - year
63 ; FIELD - the sequence # of the field
64 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
65 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating.
66 ;Output:
67 ; SEG - segment that is being built
68 ;
69 ;Example:
70 ; D SETDT^HLOAPI4(.SEG,$$TODAY^XLFDT,1) will place the current date into segment in the 1st field,1st occurence.
71 ;
72 ;
73 N TIME
74 Q:'$G(FIELD)
75 S:'$G(REP) REP=1
76 S:'$G(COMP) COMP=1
77 S TIME=$$FMTHL7^XLFDT(VALUE)
78 I $D(VALUE("PRECISION")) D
79 .I VALUE("PRECISION")="Y" D
80 ..S TIME=$E(TIME,1,4)
81 .E I VALUE("PRECISION")="L" D
82 ..S TIME=$E(TIME,1,6)
83 .E I VALUE("PRECISION")="D" D
84 ..S TIME=$E(TIME,1,8)
85 S SEG(FIELD,REP,COMP,1)=TIME
86 Q
87 ;
88SETCE(SEG,VALUE,FIELD,COMP,REP) ;
89 ;Sets a value that is an HL7 Coded Element data type (HL7 Section Reference 2.9.3) into the segment in the specified field.
90 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
91 ;
92 ;Input:
93 ; SEG - (required, pass by reference) The array where the seg is being built.
94 ; VALUE (required, pass-by-reference) These subscripts may be passed:
95 ; "ID" - the identifier
96 ; "TEXT" -
97 ; "SYSTEM" - name of the code system
98 ; "ALTERNATE ID" - alternate identifier
99 ; "ALTERNATE TEXT"
100 ; "ALTERNATE SYSTEM" - name of the alternate coding system
101 ; FIELD (required) the sequence # of the field
102 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
103 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
104 ;Output:
105 ; SEG - segment that is being built
106 ;
107 N SUB,VAR
108 Q:'$G(FIELD)
109 S:'$G(REP) REP=1
110 I '$G(COMP) D
111 .S VAR="COMP",SUB=1
112 E D
113 .S VAR="SUB"
114 S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ID"))
115 S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("TEXT"))
116 S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("SYSTEM"))
117 S @VAR=4,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ALTERNATE ID"))
118 S @VAR=5,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ALTERNATE TEXT"))
119 S @VAR=6,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ALTERNATE SYSTEM"))
120 Q
121 ;
122SETHD(SEG,VALUE,FIELD,COMP,REP) ;
123 ;Sets a value that is an HL7 Hierarchic Designator data type (HL7 Section Reference 2.9.21) into the segment in the specified field.
124 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
125 ;
126 ;Input:
127 ; SEG - (required, pass by reference) The array where the seg is being built.
128 ; VALUE (required, pass-by-reference) These subscripts may be passed:
129 ; "NAMESPACE ID"
130 ; "UNIVERSAL ID"
131 ; "UNIVERSAL ID TYPE"
132 ; FIELD (required) the sequence # of the field
133 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
134 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
135 ;Output:
136 ; SEG - segment that is being built
137 ;
138 N SUB,VAR
139 Q:'$G(FIELD)
140 S:'$G(REP) REP=1
141 I '$G(COMP) D
142 .S VAR="COMP",SUB=1
143 E D
144 .S VAR="SUB"
145 S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("NAMESPACE ID"))
146 S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("UNIVERSAL ID"))
147 S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("UNIVERSAL ID TYPE"))
148 Q
149 ;
150SETCNE(SEG,VALUE,FIELD,COMP,REP) ;
151 ;Sets a value that is an HL7 Coded With No Exceptions data type (HL7 Section Reference 2.9.8) into the segment in the specified field.
152 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
153 ;
154 ;Input:
155 ; SEG - (required, pass by reference) The array where the seg is being built.
156 ; VALUE (required, pass-by-reference) These subscripts may be passed:
157 ; "ID" - the identifier
158 ; "TEXT" -
159 ; "SYSTEM" - name of the code system
160 ; "ALTERNATE ID" - alternate identifier
161 ; "ALTERNATE TEXT"
162 ; "ALTERNATE SYSTEM" - name of the alternate coding system
163 ; "SYSTEM VERSION" - version ID of the coding system
164 ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
165 ; "ORIGINAL TEXT"
166 ; FIELD (required) the sequence # of the field
167 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
168 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
169 ;Output:
170 ; SEG - segment that is being built
171 D SETCODE^HLOAPI2(.SEG,.VALUE,.FIELD,.COMP,.REP)
172 Q
173 ;
174SETCWE(SEG,VALUE,FIELD,COMP,REP) ;
175 ;Sets a value that is an HL7 Coded With Exceptions data type (HL7 Section Reference 2.9.11) into the segment in the specified field.
176 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
177 ;
178 ;Input:
179 ; SEG - (required, pass by reference) The array where the seg is being built.
180 ; VALUE (required, pass-by-reference) These subscripts may be passed:
181 ; "ID" - the identifier
182 ; "TEXT" -
183 ; "SYSTEM" - name of the code system
184 ; "ALTERNATE ID" - alternate identifier
185 ; "ALTERNATE TEXT"
186 ; "ALTERNATE SYSTEM" - name of the alternate coding system
187 ; "SYSTEM VERSION" - version ID of the coding system
188 ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
189 ; "ORIGINAL TEXT"
190 ; FIELD (required) the sequence # of the field
191 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
192 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
193 ;Output:
194 ; SEG - segment that is being built
195 D SETCODE^HLOAPI2(.SEG,.VALUE,.FIELD,.COMP,.REP)
196 Q
197 ;
198SETAD(SEG,VALUE,FIELD,COMP,REP) ;
199 ;Sets an AD data type (Address, HL7 Section Reference 2.9.1) into the segment in the specified field. It can also be used to set the 1st 8 components of the XAD (Extended Address) data type.
200 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
201 ;
202 ;Input:
203 ; SEG - (required, pass by reference) The array where the seg is being built.
204 ; VALUE (required, pass-by-reference) These subscripts may be passed:
205 ; "STREET1" -street address
206 ; "STREET2" - other designation
207 ; "CITY"
208 ; "STATE" - state or province
209 ; "ZIP" - zip or postal code
210 ; "COUNTRY"
211 ; "TYPE" - address type
212 ; "OTHER" - other geographic designation
213 ; FIELD (required) the sequence # of the field
214 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
215 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
216 ;Output:
217 ; SEG - segment that is being built
218 ;
219 N SUB,VAR
220 Q:'$G(FIELD)
221 S:'$G(REP) REP=1
222 I '$G(COMP) D
223 .S VAR="COMP",SUB=1
224 E D
225 .S VAR="SUB"
226 S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("STREET1"))
227 S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("STREET2"))
228 S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("CITY"))
229 S @VAR=4,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("STATE"))
230 S @VAR=5,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ZIP"))
231 S @VAR=6,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("COUNTRY"))
232 S @VAR=7,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("TYPE"))
233 S @VAR=8,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("OTHER"))
234 Q
Note: See TracBrowser for help on using the repository browser.