INHUT ; FRW ; 7 May 99 11:24; HL7 utilities
;;3.01;BHL IHS Interfaces with GIS;**16**;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;
;All linetags in this program are supported and may be called
;by aapplication software
;
COMP() ;EP - Return HL7 component separator
Q:$L($G(INSUBDEL)) INSUBDEL
Q:$L($G(SUBDELIM)) SUBDELIM
;Q "\" orig
Q $S($G(BHLMIEN):$E($G(^INTHL7M(BHLMIEN,"EC")),1,1),1:"^") ;cmi/maw md
;
FIELD() ;EP - Return HL7 field separator
Q:$L($G(INDELIM)) INDELIM
Q:$L($G(DELIM)) DELIM
;Q "^" orig
Q $S($G(BHLMIEN):$G(^INTHL7M(BHLMIEN,"FS")),1:"|") ;cmi/maw mod
;
SUBCOMP() ;EP - Subcomponent separator
Q:$L($G(INSUBCOM)) INSUBCOM
;Q "&" orig
Q $S($G(BHLMIEN):$E($G(^INTHL7M(BHLMIEN,"EC")),3,3),1:"\") ;cmi/maw md
;
REP() ;EP - Repetition separator
;Q "|" orig
Q $S($G(BHLMIEN):$E($G(^INTHL7M(BHLMIEN,"EC")),2,2),1:"~") ;cmi/maw md
;
ESC() ;EP - Escape Character
;Q "~" orig
Q $S($G(BHLMIEN):$E($G(^INTHL7M(BHLMIEN,"EC")),4,4),1:"&") ;cmi/maw md
Q
;
CE(INTCE,FILE,CODE,INDELIMS,INENC,INDIR) ;Entry point to transform to coded entry data type
;INPUT:
; INTCE - ien of coded entry in format ien or ien ; file ; coding system
; FILE - File number in format NN or global ref in format ^GL(
; CODE - Coding system
; INDELIMS - Delimeter values
; INENC - 0 Don't encode, 1 encode
; INDIR - O Outbound, I Inbound
;OUTPUT:
; ien\value\coding system
; note: the actual delimiter may not be "\"
;
Q $$CE^INHUT1(.INTCE,.FILE,.CODE,.INDELIMS,.INENC,.INDIR)
;
CM(INTCE,FILE,CODE,INDELIMS,INENC,INDIR) ;Entry point to transform to composite data type
;INPUT: same as CE module
;OUTPUT:
; internal value (i.e. .001 field) \ external value (i.e. .01 field)
;
Q $$CM^INHUT1($G(INTCE),$G(FILE),$G(CODE),.INDELIMS,.INENC,.INDIR)
;
CN(INTCE,FILE,CODE,INDELIMS,INENC,INDIR) ;Entry point to transform to composite person name data type
;INPUT: same as CE module
;OUTPUT:
; internal value (i.e. .001 field) \ formatted person name
;
Q $$CN^INHUT1($G(INTCE),$G(FILE),$G(CODE),.INDELIMS,.INENC,.INDIR)
;
PN(NAME,INDELIMS,INENC,INDIR) ;Transform person name to HL7 formatted person name
;INPUT:
; NAME - name in format LAST,FIRST MI
; INDELIMS - Delimeter values
; INENC - 0 Don't encode, 1 encode
; INDIR - O Outbound, I Inbound
;OUTPUT:
; function - name in format LAST\FIRST\MI
;
Q $$PN^INHUT1(NAME,.INDELIMS,.INENC,.INDIR)
;
HLPN(NAME,COMP,INDELIMS,INENC,INDIR) ;EP - Transform HL7 formatted person name to person name
;INPUT:
; NAME - name in format LAST\FIRST\MI\SUFFIX
; COMP - HL7 component seperator
; INDELIMS - Delimeter values
; INENC - 0 Don't encode, 1 encode
; INDIR - I Inbound
;OUTPUT:
; function - name in format LAST,FIRST MI SU
;
Q $$HLPN^INHUT1(NAME,$G(COMP),.INDELIMS,.INENC,.INDIR)
;
DATE(X,TS) ;Transform fileman date/time to HL7 date/time stamp
;INPUT:
; X - date in any fileman or external format
; TS - include time [ 1 - yes ; 0 - no (default) ]
;OUPUT:
; function - date/time in HL7 format
;
Q:$G(TS) $$TS^INHUT1(X)
Q $$DT^INHUT1(X)
;
HDATE(X,TS,VA) ;EP - Transform HL7 date/time format to internal fileman format
;INPUT:
; X - date/time in HL7 format
; TS - control variable - similiar to %DT
; used as %DT when validating data
; TS [ "T" allow time
; TS [ "S" allow seconds
; VA - validate data ( 1 - yes ; 0 - no )
;OUPUT:
; function - date/time in fileman format
; X - same as function (pass by ref)
; VA - is data valid (pbr) ( 1 - valid ; 0 - invalid )
;
Q $$HDT^INHUT1(.X,.TS,.VA)
;
CL(X,INDELIMS,INENC,INDIR) ;Transform hospital location to coded location data type
;INPUT:
; X - hospital location ien _ ";" _ division ien (opt.)
; INDELIMS - Delimeter values
; INENC - 0 Don't encode, 1 encode
; INDIR - O Outbound, I Inbound
;OUTPUT:
; function - location and division in CE format
;
Q $$CL^INHUT1(X,.INDELIMS,.INENC,.INDIR)
;
CC(X,INDELIMS,INENC,INDIR) ;Transform MEPRS to charge code data type
;INPUT:
; X - MEPRS iend _ ";" _ charge amount (opt.)
; INDELIMS - Delimeter values
; INENC - 0 Don't encode, 1 encode
; INDIR - O Outbound, I Inbound
;OUTPUT:
; function - charge code \ MEPRS ien \ MEPRS code \ 99MEP
;
Q $$CC^INHUT1(X,.INDELIMS,.INENC,.INDIR)
;
CRB(X,INDELIMS,INENC,INDIR) ;Transform room-bed & location code room-bed data type
;INPUT:
; X -> room-bed (opt.) _ ";" _ hos loc ien (opt.)
; INDELIMS - Delimeter values
; INENC - 0 Don't encode, 1 encode
; INDIR - O Outbound, I Inbound
;
;OUTPUT:
; function - ward location (CE) \ Room-Bed \ \ MTF Code
;
Q $$CRB^INHUT1($G(X),.INDELIMS,.INENC,.INDIR)
;
RCVSCRN(INSRCTL,INSRDATA,INA,INDA) ; Default Inbound Receiver screen.
; Called by: Receiver SRMC code for inbound BPC, Dest or TT entries.
; D RCVSCRN^INHUT(.INSRCTL,.INSRDATA,.INA,.INDA)
; See called routine for comments.
D RCVSCRN^INHUT5(.INSRCTL,.INSRDATA,.INA,.INDA)
Q
;
LOG(INFN,INIEN,INSRMC,INUIF,INLOG) ; Log error message in UIF or IEF
D LOG^INHUT6(.INFN,.INIEN,.INSRMC,.INUIF,.INLOG)
Q
;
GETDEST(INACKTT,INA,INACKDST,INACKUIF) ; $$function
; Called by: SCRIPT GENERATOR MESSAGE file, Outgoing Initial MUMPS
; Code field, S INDEST=$$GETDEST^INHUT(INTT,.INA,INDEST)
; See called routine for comments.
Q $$GETDEST^INHUT7(INACKTT,.INA,$G(INACKDST),$G(INACKUIF))
;
GETSEG(INUIF,INSEGNM,INSTANCE) ; Get an HL7 Segment
Q $$GETSEG^INHUT2(.INUIF,.INSEGNM,.INSTANCE)
;
PARSEG(INSRCTL,INSEGNM) ; Parse an HL7 segment (from GETSEG.)
D PARSEG^INHUT2(.INSRCTL,.INSEGNM)
Q
;
SUBESC(INREC,INDEL,INB) ;Substitute escape delimeters to and from HL7
; spec
;Input:
; INREC - Portion of HL7 MSG to check
; INDEL(opt) = FSRET values - each position is critical
; ie S INDEL="^\|~&"
; or
; array of delimiters
; S INDEL("F")="^"
; S INDEL("S")="\"
; S INDEL("R")="|"
; S INDEL("E")="~"
; S INDEL("T")="&"
; INB - I inbound, O outbound
;Returns - Record with replace values
Q $$SUBESC^INHUT7(INREC,.INDEL,.INB)
CNVDLM(INREC) ;Convert delimeters to HL7 specifications if in record
; Input: INREC - Portion of HL7 MSG to check
; Returns - Record with replace values
;
Q $$CNVDLM^INHUT7(INREC)
;
BPSTAT(INBKGNM,INSRVR) ;-determine status of GIS background process, given name
;Input: INBKGNM - name of background process to determine status
; INSRVR - server number (not currently supported)
;Output: Status message string of given background process name
;
Q $$BPSTAT^INHUT2($G(INBKGNM),$G(INSRVR))
;
TIMEIO(X,INP,INCV,IN24,INOUT) ;Convert time to input or output
;Input:
; X - date/time
; INP(opt) - Precision Y=year, L=month, D=day, H=hour, M=minute,S=second
; 1=Auto precision
; INCV(opt) - 1 convert, 0 don't convert, 2 convert no 2nd component
; 3 convert 2.3
; outbound - INOUT flag set to 0
; IN24(opt) - 0 do nothing, 1 - add 1 day set time to 0000
; 2 - subtract one second, 3 - subtract one minute
; inbound - INOUT flag set to 1
; 0 - do nothing, 1 - subtract 1 day set time to 2400
; 2 - add one second, 3 - add one minute
; INOUT - 0 or null outbound - converts from fileman to HL7
; 1 inbound - converts from HL7 to fileman
;Output:
; INP - Precision
;
;External Input:
; (opt) INSUBDEL - Sub delimeter
;Returns:
; function date/time in converted format
;
;Output
; INP (val) - Precision
Q $$TIMEIO^INHUT10(X,.INP,INCV,IN24,INOUT)
MRGINA(INOA,INA) ;Merge INOA array into INA array
; Used by Query Response capability
; Input: INA = Application team INA array
; INOA = Values used by GIS for processing responses
; Output: Consolidated INA array used for processing responses
M INA=INOA
Q
APPACK(INUIF,INAKMES,INASTAT,INERMSG) ;User API to ACKLOG^INHU
;This routine is documented in APPACK^INHUT7
D APPACK^INHUT7(INUIF,$G(INAKMES),$G(INASTAT),$G(INERMSG))
Q
;
TASKNUM(INSEQ) ; return task number for a given seq. #
;
Q $$TASKNUM^INTQRY($G(INSEQ))
INHUT ; FRW ; 7 May 99 11:24; HL7 utilities
+1 ;;3.01;BHL IHS Interfaces with GIS;**16**;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;
+4 ;All linetags in this program are supported and may be called
+5 ;by aapplication software
+6 ;
COMP() ;EP - Return HL7 component separator
+1 IF $LENGTH($GET(INSUBDEL))
QUIT INSUBDEL
+2 IF $LENGTH($GET(SUBDELIM))
QUIT SUBDELIM
+3 ;Q "\" orig
+4 ;cmi/maw md
QUIT $SELECT($GET(BHLMIEN):$EXTRACT($GET(^INTHL7M(BHLMIEN,"EC")),1,1),1:"^")
+5 ;
FIELD() ;EP - Return HL7 field separator
+1 IF $LENGTH($GET(INDELIM))
QUIT INDELIM
+2 IF $LENGTH($GET(DELIM))
QUIT DELIM
+3 ;Q "^" orig
+4 ;cmi/maw mod
QUIT $SELECT($GET(BHLMIEN):$GET(^INTHL7M(BHLMIEN,"FS")),1:"|")
+5 ;
SUBCOMP() ;EP - Subcomponent separator
+1 IF $LENGTH($GET(INSUBCOM))
QUIT INSUBCOM
+2 ;Q "&" orig
+3 ;cmi/maw md
QUIT $SELECT($GET(BHLMIEN):$EXTRACT($GET(^INTHL7M(BHLMIEN,"EC")),3,3),1:"\")
+4 ;
REP() ;EP - Repetition separator
+1 ;Q "|" orig
+2 ;cmi/maw md
QUIT $SELECT($GET(BHLMIEN):$EXTRACT($GET(^INTHL7M(BHLMIEN,"EC")),2,2),1:"~")
+3 ;
ESC() ;EP - Escape Character
+1 ;Q "~" orig
+2 ;cmi/maw md
QUIT $SELECT($GET(BHLMIEN):$EXTRACT($GET(^INTHL7M(BHLMIEN,"EC")),4,4),1:"&")
+3 QUIT
+4 ;
CE(INTCE,FILE,CODE,INDELIMS,INENC,INDIR) ;Entry point to transform to coded entry data type
+1 ;INPUT:
+2 ; INTCE - ien of coded entry in format ien or ien ; file ; coding system
+3 ; FILE - File number in format NN or global ref in format ^GL(
+4 ; CODE - Coding system
+5 ; INDELIMS - Delimeter values
+6 ; INENC - 0 Don't encode, 1 encode
+7 ; INDIR - O Outbound, I Inbound
+8 ;OUTPUT:
+9 ; ien\value\coding system
+10 ; note: the actual delimiter may not be "\"
+11 ;
+12 QUIT $$CE^INHUT1(.INTCE,.FILE,.CODE,.INDELIMS,.INENC,.INDIR)
+13 ;
CM(INTCE,FILE,CODE,INDELIMS,INENC,INDIR) ;Entry point to transform to composite data type
+1 ;INPUT: same as CE module
+2 ;OUTPUT:
+3 ; internal value (i.e. .001 field) \ external value (i.e. .01 field)
+4 ;
+5 QUIT $$CM^INHUT1($GET(INTCE),$GET(FILE),$GET(CODE),.INDELIMS,.INENC,.INDIR)
+6 ;
CN(INTCE,FILE,CODE,INDELIMS,INENC,INDIR) ;Entry point to transform to composite person name data type
+1 ;INPUT: same as CE module
+2 ;OUTPUT:
+3 ; internal value (i.e. .001 field) \ formatted person name
+4 ;
+5 QUIT $$CN^INHUT1($GET(INTCE),$GET(FILE),$GET(CODE),.INDELIMS,.INENC,.INDIR)
+6 ;
PN(NAME,INDELIMS,INENC,INDIR) ;Transform person name to HL7 formatted person name
+1 ;INPUT:
+2 ; NAME - name in format LAST,FIRST MI
+3 ; INDELIMS - Delimeter values
+4 ; INENC - 0 Don't encode, 1 encode
+5 ; INDIR - O Outbound, I Inbound
+6 ;OUTPUT:
+7 ; function - name in format LAST\FIRST\MI
+8 ;
+9 QUIT $$PN^INHUT1(NAME,.INDELIMS,.INENC,.INDIR)
+10 ;
HLPN(NAME,COMP,INDELIMS,INENC,INDIR) ;EP - Transform HL7 formatted person name to person name
+1 ;INPUT:
+2 ; NAME - name in format LAST\FIRST\MI\SUFFIX
+3 ; COMP - HL7 component seperator
+4 ; INDELIMS - Delimeter values
+5 ; INENC - 0 Don't encode, 1 encode
+6 ; INDIR - I Inbound
+7 ;OUTPUT:
+8 ; function - name in format LAST,FIRST MI SU
+9 ;
+10 QUIT $$HLPN^INHUT1(NAME,$GET(COMP),.INDELIMS,.INENC,.INDIR)
+11 ;
DATE(X,TS) ;Transform fileman date/time to HL7 date/time stamp
+1 ;INPUT:
+2 ; X - date in any fileman or external format
+3 ; TS - include time [ 1 - yes ; 0 - no (default) ]
+4 ;OUPUT:
+5 ; function - date/time in HL7 format
+6 ;
+7 IF $GET(TS)
QUIT $$TS^INHUT1(X)
+8 QUIT $$DT^INHUT1(X)
+9 ;
HDATE(X,TS,VA) ;EP - Transform HL7 date/time format to internal fileman format
+1 ;INPUT:
+2 ; X - date/time in HL7 format
+3 ; TS - control variable - similiar to %DT
+4 ; used as %DT when validating data
+5 ; TS [ "T" allow time
+6 ; TS [ "S" allow seconds
+7 ; VA - validate data ( 1 - yes ; 0 - no )
+8 ;OUPUT:
+9 ; function - date/time in fileman format
+10 ; X - same as function (pass by ref)
+11 ; VA - is data valid (pbr) ( 1 - valid ; 0 - invalid )
+12 ;
+13 QUIT $$HDT^INHUT1(.X,.TS,.VA)
+14 ;
CL(X,INDELIMS,INENC,INDIR) ;Transform hospital location to coded location data type
+1 ;INPUT:
+2 ; X - hospital location ien _ ";" _ division ien (opt.)
+3 ; INDELIMS - Delimeter values
+4 ; INENC - 0 Don't encode, 1 encode
+5 ; INDIR - O Outbound, I Inbound
+6 ;OUTPUT:
+7 ; function - location and division in CE format
+8 ;
+9 QUIT $$CL^INHUT1(X,.INDELIMS,.INENC,.INDIR)
+10 ;
CC(X,INDELIMS,INENC,INDIR) ;Transform MEPRS to charge code data type
+1 ;INPUT:
+2 ; X - MEPRS iend _ ";" _ charge amount (opt.)
+3 ; INDELIMS - Delimeter values
+4 ; INENC - 0 Don't encode, 1 encode
+5 ; INDIR - O Outbound, I Inbound
+6 ;OUTPUT:
+7 ; function - charge code \ MEPRS ien \ MEPRS code \ 99MEP
+8 ;
+9 QUIT $$CC^INHUT1(X,.INDELIMS,.INENC,.INDIR)
+10 ;
CRB(X,INDELIMS,INENC,INDIR) ;Transform room-bed & location code room-bed data type
+1 ;INPUT:
+2 ; X -> room-bed (opt.) _ ";" _ hos loc ien (opt.)
+3 ; INDELIMS - Delimeter values
+4 ; INENC - 0 Don't encode, 1 encode
+5 ; INDIR - O Outbound, I Inbound
+6 ;
+7 ;OUTPUT:
+8 ; function - ward location (CE) \ Room-Bed \ \ MTF Code
+9 ;
+10 QUIT $$CRB^INHUT1($GET(X),.INDELIMS,.INENC,.INDIR)
+11 ;
RCVSCRN(INSRCTL,INSRDATA,INA,INDA) ; Default Inbound Receiver screen.
+1 ; Called by: Receiver SRMC code for inbound BPC, Dest or TT entries.
+2 ; D RCVSCRN^INHUT(.INSRCTL,.INSRDATA,.INA,.INDA)
+3 ; See called routine for comments.
+4 DO RCVSCRN^INHUT5(.INSRCTL,.INSRDATA,.INA,.INDA)
+5 QUIT
+6 ;
LOG(INFN,INIEN,INSRMC,INUIF,INLOG) ; Log error message in UIF or IEF
+1 DO LOG^INHUT6(.INFN,.INIEN,.INSRMC,.INUIF,.INLOG)
+2 QUIT
+3 ;
GETDEST(INACKTT,INA,INACKDST,INACKUIF) ; $$function
+1 ; Called by: SCRIPT GENERATOR MESSAGE file, Outgoing Initial MUMPS
+2 ; Code field, S INDEST=$$GETDEST^INHUT(INTT,.INA,INDEST)
+3 ; See called routine for comments.
+4 QUIT $$GETDEST^INHUT7(INACKTT,.INA,$GET(INACKDST),$GET(INACKUIF))
+5 ;
GETSEG(INUIF,INSEGNM,INSTANCE) ; Get an HL7 Segment
+1 QUIT $$GETSEG^INHUT2(.INUIF,.INSEGNM,.INSTANCE)
+2 ;
PARSEG(INSRCTL,INSEGNM) ; Parse an HL7 segment (from GETSEG.)
+1 DO PARSEG^INHUT2(.INSRCTL,.INSEGNM)
+2 QUIT
+3 ;
SUBESC(INREC,INDEL,INB) ;Substitute escape delimeters to and from HL7
+1 ; spec
+2 ;Input:
+3 ; INREC - Portion of HL7 MSG to check
+4 ; INDEL(opt) = FSRET values - each position is critical
+5 ; ie S INDEL="^\|~&"
+6 ; or
+7 ; array of delimiters
+8 ; S INDEL("F")="^"
+9 ; S INDEL("S")="\"
+10 ; S INDEL("R")="|"
+11 ; S INDEL("E")="~"
+12 ; S INDEL("T")="&"
+13 ; INB - I inbound, O outbound
+14 ;Returns - Record with replace values
+15 QUIT $$SUBESC^INHUT7(INREC,.INDEL,.INB)
CNVDLM(INREC) ;Convert delimeters to HL7 specifications if in record
+1 ; Input: INREC - Portion of HL7 MSG to check
+2 ; Returns - Record with replace values
+3 ;
+4 QUIT $$CNVDLM^INHUT7(INREC)
+5 ;
BPSTAT(INBKGNM,INSRVR) ;-determine status of GIS background process, given name
+1 ;Input: INBKGNM - name of background process to determine status
+2 ; INSRVR - server number (not currently supported)
+3 ;Output: Status message string of given background process name
+4 ;
+5 QUIT $$BPSTAT^INHUT2($GET(INBKGNM),$GET(INSRVR))
+6 ;
TIMEIO(X,INP,INCV,IN24,INOUT) ;Convert time to input or output
+1 ;Input:
+2 ; X - date/time
+3 ; INP(opt) - Precision Y=year, L=month, D=day, H=hour, M=minute,S=second
+4 ; 1=Auto precision
+5 ; INCV(opt) - 1 convert, 0 don't convert, 2 convert no 2nd component
+6 ; 3 convert 2.3
+7 ; outbound - INOUT flag set to 0
+8 ; IN24(opt) - 0 do nothing, 1 - add 1 day set time to 0000
+9 ; 2 - subtract one second, 3 - subtract one minute
+10 ; inbound - INOUT flag set to 1
+11 ; 0 - do nothing, 1 - subtract 1 day set time to 2400
+12 ; 2 - add one second, 3 - add one minute
+13 ; INOUT - 0 or null outbound - converts from fileman to HL7
+14 ; 1 inbound - converts from HL7 to fileman
+15 ;Output:
+16 ; INP - Precision
+17 ;
+18 ;External Input:
+19 ; (opt) INSUBDEL - Sub delimeter
+20 ;Returns:
+21 ; function date/time in converted format
+22 ;
+23 ;Output
+24 ; INP (val) - Precision
+25 QUIT $$TIMEIO^INHUT10(X,.INP,INCV,IN24,INOUT)
MRGINA(INOA,INA) ;Merge INOA array into INA array
+1 ; Used by Query Response capability
+2 ; Input: INA = Application team INA array
+3 ; INOA = Values used by GIS for processing responses
+4 ; Output: Consolidated INA array used for processing responses
+5 MERGE INA=INOA
+6 QUIT
APPACK(INUIF,INAKMES,INASTAT,INERMSG) ;User API to ACKLOG^INHU
+1 ;This routine is documented in APPACK^INHUT7
+2 DO APPACK^INHUT7(INUIF,$GET(INAKMES),$GET(INASTAT),$GET(INERMSG))
+3 QUIT
+4 ;
TASKNUM(INSEQ) ; return task number for a given seq. #
+1 ;
+2 QUIT $$TASKNUM^INTQRY($GET(INSEQ))