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

MHV7BU.m

Go to the documentation of this file.
  1. MHV7BU ;WAS/EFJ - HL7 message builder UTILITY ; [12/14/06 11:10am]
  1. ;;1.0;My HealtheVet;**2,29**;July 10, 2017;Build 73
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ; Utilities common to message and segment builders.
  1. ;
  1. Q
  1. ;
  1. PID3(PID,ICN,DFN,SSN) ;Build PID3 - Patient Identifier List
  1. ; Populates PID array with Patient Identifier List Entries for
  1. ; ICN, DFN, and SSN.
  1. ;
  1. ; Integration Agreements:
  1. ; 10112 : $$SITE^VASITE
  1. ;
  1. ; Input:
  1. ; ICN, DFN, SSN - Identifiers
  1. ;
  1. ; Output:
  1. ; PID - PID array
  1. ;
  1. N STATION,IDCNT
  1. S STATION=$P($$SITE^VASITE,"^",3)
  1. S IDCNT=0
  1. I ICN'="" D
  1. . S IDCNT=IDCNT+1
  1. . S PID(3,IDCNT,1)=ICN ;Patient ID - ICN
  1. . S PID(3,IDCNT,4,1)="USVHA" ;assigning authority ID
  1. . S PID(3,IDCNT,4,3)="HL70363" ;assigning authority type
  1. . S PID(3,IDCNT,5)="NI" ;Patient ID type
  1. . S PID(3,IDCNT,6,1)="VA FACILITY ID" ;assigning facility
  1. . S PID(3,IDCNT,6,2)=STATION ;Station number
  1. . S PID(3,IDCNT,6,3)="L" ;facility ID type
  1. ;
  1. I DFN'="" D
  1. . S IDCNT=IDCNT+1
  1. . S PID(3,IDCNT,1)=DFN ;Patient ID - DFN
  1. . S PID(3,IDCNT,4,1)="USVHA" ;assigning authority ID
  1. . S PID(3,IDCNT,4,3)="HL70363" ;assigning authority type
  1. . S PID(3,IDCNT,5)="PI" ;Patient ID type
  1. . S PID(3,IDCNT,6,1)="VA FACILITY ID" ;assigning facility
  1. . S PID(3,IDCNT,6,2)=STATION ;Station number
  1. . S PID(3,IDCNT,6,3)="L" ;facility ID type
  1. ;
  1. I SSN'="" D
  1. . S IDCNT=IDCNT+1
  1. . S PID(3,IDCNT,1)=SSN ;Patient ID - SSN
  1. . S PID(3,IDCNT,4,1)="USSSA" ;assigning authority ID
  1. . S PID(3,IDCNT,4,3)="HL70363" ;assigning authority type
  1. . S PID(3,IDCNT,5)="SS" ;Patient ID type
  1. . S PID(3,IDCNT,6,1)="VA FACILITY ID" ;assigning facility
  1. . S PID(3,IDCNT,6,2)=STATION ;Station number
  1. . S PID(3,IDCNT,6,3)="L" ;facility ID type
  1. Q
  1. ;
  1. FMTNAME(NAME,SUBSEG,HL,DATATYPE) ;Format comma/space delimited name
  1. ; Populates SUBSEG array with formatted and escaped name components
  1. ; based on the DATATYPE passed. XCN types and XPN types differ in
  1. ; that XCN has an ID in the first component effectively shifting the
  1. ; name components by one.
  1. ;
  1. ; Integration Agreements:
  1. ; 3065 : NAMEFMT^XLFNAME
  1. ;
  1. ; Input:
  1. ; NAME - FileMan formatted name Ex: PATIENT,FIRST M
  1. ; HL - HL7 package array variable
  1. ; DATATYPE - HL7 data type to be formatted Ex: XCN, XPN
  1. ;
  1. ; Output:
  1. ; SUBSEG - Array to hold the formatted name.
  1. ;
  1. ; Example Usage:
  1. ; S NAME="SMITH,BOB A"
  1. ; K NMARR
  1. ; D FMTNAME^MHV7BU(NAME,.NMARR,.HL,"XCN")
  1. ; M PD1(4,1)=NMARR
  1. ;
  1. N OFFSET
  1. S OFFSET=(DATATYPE="XCN")
  1. S NAME=$$NAMEFMT^XLFNAME(.NAME,"F","DSP")
  1. S SUBSEG(1+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",1),.HL) ;family
  1. S SUBSEG(2+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",2),.HL) ;given
  1. S SUBSEG(3+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",3),.HL) ;middle
  1. S SUBSEG(4+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",4),.HL) ;suffix
  1. S SUBSEG(5+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",5),.HL) ;prefix
  1. S SUBSEG(6+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",6),.HL) ;degree
  1. Q
  1. ;
  1. FMTNAME2(IEN,FILE,SUBSEG,HL,DATATYPE) ;Lookup and format name
  1. ; Looks up name components based on IEN and FILE passed.
  1. ; Populates SUBSEG array with formatted and escaped name components
  1. ; based on the DATATYPE passed. XCN types and XPN types differ in
  1. ; that XCN has an ID in the first component effectively shifting the
  1. ; name components by one.
  1. ;
  1. ; Integration Agreements:
  1. ; 3065 : NAMEFMT^XLFNAME
  1. ;
  1. ; Input:
  1. ; IEN - IEN of patient/person in FILE
  1. ; FILE - File number of file Ex: 2 - PATIENT file
  1. ; HL - HL7 package array variable
  1. ; DATATYPE - HL7 data type to be formatted Ex: XCN, XPN
  1. ;
  1. ; Output:
  1. ; SUBSEG - Array to hold the formatted name.
  1. ;
  1. ; Example Usage:
  1. ; K NMARR
  1. ; D FMTNAME^MHV7BU(DFN,2,.NMARR,.HL,"XPN")
  1. ; M PID(5,1)=NMARR
  1. ;
  1. N NAME,OFFSET
  1. S OFFSET=(DATATYPE="XCN")
  1. S NAME("FILE")=FILE,NAME("FIELD")=.01,NAME("IENS")=IEN_","
  1. S NAME=$$NAMEFMT^XLFNAME(.NAME,"F","DSP")
  1. S SUBSEG(1+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",1),.HL) ;family
  1. S SUBSEG(2+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",2),.HL) ;given
  1. S SUBSEG(3+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",3),.HL) ;middle
  1. S SUBSEG(4+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",4),.HL) ;suffix
  1. S SUBSEG(5+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",5),.HL) ;prefix
  1. S SUBSEG(6+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",6),.HL) ;degree
  1. Q
  1. ;
  1. FMTNAME3(IEN,FILE,SUBSEG,HL,DATATYPE) ;Lookup and format name
  1. ;JAZZ#409966 -NeW Function for Names with Space not showing in SM queries
  1. ;========================================================================
  1. ; Looks up name components based on IEN and FILE passed.
  1. ; Populates SUBSEG array with formatted and escaped name components
  1. ; based on the DATATYPE passed. XCN types and XPN types differ in
  1. ; that XCN has an ID in the first component effectively shifting the
  1. ; name components by one.
  1. ;
  1. ; Integration Agreements:
  1. ; 3065 : NAMEFMT^XLFNAME
  1. ;
  1. ; Input:
  1. ; IEN - IEN of patient/person in FILE
  1. ; FILE - File number of file Ex: 2 - PATIENT file
  1. ; HL - HL7 package array variable
  1. ; DATATYPE - HL7 data type to be formatted Ex: XCN, XPN
  1. ;
  1. ; Output:
  1. ; SUBSEG - Array to hold the formatted name.
  1. ;
  1. ; Example Usage:
  1. ; K NMARR
  1. ; D FMTNAME^MHV7BU(DFN,2,.NMARR,.HL,"XPN")
  1. ; M PID(5,1)=NMARR
  1. ;
  1. N NAME,OFFSET
  1. S OFFSET=(DATATYPE="XCN")
  1. S NAME("FILE")=FILE,NAME("FIELD")=.01,NAME("IENS")=IEN_","
  1. S NAME=$$HLNAME^XLFNAME(.NAME)
  1. S SUBSEG(1+OFFSET)=$$ESCAPE^MHV7U($P(NAME,"^",1),.HL) ;family
  1. S SUBSEG(2+OFFSET)=$$ESCAPE^MHV7U($P(NAME,"^",2),.HL) ;given
  1. S SUBSEG(3+OFFSET)=$$ESCAPE^MHV7U($P(NAME,"^",3),.HL) ;middle
  1. S SUBSEG(4+OFFSET)=$$ESCAPE^MHV7U($P(NAME,"^",4),.HL) ;suffix
  1. S SUBSEG(5+OFFSET)=$$ESCAPE^MHV7U($P(NAME,"^",5),.HL) ;prefix
  1. S SUBSEG(6+OFFSET)=$$ESCAPE^MHV7U($P(NAME,"^",6),.HL) ;degree
  1. Q
  1. ;
  1. FMTHL7(DT) ;Convert Fileman formatted dates to HL7 format
  1. ; Handles imprecise dates properly because $$FMTHL7^XLFDT does not.
  1. ; Strips Timezone offset
  1. ;
  1. ; Integration Agreements:
  1. ; 10103 : FMTHL7^XLFDT
  1. ;
  1. ; Input:
  1. ; DT - Fileman formatted date/time
  1. ;
  1. ; Output: Returns HL7 formatted date/time
  1. ;
  1. S DT=$$FMTHL7^XLFDT(DT)
  1. I $E(DT,7,8)="00" S DT=$E(DT,1,6)
  1. I $E(DT,5,6)="00" S DT=$E(DT,1,4)
  1. S DT=$P(DT,"-")
  1. S DT=$P(DT,"+")
  1. Q DT
  1. ;