HLOAPI4 ;ALB/CJM-HL7 - Developer API's for sending & receiving messages(continued) ;08/19/2009
;;1.6;HEALTH LEVEL SEVEN;**131,134,146**;Oct 13, 1995;Build 16
;Per VHA Directive 2004-038, this routine should not be modified.
;
SETTS(SEG,VALUE,FIELD,COMP,REP) ;
;Sets a value that is a timestamp in FM format into the segment in HL7
;format. The degree of precision may be optionally specified. The
;inserted value will include the timezone if the input included the time.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required)to be set into the segment
; VALUE("PRECISION") (optional) If included, VALUE must be passed by
; reference. Allowed values are:
; "S" - seconds (default value)
; "M" - minutes
; "H" - hours
; "D" - days
; FIELD - the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating.
;Output:
; SEG array
;
;Example:
; 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.
;
;
N TIME
Q:'$G(FIELD)
Q:'$G(VALUE)
S:'$G(REP) REP=1
S:'$G(COMP) COMP=1
S TIME=$$FMTHL7^XLFDT(VALUE)
I $D(VALUE("PRECISION")) D
.N TZ
.S TZ=""
.I TIME["+" S TZ="+"_$P(TIME,"+",2)
.E I TIME["-" S TZ="-"_$P(TIME,"-",2)
.I VALUE("PRECISION")="D" D
..S TIME=$E(TIME,1,8)_TZ
.E I VALUE("PRECISION")="H" D
..S TIME=$E($$LJ^XLFSTR(+TIME,10,0),1,10)_TZ
.E I VALUE("PRECISION")="M" D
..S TIME=$E($$LJ^XLFSTR(+TIME,12,0),1,12)_TZ
.E I VALUE("PRECISION")="S" D
..S TIME=$E($$LJ^XLFSTR(+TIME,14,0),1,14)_TZ
S SEG(FIELD,REP,COMP,1)=TIME
Q
;
SETDT(SEG,VALUE,FIELD,COMP,REP) ;
;Sets a value that is a date in FM format into the segment in HL7 format. The degree of precision may be optionally specified.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required)the date to be set into the segment
; VALUE("PRECISION") (optional) If included, VALUE must be passed by
; reference. Allowed values are:
; "D" - day (default value)
; "L" - month
; "Y" - year
; FIELD - the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating.
;Output:
; SEG - segment that is being built
;
;Example:
; D SETDT^HLOAPI4(.SEG,$$TODAY^XLFDT,1) will place the current date into segment in the 1st field,1st occurence.
;
;
N TIME
Q:'$G(FIELD)
S:'$G(REP) REP=1
S:'$G(COMP) COMP=1
S TIME=$$FMTHL7^XLFDT(VALUE)
I $D(VALUE("PRECISION")) D
.I VALUE("PRECISION")="Y" D
..S TIME=$E(TIME,1,4)
.E I VALUE("PRECISION")="L" D
..S TIME=$E(TIME,1,6)
.E I VALUE("PRECISION")="D" D
..S TIME=$E(TIME,1,8)
S SEG(FIELD,REP,COMP,1)=TIME
Q
;
SETCE(SEG,VALUE,FIELD,COMP,REP) ;
;Sets a value that is an HL7 Coded Element data type (HL7 Section Reference 2.9.3) into the segment in the specified field.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required, pass-by-reference) These subscripts may be passed:
; "ID" - the identifier
; "TEXT" -
; "SYSTEM" - name of the code system
; "ALTERNATE ID" - alternate identifier
; "ALTERNATE TEXT"
; "ALTERNATE SYSTEM" - name of the alternate coding system
; FIELD (required) the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
;Output:
; SEG - segment that is being built
;
N SUB,VAR
Q:'$G(FIELD)
S:'$G(REP) REP=1
I '$G(COMP) D
.S VAR="COMP",SUB=1
E D
.S VAR="SUB"
S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ID"))
S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("TEXT"))
S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("SYSTEM"))
S @VAR=4,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ALTERNATE ID"))
S @VAR=5,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ALTERNATE TEXT"))
S @VAR=6,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ALTERNATE SYSTEM"))
Q
;
SETHD(SEG,VALUE,FIELD,COMP,REP) ;
;Sets a value that is an HL7 Hierarchic Designator data type (HL7 Section Reference 2.9.21) into the segment in the specified field.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required, pass-by-reference) These subscripts may be passed:
; "NAMESPACE ID"
; "UNIVERSAL ID"
; "UNIVERSAL ID TYPE"
; FIELD (required) the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
;Output:
; SEG - segment that is being built
;
N SUB,VAR
Q:'$G(FIELD)
S:'$G(REP) REP=1
I '$G(COMP) D
.S VAR="COMP",SUB=1
E D
.S VAR="SUB"
S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("NAMESPACE ID"))
S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("UNIVERSAL ID"))
S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("UNIVERSAL ID TYPE"))
Q
;
SETCNE(SEG,VALUE,FIELD,COMP,REP) ;
;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.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required, pass-by-reference) These subscripts may be passed:
; "ID" - the identifier
; "TEXT" -
; "SYSTEM" - name of the code system
; "ALTERNATE ID" - alternate identifier
; "ALTERNATE TEXT"
; "ALTERNATE SYSTEM" - name of the alternate coding system
; "SYSTEM VERSION" - version ID of the coding system
; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
; "ORIGINAL TEXT"
; FIELD (required) the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
;Output:
; SEG - segment that is being built
D SETCODE^HLOAPI2(.SEG,.VALUE,.FIELD,.COMP,.REP)
Q
;
SETCWE(SEG,VALUE,FIELD,COMP,REP) ;
;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.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required, pass-by-reference) These subscripts may be passed:
; "ID" - the identifier
; "TEXT" -
; "SYSTEM" - name of the code system
; "ALTERNATE ID" - alternate identifier
; "ALTERNATE TEXT"
; "ALTERNATE SYSTEM" - name of the alternate coding system
; "SYSTEM VERSION" - version ID of the coding system
; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
; "ORIGINAL TEXT"
; FIELD (required) the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
;Output:
; SEG - segment that is being built
D SETCODE^HLOAPI2(.SEG,.VALUE,.FIELD,.COMP,.REP)
Q
;
SETAD(SEG,VALUE,FIELD,COMP,REP) ;
;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.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required, pass-by-reference) These subscripts may be passed:
; "STREET1" -street address
; "STREET2" - other designation
; "CITY"
; "STATE" - state or province
; "ZIP" - zip or postal code
; "COUNTRY"
; "TYPE" - address type
; "OTHER" - other geographic designation
; FIELD (required) the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
;Output:
; SEG - segment that is being built
;
N SUB,VAR
Q:'$G(FIELD)
S:'$G(REP) REP=1
I '$G(COMP) D
.S VAR="COMP",SUB=1
E D
.S VAR="SUB"
S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("STREET1"))
S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("STREET2"))
S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("CITY"))
S @VAR=4,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("STATE"))
S @VAR=5,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("ZIP"))
S @VAR=6,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("COUNTRY"))
S @VAR=7,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("TYPE"))
S @VAR=8,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("OTHER"))
Q
;
;** P146 START CJM
SETXPN(SEG,VALUE,FIELD,COMP,REP) ;
;Sets an XPN data type (extended person name) into the segment in the specified field.
;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
;
;Input:
; SEG - (required, pass by reference) The array where the seg is being built.
; VALUE (required, pass-by-reference) These subscripts may be passed:
; "FAMILY"
; "GIVEN" first name
; "SECOND" second and further names or initials
; "SUFFIX" (e.g., JR)
; "PREFIX" (e.g., DR)
; "DEGREE" (e.g., MD)
; FIELD (required) the sequence # of the field
; COMP (optional) If specified, the data type is 'demoted' to a component value.
; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
;Output:
; SEG - segment that is being built
;
N SUB,VAR
Q:'$G(FIELD)
S:'$G(REP) REP=1
I '$G(COMP) D
.S VAR="COMP",SUB=1
E D
.S VAR="SUB"
S @VAR=1,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("FAMILY"))
S @VAR=2,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("GIVEN"))
S @VAR=3,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("SECOND"))
S @VAR=4,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("SUFFIX"))
S @VAR=5,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("PREFIX"))
S @VAR=6,SEG(FIELD,REP,COMP,SUB)=$G(VALUE("DEGREE"))
Q
;**P146 END CJM
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLOAPI4 11402 printed Oct 16, 2024@17:59:16 Page 2
HLOAPI4 ;ALB/CJM-HL7 - Developer API's for sending & receiving messages(continued) ;08/19/2009
+1 ;;1.6;HEALTH LEVEL SEVEN;**131,134,146**;Oct 13, 1995;Build 16
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
SETTS(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;Sets a value that is a timestamp in FM format into the segment in HL7
+2 ;format. The degree of precision may be optionally specified. The
+3 ;inserted value will include the timezone if the input included the time.
+4 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+5 ;
+6 ;Input:
+7 ; SEG - (required, pass by reference) The array where the seg is being built.
+8 ; VALUE (required)to be set into the segment
+9 ; VALUE("PRECISION") (optional) If included, VALUE must be passed by
+10 ; reference. Allowed values are:
+11 ; "S" - seconds (default value)
+12 ; "M" - minutes
+13 ; "H" - hours
+14 ; "D" - days
+15 ; FIELD - the sequence # of the field
+16 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+17 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating.
+18 ;Output:
+19 ; SEG array
+20 ;
+21 ;Example:
+22 ; 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.
+23 ;
+24 ;
+25 NEW TIME
+26 if '$GET(FIELD)
QUIT
+27 if '$GET(VALUE)
QUIT
+28 if '$GET(REP)
SET REP=1
+29 if '$GET(COMP)
SET COMP=1
+30 SET TIME=$$FMTHL7^XLFDT(VALUE)
+31 IF $DATA(VALUE("PRECISION"))
Begin DoDot:1
+32 NEW TZ
+33 SET TZ=""
+34 IF TIME["+"
SET TZ="+"_$PIECE(TIME,"+",2)
+35 IF '$TEST
IF TIME["-"
SET TZ="-"_$PIECE(TIME,"-",2)
+36 IF VALUE("PRECISION")="D"
Begin DoDot:2
+37 SET TIME=$EXTRACT(TIME,1,8)_TZ
End DoDot:2
+38 IF '$TEST
IF VALUE("PRECISION")="H"
Begin DoDot:2
+39 SET TIME=$EXTRACT($$LJ^XLFSTR(+TIME,10,0),1,10)_TZ
End DoDot:2
+40 IF '$TEST
IF VALUE("PRECISION")="M"
Begin DoDot:2
+41 SET TIME=$EXTRACT($$LJ^XLFSTR(+TIME,12,0),1,12)_TZ
End DoDot:2
+42 IF '$TEST
IF VALUE("PRECISION")="S"
Begin DoDot:2
+43 SET TIME=$EXTRACT($$LJ^XLFSTR(+TIME,14,0),1,14)_TZ
End DoDot:2
End DoDot:1
+44 SET SEG(FIELD,REP,COMP,1)=TIME
+45 QUIT
+46 ;
SETDT(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;Sets a value that is a date in FM format into the segment in HL7 format. The degree of precision may be optionally specified.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required)the date to be set into the segment
+7 ; VALUE("PRECISION") (optional) If included, VALUE must be passed by
+8 ; reference. Allowed values are:
+9 ; "D" - day (default value)
+10 ; "L" - month
+11 ; "Y" - year
+12 ; FIELD - the sequence # of the field
+13 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+14 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating.
+15 ;Output:
+16 ; SEG - segment that is being built
+17 ;
+18 ;Example:
+19 ; D SETDT^HLOAPI4(.SEG,$$TODAY^XLFDT,1) will place the current date into segment in the 1st field,1st occurence.
+20 ;
+21 ;
+22 NEW TIME
+23 if '$GET(FIELD)
QUIT
+24 if '$GET(REP)
SET REP=1
+25 if '$GET(COMP)
SET COMP=1
+26 SET TIME=$$FMTHL7^XLFDT(VALUE)
+27 IF $DATA(VALUE("PRECISION"))
Begin DoDot:1
+28 IF VALUE("PRECISION")="Y"
Begin DoDot:2
+29 SET TIME=$EXTRACT(TIME,1,4)
End DoDot:2
+30 IF '$TEST
IF VALUE("PRECISION")="L"
Begin DoDot:2
+31 SET TIME=$EXTRACT(TIME,1,6)
End DoDot:2
+32 IF '$TEST
IF VALUE("PRECISION")="D"
Begin DoDot:2
+33 SET TIME=$EXTRACT(TIME,1,8)
End DoDot:2
End DoDot:1
+34 SET SEG(FIELD,REP,COMP,1)=TIME
+35 QUIT
+36 ;
SETCE(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;Sets a value that is an HL7 Coded Element data type (HL7 Section Reference 2.9.3) into the segment in the specified field.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required, pass-by-reference) These subscripts may be passed:
+7 ; "ID" - the identifier
+8 ; "TEXT" -
+9 ; "SYSTEM" - name of the code system
+10 ; "ALTERNATE ID" - alternate identifier
+11 ; "ALTERNATE TEXT"
+12 ; "ALTERNATE SYSTEM" - name of the alternate coding system
+13 ; FIELD (required) the sequence # of the field
+14 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+15 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
+16 ;Output:
+17 ; SEG - segment that is being built
+18 ;
+19 NEW SUB,VAR
+20 if '$GET(FIELD)
QUIT
+21 if '$GET(REP)
SET REP=1
+22 IF '$GET(COMP)
Begin DoDot:1
+23 SET VAR="COMP"
SET SUB=1
End DoDot:1
+24 IF '$TEST
Begin DoDot:1
+25 SET VAR="SUB"
End DoDot:1
+26 SET @VAR=1
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("ID"))
+27 SET @VAR=2
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("TEXT"))
+28 SET @VAR=3
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("SYSTEM"))
+29 SET @VAR=4
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("ALTERNATE ID"))
+30 SET @VAR=5
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("ALTERNATE TEXT"))
+31 SET @VAR=6
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("ALTERNATE SYSTEM"))
+32 QUIT
+33 ;
SETHD(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;Sets a value that is an HL7 Hierarchic Designator data type (HL7 Section Reference 2.9.21) into the segment in the specified field.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required, pass-by-reference) These subscripts may be passed:
+7 ; "NAMESPACE ID"
+8 ; "UNIVERSAL ID"
+9 ; "UNIVERSAL ID TYPE"
+10 ; FIELD (required) the sequence # of the field
+11 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+12 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
+13 ;Output:
+14 ; SEG - segment that is being built
+15 ;
+16 NEW SUB,VAR
+17 if '$GET(FIELD)
QUIT
+18 if '$GET(REP)
SET REP=1
+19 IF '$GET(COMP)
Begin DoDot:1
+20 SET VAR="COMP"
SET SUB=1
End DoDot:1
+21 IF '$TEST
Begin DoDot:1
+22 SET VAR="SUB"
End DoDot:1
+23 SET @VAR=1
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("NAMESPACE ID"))
+24 SET @VAR=2
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("UNIVERSAL ID"))
+25 SET @VAR=3
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("UNIVERSAL ID TYPE"))
+26 QUIT
+27 ;
SETCNE(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;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.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required, pass-by-reference) These subscripts may be passed:
+7 ; "ID" - the identifier
+8 ; "TEXT" -
+9 ; "SYSTEM" - name of the code system
+10 ; "ALTERNATE ID" - alternate identifier
+11 ; "ALTERNATE TEXT"
+12 ; "ALTERNATE SYSTEM" - name of the alternate coding system
+13 ; "SYSTEM VERSION" - version ID of the coding system
+14 ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
+15 ; "ORIGINAL TEXT"
+16 ; FIELD (required) the sequence # of the field
+17 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+18 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
+19 ;Output:
+20 ; SEG - segment that is being built
+21 DO SETCODE^HLOAPI2(.SEG,.VALUE,.FIELD,.COMP,.REP)
+22 QUIT
+23 ;
SETCWE(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;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.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required, pass-by-reference) These subscripts may be passed:
+7 ; "ID" - the identifier
+8 ; "TEXT" -
+9 ; "SYSTEM" - name of the code system
+10 ; "ALTERNATE ID" - alternate identifier
+11 ; "ALTERNATE TEXT"
+12 ; "ALTERNATE SYSTEM" - name of the alternate coding system
+13 ; "SYSTEM VERSION" - version ID of the coding system
+14 ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
+15 ; "ORIGINAL TEXT"
+16 ; FIELD (required) the sequence # of the field
+17 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+18 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
+19 ;Output:
+20 ; SEG - segment that is being built
+21 DO SETCODE^HLOAPI2(.SEG,.VALUE,.FIELD,.COMP,.REP)
+22 QUIT
+23 ;
SETAD(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;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.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required, pass-by-reference) These subscripts may be passed:
+7 ; "STREET1" -street address
+8 ; "STREET2" - other designation
+9 ; "CITY"
+10 ; "STATE" - state or province
+11 ; "ZIP" - zip or postal code
+12 ; "COUNTRY"
+13 ; "TYPE" - address type
+14 ; "OTHER" - other geographic designation
+15 ; FIELD (required) the sequence # of the field
+16 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+17 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
+18 ;Output:
+19 ; SEG - segment that is being built
+20 ;
+21 NEW SUB,VAR
+22 if '$GET(FIELD)
QUIT
+23 if '$GET(REP)
SET REP=1
+24 IF '$GET(COMP)
Begin DoDot:1
+25 SET VAR="COMP"
SET SUB=1
End DoDot:1
+26 IF '$TEST
Begin DoDot:1
+27 SET VAR="SUB"
End DoDot:1
+28 SET @VAR=1
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("STREET1"))
+29 SET @VAR=2
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("STREET2"))
+30 SET @VAR=3
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("CITY"))
+31 SET @VAR=4
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("STATE"))
+32 SET @VAR=5
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("ZIP"))
+33 SET @VAR=6
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("COUNTRY"))
+34 SET @VAR=7
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("TYPE"))
+35 SET @VAR=8
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("OTHER"))
+36 QUIT
+37 ;
+38 ;** P146 START CJM
SETXPN(SEG,VALUE,FIELD,COMP,REP) ;
+1 ;Sets an XPN data type (extended person name) into the segment in the specified field.
+2 ;IF the component is specified, then the data type is 'demoted' to a component, and its components are 'demoted' to subcomponents.
+3 ;
+4 ;Input:
+5 ; SEG - (required, pass by reference) The array where the seg is being built.
+6 ; VALUE (required, pass-by-reference) These subscripts may be passed:
+7 ; "FAMILY"
+8 ; "GIVEN" first name
+9 ; "SECOND" second and further names or initials
+10 ; "SUFFIX" (e.g., JR)
+11 ; "PREFIX" (e.g., DR)
+12 ; "DEGREE" (e.g., MD)
+13 ; FIELD (required) the sequence # of the field
+14 ; COMP (optional) If specified, the data type is 'demoted' to a component value.
+15 ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
+16 ;Output:
+17 ; SEG - segment that is being built
+18 ;
+19 NEW SUB,VAR
+20 if '$GET(FIELD)
QUIT
+21 if '$GET(REP)
SET REP=1
+22 IF '$GET(COMP)
Begin DoDot:1
+23 SET VAR="COMP"
SET SUB=1
End DoDot:1
+24 IF '$TEST
Begin DoDot:1
+25 SET VAR="SUB"
End DoDot:1
+26 SET @VAR=1
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("FAMILY"))
+27 SET @VAR=2
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("GIVEN"))
+28 SET @VAR=3
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("SECOND"))
+29 SET @VAR=4
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("SUFFIX"))
+30 SET @VAR=5
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("PREFIX"))
+31 SET @VAR=6
SET SEG(FIELD,REP,COMP,SUB)=$GET(VALUE("DEGREE"))
+32 QUIT
+33 ;**P146 END CJM