Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLOPRS2

HLOPRS2.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. GETTS(SEG,VALUE,FIELD,COMP,REP) ;
  1. ;Gets a segment value that is a timestamp in HL7 format and converts it
  1. ;to FileMan format. IF the segment value included the timezone, it is
  1. ;the timestamp is converted to local time.
  1. ;
  1. ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
  1. ;
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to $$NEXTSEG^HLOPRS.
  1. ; FIELD - The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (pass-by-reference) The date/time in FileMan format.
  1. ; VALUE("PRECISION") Expected values are:
  1. ; "S" - second
  1. ; "M" - minute
  1. ; "H" - hour
  1. ; "D" - day
  1. ; "L" - month
  1. ; "Y" - year
  1. ; "" - precision not specified
  1. ; Note: FM does not allow greater precision than seconds, so this API will round off to the second.
  1. ;
  1. N TIME,PREC,VAR
  1. Q:'$G(FIELD)
  1. I '$G(COMP) D
  1. .S VAR="COMP",SUB=1
  1. E D
  1. .S VAR="SUB"
  1. S:'$G(REP) REP=1
  1. S @VAR=1,TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=2,PREC=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S VALUE=$$HL7TFM^XLFDT(TIME)
  1. I '$L(PREC) D
  1. .I $L(+TIME)>12 S PREC="S" Q
  1. .I $L(+TIME)>10 S PREC="M" Q
  1. .I $L(+TIME)>8 S PREC="H" Q
  1. .I $L(+TIME)>6 S PREC="D" Q
  1. .I $L(+TIME)>4 S PREC="L" Q
  1. .I $L(+TIME)=4 S PREC="Y" Q
  1. S VALUE("PRECISION")=PREC
  1. Q
  1. ;
  1. GETDT(SEG,VALUE,FIELD,COMP,REP) ;
  1. ;Gets a segment value that is a date in HL7 format and converts it to FileMan format.
  1. ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to $$NEXTSEG^HLOPRS.
  1. ; FIELD - The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - the occurrence# (optional, defaults to 1) For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (pass-by-reference) The date/time in FileMan format.
  1. ; VALUE("PRECISION") - Expected values are:
  1. ; "S" - second (not valid for DT)
  1. ; "M" - minute (not valid for DT)
  1. ; "H" - hour (not valid for DT)
  1. ; "D" - day
  1. ; "L" - month
  1. ; "Y" - year
  1. ; "" - not specified
  1. ;
  1. N TIME,PREC,VAR
  1. Q:'$G(FIELD)
  1. I '$G(COMP) D
  1. .S VAR="COMP",SUB=1
  1. E D
  1. .S VAR="SUB"
  1. S:'$G(REP) REP=1
  1. S @VAR=1,TIME=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S VALUE=$$HL7TFM^XLFDT(TIME)
  1. S PREC=""
  1. D
  1. .I $L(+TIME)>12 S PREC="S" Q
  1. .I $L(+TIME)>10 S PREC="M" Q
  1. .I $L(+TIME)>8 S PREC="H" Q
  1. .I $L(+TIME)>6 S PREC="D" Q
  1. .I $L(+TIME)>4 S PREC="L" Q
  1. .I $L(+TIME)=4 S PREC="Y" Q
  1. S VALUE("PRECISION")=PREC
  1. Q
  1. ;
  1. GETCE(SEG,VALUE,FIELD,COMP,REP) ;
  1. ;Gets an CE data type(Coded Element, HL7 Section Reference 2.9.8) from the specified field.
  1. ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
  1. ; FIELD (required) The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (required, pass-by-reference) These subscripts are returned:
  1. ; "ID" - the identifier
  1. ; "TEXT" -
  1. ; "SYSTEM" - name of the code system
  1. ; "ALTERNATE ID" - alternate identifier
  1. ; "ALTERNATE TEXT"
  1. ; "ALTERNATE SYSTEM" - name of the alternate coding system
  1. ;
  1. N SUB,VAR
  1. Q:'$G(FIELD)
  1. S:'$G(REP) REP=1
  1. I '$G(COMP) D
  1. .S VAR="COMP",SUB=1
  1. E D
  1. .S VAR="SUB"
  1. S @VAR=1,VALUE("ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=2,VALUE("TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=3,VALUE("SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=4,VALUE("ALTERNATE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=5,VALUE("ALTERNATE TEXT")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=6,VALUE("ALTERNATE SYSTEM")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. Q
  1. ;
  1. GETHD(SEG,VALUE,FIELD,COMP,REP) ;
  1. ;Gets an HD data type (Hierarchic Designator, HL7 Section Reference 2.9.21) from the specified field.
  1. ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
  1. ; FIELD (required) The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (required, pass-by-reference) These subscripts are returned:
  1. ; "NAMESPACE ID"
  1. ; "UNIVERSAL ID"
  1. ; "UNIVERSAL ID TYPE"
  1. ;
  1. N SUB,VAR
  1. Q:'$G(FIELD)
  1. S:'$G(REP) REP=1
  1. I '$G(COMP) D
  1. .S VAR="COMP",SUB=1
  1. E D
  1. .S VAR="SUB"
  1. S @VAR=1,VALUE("NAMESPACE ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=2,VALUE("UNIVERSAL ID")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=3,VALUE("UNIVERSAL ID TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. Q
  1. ;
  1. 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.
  1. ;IF the component is specified, then the component is parsed for data type rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
  1. ; FIELD (required) The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (required, pass-by-reference) These subscripts are returned:
  1. ; "ID" - the identifier
  1. ; "TEXT" -
  1. ; "SYSTEM" - name of the code system
  1. ; "ALTERNATE ID" - alternate identifier
  1. ; "ALTERNATE TEXT"
  1. ; "ALTERNATE SYSTEM" - name of the alternate coding system
  1. ; "SYSTEM VERSION" - version ID of the coding system
  1. ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
  1. ; "ORIGINAL TEXT"
  1. ;
  1. D GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
  1. Q
  1. ;
  1. 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.
  1. ;IF the component is specified, then the component is parsed for the data type rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
  1. ; FIELD (required) The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (required, pass-by-reference) These subscripts are returned:
  1. ; "ID" - the identifier
  1. ; "TEXT" -
  1. ; "SYSTEM" - name of the code system
  1. ; "ALTERNATE ID" - alternate identifier
  1. ; "ALTERNATE TEXT"
  1. ; "ALTERNATE SYSTEM" - name of the alternate coding system
  1. ; "SYSTEM VERSION" - version ID of the coding system
  1. ; "ALTERNATE SYSTEM VERSION" - version ID of the alternate coding system
  1. ; "ORIGINAL TEXT"
  1. D GETCODE^HLOPRS1(.SEG,.VALUE,.FIELD,.COMP,.REP)
  1. Q
  1. ;
  1. 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.
  1. ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
  1. ; FIELD (required) The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (required, pass-by-reference) These subscripts are returned:
  1. ; "STREET1" -street address
  1. ; "STREET2" - other designation
  1. ; "CITY"
  1. ; "STATE" - state or province
  1. ; "ZIP" - zip or postal code
  1. ; "COUNTRY"
  1. ; "TYPE" - address type
  1. ; "OTHER" - other geographic designation
  1. ;
  1. N SUB,VAR
  1. Q:'$G(FIELD)
  1. I '$G(COMP) D
  1. .S VAR="COMP",SUB=1
  1. E D
  1. .S VAR="SUB"
  1. S:'$G(REP) REP=1
  1. S @VAR=1,VALUE("STREET1")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=2,VALUE("STREET2")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=3,VALUE("CITY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=4,VALUE("STATE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=5,VALUE("ZIP")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=6,VALUE("COUNTRY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=7,VALUE("TYPE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=8,VALUE("OTHER")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. Q
  1. ;
  1. ;**P146 START CJM
  1. 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.
  1. ;IF the component is specified, then the component is parsed for the address rather than at the higher field level.
  1. ;
  1. ;Input:
  1. ; SEG - (required, pass by reference) The array returned by a call to NEXTSEG^HLOPRS.
  1. ; FIELD (required) The sequence # of the field.
  1. ; COMP (optional) If specified, the data type is parsed as a component value.
  1. ; REP - The occurrence # (optional, defaults to 1). For a non-repeating fields, this parameter is not necessary.
  1. ;Output:
  1. ; VALUE (required, pass-by-reference) These subscripts are returned:
  1. ; "FAMILY"
  1. ; "GIVEN" first name
  1. ; "SECOND" second and further names or initials
  1. ; "SUFFIX" (e.g., JR)
  1. ; "PREFIX" (e.g., DR)
  1. ; "DEGREE" (e.g., MD)
  1. ;
  1. N SUB,VAR
  1. Q:'$G(FIELD)
  1. I '$G(COMP) D
  1. .S VAR="COMP",SUB=1
  1. E D
  1. .S VAR="SUB"
  1. S:'$G(REP) REP=1
  1. S @VAR=1,VALUE("FAMILY")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=2,VALUE("GIVEN")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=3,VALUE("SECOND")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=4,VALUE("SUFFIX")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=5,VALUE("PREFIX")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. S @VAR=6,VALUE("DEGREE")=$$GET^HLOPRS(.SEG,FIELD,COMP,SUB,REP)
  1. Q
  1. ;** P146 END CJM