HLOPRS2 ;ALB/CJM-HL7 - Developer API's for parsing messages(continued) ;05/12/2009
 ;;1.6;HEALTH LEVEL SEVEN;**131,146**;Oct 13, 1995;Build 16
 ;
GETTS(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets a segment value that is a timestamp in HL7 format and converts it 
 ;to FileMan format. IF the segment value included the timezone, it is
 ;the timestamp is converted to local time.
 ;
 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 ;
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a  call to $$NEXTSEG^HLOPRS.
 ;  FIELD - The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (pass-by-reference) The date/time in FileMan format.
 ;  VALUE("PRECISION") Expected values are:
 ;           "S" - second
 ;           "M" - minute
 ;           "H" - hour
 ;           "D" - day
 ;           "L" - month
 ;           "Y" - year
 ;           "" - precision not specified
 ;   Note:  FM does not allow greater precision than seconds, so this API will round off to the second.
 ;
 N TIME,PREC,VAR
 Q:'$G(FIELD)
 I '$G(COMP) D
 .S VAR="COMP",SUB=1
 E  D
 .S VAR="SUB"
 S:'$G(REP) REP=1
 S @VAR=1,TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=2,PREC=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S VALUE=$$HL7TFM^XLFDT(TIME)
 I '$L(PREC) D
 .I $L(+TIME)>12 S PREC="S" Q
 .I $L(+TIME)>10 S PREC="M" Q
 .I $L(+TIME)>8 S PREC="H" Q
 .I $L(+TIME)>6 S PREC="D" Q
 .I $L(+TIME)>4 S PREC="L" Q
 .I $L(+TIME)=4 S PREC="Y" Q
 S VALUE("PRECISION")=PREC
 Q
 ;
GETDT(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets a segment value that is a date in HL7 format and converts it to FileMan format.
 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a  call to $$NEXTSEG^HLOPRS.
 ;  FIELD - The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - the occurrence# (optional, defaults to 1)  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (pass-by-reference) The date/time in FileMan format.
 ;  VALUE("PRECISION") - Expected values are:
 ;           "S" - second (not valid for DT)
 ;           "M" - minute (not valid for DT)
 ;           "H" - hour (not valid for DT)
 ;           "D" - day
 ;           "L" - month
 ;           "Y" - year
 ;           "" - not specified
 ;
 N TIME,PREC,VAR
 Q:'$G(FIELD)
 I '$G(COMP) D
 .S VAR="COMP",SUB=1
 E  D
 .S VAR="SUB"
 S:'$G(REP) REP=1
 S @VAR=1,TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S VALUE=$$HL7TFM^XLFDT(TIME)
 S PREC=""
 D
 .I $L(+TIME)>12 S PREC="S" Q
 .I $L(+TIME)>10 S PREC="M" Q
 .I $L(+TIME)>8 S PREC="H" Q
 .I $L(+TIME)>6 S PREC="D" Q
 .I $L(+TIME)>4 S PREC="L" Q
 .I $L(+TIME)=4 S PREC="Y" Q
 S VALUE("PRECISION")=PREC
 Q
 ;
GETCE(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets an CE data type(Coded Element, HL7 Section Reference 2.9.8) from the specified field.
 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 ;  FIELD (required) The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 ;    "ID" - the identifier
 ;    "TEXT" - 
 ;    "SYSTEM" - name of the code system
 ;    "ALTERNATE ID" - alternate identifier
 ;    "ALTERNATE TEXT"
 ;    "ALTERNATE SYSTEM" - name of the alternate coding system
 ;
 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,VALUE("ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=2,VALUE("TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=3,VALUE("SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=4,VALUE("ALTERNATE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=5,VALUE("ALTERNATE TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=6,VALUE("ALTERNATE SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 Q
 ;
GETHD(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets an HD data type (Hierarchic Designator, HL7 Section Reference 2.9.21) from the specified field.
 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 ;  FIELD (required) The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 ;    "NAMESPACE ID"
 ;    "UNIVERSAL ID"
 ;    "UNIVERSAL ID TYPE"
 ;
 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,VALUE("NAMESPACE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=2,VALUE("UNIVERSAL ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=3,VALUE("UNIVERSAL ID TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 Q
 ;
GETCNE(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets an CNE data type (Coded With No Exceptions, HL7 Section Reference 2.9.8) from the specified field.
 ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 ;  FIELD (required) The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 ;    "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"
 ;
 D GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
 Q
 ;
GETCWE(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets an CWE data type (Coded With Exceptions, HL7 Section Reference 2.9.11) from the specified field.
 ;IF the component is specified, then the component is parsed for the data type rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 ;  FIELD (required) The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 ;    "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"
 D GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
 Q
 ;
GETAD(SEG,VALUE,FIELD,COMP,REP) ;
 ;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.
 ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 ;  FIELD (required) The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 ;    "STREET1" -street address
 ;    "STREET2" - other designation
 ;    "CITY"
 ;    "STATE" - state or province
 ;    "ZIP" - zip or postal code
 ;    "COUNTRY"
 ;    "TYPE"  - address type
 ;    "OTHER" - other geographic designation
 ;
 N SUB,VAR
 Q:'$G(FIELD)
 I '$G(COMP) D
 .S VAR="COMP",SUB=1
 E  D
 .S VAR="SUB"
 S:'$G(REP) REP=1
 S @VAR=1,VALUE("STREET1")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=2,VALUE("STREET2")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=3,VALUE("CITY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=4,VALUE("STATE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=5,VALUE("ZIP")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=6,VALUE("COUNTRY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=7,VALUE("TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=8,VALUE("OTHER")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 Q
 ;
 ;**P146 START CJM
GETXPN(SEG,VALUE,FIELD,COMP,REP) ;
 ;Gets an XPN data type (Extended Persons Name, HL7 Section Reference 2.9.1) from the specified field.
 ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
 ;
 ;Input:
 ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 ;  FIELD (required) The sequence # of the field.
 ;  COMP (optional) If specified, the data type is parsed as a component  value.
 ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 ;Output:
 ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 ;    "FAMILY"
 ;    "GIVEN" first name
 ;    "SECOND" second and further names or initials
 ;    "SUFFIX" (e.g., JR)
 ;    "PREFIX" (e.g., DR)
 ;    "DEGREE" (e.g., MD)
 ;
 N SUB,VAR
 Q:'$G(FIELD)
 I '$G(COMP) D
 .S VAR="COMP",SUB=1
 E  D
 .S VAR="SUB"
 S:'$G(REP) REP=1
 S @VAR=1,VALUE("FAMILY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=2,VALUE("GIVEN")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=3,VALUE("SECOND")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=4,VALUE("SUFFIX")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=5,VALUE("PREFIX")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 S @VAR=6,VALUE("DEGREE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 Q
 ;** P146 END CJM
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLOPRS2   11008     printed  Sep 23, 2025@19:35:06                                                                                                                                                                                                    Page 2
HLOPRS2   ;ALB/CJM-HL7 - Developer API's for parsing messages(continued) ;05/12/2009
 +1       ;;1.6;HEALTH LEVEL SEVEN;**131,146**;Oct 13, 1995;Build 16
 +2       ;
GETTS(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets a segment value that is a timestamp in HL7 format and converts it 
 +2       ;to FileMan format. IF the segment value included the timezone, it is
 +3       ;the timestamp is converted to local time.
 +4       ;
 +5       ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 +6       ;
 +7       ;
 +8       ;Input:
 +9       ;  SEG - (required, pass by reference) The array returned by a  call to $$NEXTSEG^HLOPRS.
 +10      ;  FIELD - The sequence # of the field.
 +11      ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +12      ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +13      ;Output:
 +14      ;  VALUE  (pass-by-reference) The date/time in FileMan format.
 +15      ;  VALUE("PRECISION") Expected values are:
 +16      ;           "S" - second
 +17      ;           "M" - minute
 +18      ;           "H" - hour
 +19      ;           "D" - day
 +20      ;           "L" - month
 +21      ;           "Y" - year
 +22      ;           "" - precision not specified
 +23      ;   Note:  FM does not allow greater precision than seconds, so this API will round off to the second.
 +24      ;
 +25       NEW TIME,PREC,VAR
 +26       if '$GET(FIELD)
               QUIT 
 +27       IF '$GET(COMP)
               Begin DoDot:1
 +28               SET VAR="COMP"
                   SET SUB=1
               End DoDot:1
 +29      IF '$TEST
               Begin DoDot:1
 +30               SET VAR="SUB"
               End DoDot:1
 +31       if '$GET(REP)
               SET REP=1
 +32       SET @VAR=1
           SET TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +33       SET @VAR=2
           SET PREC=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +34       SET VALUE=$$HL7TFM^XLFDT(TIME)
 +35       IF '$LENGTH(PREC)
               Begin DoDot:1
 +36               IF $LENGTH(+TIME)>12
                       SET PREC="S"
                       QUIT 
 +37               IF $LENGTH(+TIME)>10
                       SET PREC="M"
                       QUIT 
 +38               IF $LENGTH(+TIME)>8
                       SET PREC="H"
                       QUIT 
 +39               IF $LENGTH(+TIME)>6
                       SET PREC="D"
                       QUIT 
 +40               IF $LENGTH(+TIME)>4
                       SET PREC="L"
                       QUIT 
 +41               IF $LENGTH(+TIME)=4
                       SET PREC="Y"
                       QUIT 
               End DoDot:1
 +42       SET VALUE("PRECISION")=PREC
 +43       QUIT 
 +44      ;
GETDT(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets a segment value that is a date in HL7 format and converts it to FileMan format.
 +2       ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a  call to $$NEXTSEG^HLOPRS.
 +6       ;  FIELD - The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - the occurrence# (optional, defaults to 1)  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (pass-by-reference) The date/time in FileMan format.
 +11      ;  VALUE("PRECISION") - Expected values are:
 +12      ;           "S" - second (not valid for DT)
 +13      ;           "M" - minute (not valid for DT)
 +14      ;           "H" - hour (not valid for DT)
 +15      ;           "D" - day
 +16      ;           "L" - month
 +17      ;           "Y" - year
 +18      ;           "" - not specified
 +19      ;
 +20       NEW TIME,PREC,VAR
 +21       if '$GET(FIELD)
               QUIT 
 +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       if '$GET(REP)
               SET REP=1
 +27       SET @VAR=1
           SET TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +28       SET VALUE=$$HL7TFM^XLFDT(TIME)
 +29       SET PREC=""
 +30       Begin DoDot:1
 +31           IF $LENGTH(+TIME)>12
                   SET PREC="S"
                   QUIT 
 +32           IF $LENGTH(+TIME)>10
                   SET PREC="M"
                   QUIT 
 +33           IF $LENGTH(+TIME)>8
                   SET PREC="H"
                   QUIT 
 +34           IF $LENGTH(+TIME)>6
                   SET PREC="D"
                   QUIT 
 +35           IF $LENGTH(+TIME)>4
                   SET PREC="L"
                   QUIT 
 +36           IF $LENGTH(+TIME)=4
                   SET PREC="Y"
                   QUIT 
           End DoDot:1
 +37       SET VALUE("PRECISION")=PREC
 +38       QUIT 
 +39      ;
GETCE(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets an CE data type(Coded Element, HL7 Section Reference 2.9.8) from the specified field.
 +2       ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 +6       ;  FIELD (required) The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 +11      ;    "ID" - the identifier
 +12      ;    "TEXT" - 
 +13      ;    "SYSTEM" - name of the code system
 +14      ;    "ALTERNATE ID" - alternate identifier
 +15      ;    "ALTERNATE TEXT"
 +16      ;    "ALTERNATE SYSTEM" - name of the alternate coding system
 +17      ;
 +18       NEW SUB,VAR
 +19       if '$GET(FIELD)
               QUIT 
 +20       if '$GET(REP)
               SET REP=1
 +21       IF '$GET(COMP)
               Begin DoDot:1
 +22               SET VAR="COMP"
                   SET SUB=1
               End DoDot:1
 +23      IF '$TEST
               Begin DoDot:1
 +24               SET VAR="SUB"
               End DoDot:1
 +25       SET @VAR=1
           SET VALUE("ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +26       SET @VAR=2
           SET VALUE("TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +27       SET @VAR=3
           SET VALUE("SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +28       SET @VAR=4
           SET VALUE("ALTERNATE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +29       SET @VAR=5
           SET VALUE("ALTERNATE TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +30       SET @VAR=6
           SET VALUE("ALTERNATE SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +31       QUIT 
 +32      ;
GETHD(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets an HD data type (Hierarchic Designator, HL7 Section Reference 2.9.21) from the specified field.
 +2       ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 +6       ;  FIELD (required) The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 +11      ;    "NAMESPACE ID"
 +12      ;    "UNIVERSAL ID"
 +13      ;    "UNIVERSAL ID TYPE"
 +14      ;
 +15       NEW SUB,VAR
 +16       if '$GET(FIELD)
               QUIT 
 +17       if '$GET(REP)
               SET REP=1
 +18       IF '$GET(COMP)
               Begin DoDot:1
 +19               SET VAR="COMP"
                   SET SUB=1
               End DoDot:1
 +20      IF '$TEST
               Begin DoDot:1
 +21               SET VAR="SUB"
               End DoDot:1
 +22       SET @VAR=1
           SET VALUE("NAMESPACE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +23       SET @VAR=2
           SET VALUE("UNIVERSAL ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +24       SET @VAR=3
           SET VALUE("UNIVERSAL ID TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +25       QUIT 
 +26      ;
GETCNE(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets an CNE data type (Coded With No Exceptions, HL7 Section Reference 2.9.8) from the specified field.
 +2       ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 +6       ;  FIELD (required) The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 +11      ;    "ID" - the identifier
 +12      ;    "TEXT" - 
 +13      ;    "SYSTEM" - name of the code system
 +14      ;    "ALTERNATE ID" - alternate identifier
 +15      ;    "ALTERNATE TEXT"
 +16      ;    "ALTERNATE SYSTEM" - name of the alternate coding system
 +17      ;    "SYSTEM VERSION" - version ID of the coding system
 +18      ;    "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
 +19      ;    "ORIGINAL TEXT"
 +20      ;
 +21       DO GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
 +22       QUIT 
 +23      ;
GETCWE(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets an CWE data type (Coded With Exceptions, HL7 Section Reference 2.9.11) from the specified field.
 +2       ;IF the component is specified, then the component is parsed for the data type rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 +6       ;  FIELD (required) The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 +11      ;    "ID" - the identifier
 +12      ;    "TEXT" - 
 +13      ;    "SYSTEM" - name of the code system
 +14      ;    "ALTERNATE ID" - alternate identifier
 +15      ;    "ALTERNATE TEXT"
 +16      ;    "ALTERNATE SYSTEM" - name of the alternate coding system
 +17      ;    "SYSTEM VERSION" - version ID of the coding system
 +18      ;    "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
 +19      ;    "ORIGINAL TEXT"
 +20       DO GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
 +21       QUIT 
 +22      ;
GETAD(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;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.
 +2       ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 +6       ;  FIELD (required) The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 +11      ;    "STREET1" -street address
 +12      ;    "STREET2" - other designation
 +13      ;    "CITY"
 +14      ;    "STATE" - state or province
 +15      ;    "ZIP" - zip or postal code
 +16      ;    "COUNTRY"
 +17      ;    "TYPE"  - address type
 +18      ;    "OTHER" - other geographic designation
 +19      ;
 +20       NEW SUB,VAR
 +21       if '$GET(FIELD)
               QUIT 
 +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       if '$GET(REP)
               SET REP=1
 +27       SET @VAR=1
           SET VALUE("STREET1")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +28       SET @VAR=2
           SET VALUE("STREET2")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +29       SET @VAR=3
           SET VALUE("CITY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +30       SET @VAR=4
           SET VALUE("STATE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +31       SET @VAR=5
           SET VALUE("ZIP")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +32       SET @VAR=6
           SET VALUE("COUNTRY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +33       SET @VAR=7
           SET VALUE("TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +34       SET @VAR=8
           SET VALUE("OTHER")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +35       QUIT 
 +36      ;
 +37      ;**P146 START CJM
GETXPN(SEG,VALUE,FIELD,COMP,REP) ;
 +1       ;Gets an XPN data type (Extended Persons Name, HL7 Section Reference 2.9.1) from the specified field.
 +2       ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
 +3       ;
 +4       ;Input:
 +5       ;  SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
 +6       ;  FIELD (required) The sequence # of the field.
 +7       ;  COMP (optional) If specified, the data type is parsed as a component  value.
 +8       ;  REP - The occurrence # (optional, defaults to 1).  For a non-repeating fields, this parameter is not necessary.
 +9       ;Output:
 +10      ;  VALUE  (required, pass-by-reference) These subscripts are returned:
 +11      ;    "FAMILY"
 +12      ;    "GIVEN" first name
 +13      ;    "SECOND" second and further names or initials
 +14      ;    "SUFFIX" (e.g., JR)
 +15      ;    "PREFIX" (e.g., DR)
 +16      ;    "DEGREE" (e.g., MD)
 +17      ;
 +18       NEW SUB,VAR
 +19       if '$GET(FIELD)
               QUIT 
 +20       IF '$GET(COMP)
               Begin DoDot:1
 +21               SET VAR="COMP"
                   SET SUB=1
               End DoDot:1
 +22      IF '$TEST
               Begin DoDot:1
 +23               SET VAR="SUB"
               End DoDot:1
 +24       if '$GET(REP)
               SET REP=1
 +25       SET @VAR=1
           SET VALUE("FAMILY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +26       SET @VAR=2
           SET VALUE("GIVEN")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +27       SET @VAR=3
           SET VALUE("SECOND")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +28       SET @VAR=4
           SET VALUE("SUFFIX")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +29       SET @VAR=5
           SET VALUE("PREFIX")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +30       SET @VAR=6
           SET VALUE("DEGREE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
 +31       QUIT 
 +32      ;** P146 END CJM