IVMPTRN7 ;ALB/KCL/CJM/PHH/BAJ,TDM - HL7 FULL DATA TRANSMISSION (Z07) BUILDER ; 8/15/08 10:30am
;;2.0;INCOME VERIFICATION MATCH;**9,11,24,34,74,88,105,115,142**;OCT 21, 1994;Build 3
;
;
FULL(DFN,IVMMTDT,EVENTS,IVMCT,IVMGTOT,IVMFLL,IVMNOMSH,IVMREC,IVMQUERY) ;
;Description: This entry point will be used to create an HL7 "Full Data Transmission" message for a patient. Transmission of these messages will be in a batch of 1-100 individual HL7 messages.
;
;Input:
; DFN - Patient IEN
; IVMMTDT - date of the patient's Means Test or Copay Test
; EVENTS () - an array of reasons for transmission, pass by reference.
; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
; EVENTS(" "DCD")=1 if transmission due to DCD criteria, 0 otherwise
; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
; IVMCT - count of segments transmitted, pass by reference
; IVMGTOT - count of batchs transmitted, pass by reference
; IVMFLL - (optional), flag for creating MSA, QRD segments for FULL query transmission, $G(IVMFLL) means yes
; IVMNOMSH - (optional), if IVMNOMSH=1, means the MSH segment should not be built
; IVMREC - (optional), if $G(IVMFLL), then this variable will contain the internal entry number of Query Income Year #301.9001 mult.
; IVMQUERY - array passed in by reference where
; IVMQUERY("LTD") -- # of the QUERY that is currently open or
; undefined, zero, or null if no QUERY opened for
; last treatment date
; IVMQUERY("OVIS") -- # of the QUERY that is currently open or
; undefined, zero, or null if no QUERY opened for
; finding outpatient visits
;
;HL7 variables as defined by call to INIT^IVMUFNC:
; HLEVN - HL7 message event counter
; HLSDT - a flag that indicates that the data to be sent is stored in the ^TMP("HLS") global array.
;
;The following variables returned by the INIT^HLTRANS entry point:
; HLNDAP - Non-DHCP Application Pointer from file 770
; HLNDAP0 - Zero node from file 770 corresponding to HLNDAP
; HLDAP - DHCP Application Pointer from file 771
; HLDAN - The DHCP Application Name (.01 field, file 771) for HLDAP
; HLPID - HL7 processing ID from file 770
; HLVER - HL7 version number from file 770
; HLFS - HL7 Field Separater from the 'FS' node of file 771
; HLECH - HL7 Encoding Characters from the 'EC' node of file 771
; HLQ - Double quotes ("") for use in building HL7 segments
; HLERR - if an error is encountered, an error message is returned in the HLERR variable.
; HLDA - the internal entry number for the entry created in file 772
;
; HLDT - the transmission date/time (associated with the entry in in file 772 identified by HLDA) in internal VA FileMan format.
; HLDT1 - the same transmission date/time as the HLDT variable, only in HL7 format.
;
;Output:
; ^TMP("HLS",$J,IVMCT) - global array containing all segments of the HL7 message that the VistA application wishes to send. The HLSDT variable is defined above and the IVMCT variable is a sequential number starting at 1.
;
N DGREL,DGINC,DR,I,IVMI,IVMDFN,IVMHLMID,IVMNTE,IVMPAT,IVMQRD,X,IVMCNTID
;
; IVM*2.0*142 Quit if test patient unless ^XTMP("IVMTST","Z07",DFN) set and user wishes test patient to send a Z07 for testing purpose.
I $$TESTPAT^VADPT(DFN) Q:'$D(^XTMP("IVMTST","Z07",DFN))
; IVM*2.0*105 BAJ 10/20/2005
; Do Z07 Consistency checks and, if fail, prevent Z07 Build
I '$$EN^IVMZ07C(DFN) Q
;
; INITIALIZE HL7 1.6 VARIABLES
D INIT^HLFNC2(HLEID,.HL)
;
; quit if Pseudo SSN and not verified
; Q:'$$SNDPSSN(DFN) ;Removed by IVM*2*105
;
S DGPRIM=$$GET1^DIQ(2,DFN_",",.361)
I $G(DGPRIM)]"" S DGPRIM=$O(^DIC(8,"B",DGPRIM,0))
I $G(DGPRIM)]"" S DGPRIM=$P($G(^DIC(8,DGPRIM,0)),U,9)
I $G(DGPRIM)=14 D REM Q
;
; if count=0 and not first batch
;RMC;I IVMCT=0,$G(IVMGTOT) D FILE^HLTF
;
; HL7 event/message counter
S HLEVN=$G(HLEVN)+1
;
; CREATE SLOT FOR EACH NEW BATCH
I HLEVN=1 D
. K HLMID,MTIEN,HLDT,HLDT1
. D CREATE^HLTF(.HLMID,.MTIEN,.HLDT,.HLDT1)
;
; handle message header processing for HL7 full data trans (Z07) msg
D MSH^IVMUFNC4($G(IVMNOMSH),$G(IVMFLL),$G(IVMREC),.IVMCT,.IVMCNTID)
;
I IVMMTDT="" D
.S IVMMTDT=$P($$LST^DGMTU(DFN,DT),"^",2)
.I IVMMTDT="" S IVMMTDT=DT
;
; build HL7 Full Data Transmission (Z07) message
D BUILD^IVMPTRN8(DFN,IVMMTDT,.IVMCT,.IVMQUERY)
;
; log patient transmission
D
.N IVMSTAT
.S X=$$LST^DGMTCOU1(DFN,IVMMTDT,3)
.S IVMSTAT=$S($E($P(X,"^",2),1,3)=$E(IVMMTDT,1,3):$P($G(^DGMT(408.31,+X,0)),"^",3),1:"")
.;
.D FILEPT^IVMPTRN3(DFN,$$LYR^DGMTSCU1(IVMMTDT),HLDT,IVMCNTID,.EVENTS,IVMSTAT,IVMINS)
;
;if number of HL7 events/msgs is 100 then call HL7 pkg to transmit batch
I HLEVN=100 D
.N IVMEVENT
.; event code for Full Data Transmission
.S IVMEVENT="Z07"
.I $G(IVMFLL) D FILE1^IVMPTRN3 Q
.D FILE^IVMPTRN3
Q
;
SNDPSSN(DFN) ; check SSN and patient eligibility
;
; Input:
; DFN Patient file (#2) IEN
; Output:
; <expression> 1: Pseudo SSN and Eligibility verified or
; not a Pseudo SSN
; 0: Psuedo SSN and Eligibility Pending verification
; Pending re-verification
;
N SSN,PFLG
;
; Don't process records with corrupted nodes
I '$D(^DPT(DFN,0)) D REM Q 0
;
S SSN=$P(^DPT(DFN,0),U,9)
S PFLG=($E(SSN,$L(SSN))="P") I 'PFLG Q 1
I ($P($G(^DPT(DFN,.361)),U)="V") Q 1
;
D REM
Q 0
;
REM ; Remove Psuedo SSN from Queue
; Set TRANSMISSION STATUS to transmission not required
S PDATA(.03)=1 I $$UPD^DGENDBS(301.5,IVMDA,.PDATA,.ERR)
K PDATA,ERR
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVMPTRN7 5729 printed Oct 16, 2024@18:03:13 Page 2
IVMPTRN7 ;ALB/KCL/CJM/PHH/BAJ,TDM - HL7 FULL DATA TRANSMISSION (Z07) BUILDER ; 8/15/08 10:30am
+1 ;;2.0;INCOME VERIFICATION MATCH;**9,11,24,34,74,88,105,115,142**;OCT 21, 1994;Build 3
+2 ;
+3 ;
FULL(DFN,IVMMTDT,EVENTS,IVMCT,IVMGTOT,IVMFLL,IVMNOMSH,IVMREC,IVMQUERY) ;
+1 ;Description: This entry point will be used to create an HL7 "Full Data Transmission" message for a patient. Transmission of these messages will be in a batch of 1-100 individual HL7 messages.
+2 ;
+3 ;Input:
+4 ; DFN - Patient IEN
+5 ; IVMMTDT - date of the patient's Means Test or Copay Test
+6 ; EVENTS () - an array of reasons for transmission, pass by reference.
+7 ; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
+8 ; EVENTS(" "DCD")=1 if transmission due to DCD criteria, 0 otherwise
+9 ; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
+10 ; IVMCT - count of segments transmitted, pass by reference
+11 ; IVMGTOT - count of batchs transmitted, pass by reference
+12 ; IVMFLL - (optional), flag for creating MSA, QRD segments for FULL query transmission, $G(IVMFLL) means yes
+13 ; IVMNOMSH - (optional), if IVMNOMSH=1, means the MSH segment should not be built
+14 ; IVMREC - (optional), if $G(IVMFLL), then this variable will contain the internal entry number of Query Income Year #301.9001 mult.
+15 ; IVMQUERY - array passed in by reference where
+16 ; IVMQUERY("LTD") -- # of the QUERY that is currently open or
+17 ; undefined, zero, or null if no QUERY opened for
+18 ; last treatment date
+19 ; IVMQUERY("OVIS") -- # of the QUERY that is currently open or
+20 ; undefined, zero, or null if no QUERY opened for
+21 ; finding outpatient visits
+22 ;
+23 ;HL7 variables as defined by call to INIT^IVMUFNC:
+24 ; HLEVN - HL7 message event counter
+25 ; HLSDT - a flag that indicates that the data to be sent is stored in the ^TMP("HLS") global array.
+26 ;
+27 ;The following variables returned by the INIT^HLTRANS entry point:
+28 ; HLNDAP - Non-DHCP Application Pointer from file 770
+29 ; HLNDAP0 - Zero node from file 770 corresponding to HLNDAP
+30 ; HLDAP - DHCP Application Pointer from file 771
+31 ; HLDAN - The DHCP Application Name (.01 field, file 771) for HLDAP
+32 ; HLPID - HL7 processing ID from file 770
+33 ; HLVER - HL7 version number from file 770
+34 ; HLFS - HL7 Field Separater from the 'FS' node of file 771
+35 ; HLECH - HL7 Encoding Characters from the 'EC' node of file 771
+36 ; HLQ - Double quotes ("") for use in building HL7 segments
+37 ; HLERR - if an error is encountered, an error message is returned in the HLERR variable.
+38 ; HLDA - the internal entry number for the entry created in file 772
+39 ;
+40 ; HLDT - the transmission date/time (associated with the entry in in file 772 identified by HLDA) in internal VA FileMan format.
+41 ; HLDT1 - the same transmission date/time as the HLDT variable, only in HL7 format.
+42 ;
+43 ;Output:
+44 ; ^TMP("HLS",$J,IVMCT) - global array containing all segments of the HL7 message that the VistA application wishes to send. The HLSDT variable is defined above and the IVMCT variable is a sequential number starting at 1.
+45 ;
+46 NEW DGREL,DGINC,DR,I,IVMI,IVMDFN,IVMHLMID,IVMNTE,IVMPAT,IVMQRD,X,IVMCNTID
+47 ;
+48 ; IVM*2.0*142 Quit if test patient unless ^XTMP("IVMTST","Z07",DFN) set and user wishes test patient to send a Z07 for testing purpose.
+49 IF $$TESTPAT^VADPT(DFN)
if '$DATA(^XTMP("IVMTST","Z07",DFN))
QUIT
+50 ; IVM*2.0*105 BAJ 10/20/2005
+51 ; Do Z07 Consistency checks and, if fail, prevent Z07 Build
+52 IF '$$EN^IVMZ07C(DFN)
QUIT
+53 ;
+54 ; INITIALIZE HL7 1.6 VARIABLES
+55 DO INIT^HLFNC2(HLEID,.HL)
+56 ;
+57 ; quit if Pseudo SSN and not verified
+58 ; Q:'$$SNDPSSN(DFN) ;Removed by IVM*2*105
+59 ;
+60 SET DGPRIM=$$GET1^DIQ(2,DFN_",",.361)
+61 IF $GET(DGPRIM)]""
SET DGPRIM=$ORDER(^DIC(8,"B",DGPRIM,0))
+62 IF $GET(DGPRIM)]""
SET DGPRIM=$PIECE($GET(^DIC(8,DGPRIM,0)),U,9)
+63 IF $GET(DGPRIM)=14
DO REM
QUIT
+64 ;
+65 ; if count=0 and not first batch
+66 ;RMC;I IVMCT=0,$G(IVMGTOT) D FILE^HLTF
+67 ;
+68 ; HL7 event/message counter
+69 SET HLEVN=$GET(HLEVN)+1
+70 ;
+71 ; CREATE SLOT FOR EACH NEW BATCH
+72 IF HLEVN=1
Begin DoDot:1
+73 KILL HLMID,MTIEN,HLDT,HLDT1
+74 DO CREATE^HLTF(.HLMID,.MTIEN,.HLDT,.HLDT1)
End DoDot:1
+75 ;
+76 ; handle message header processing for HL7 full data trans (Z07) msg
+77 DO MSH^IVMUFNC4($GET(IVMNOMSH),$GET(IVMFLL),$GET(IVMREC),.IVMCT,.IVMCNTID)
+78 ;
+79 IF IVMMTDT=""
Begin DoDot:1
+80 SET IVMMTDT=$PIECE($$LST^DGMTU(DFN,DT),"^",2)
+81 IF IVMMTDT=""
SET IVMMTDT=DT
End DoDot:1
+82 ;
+83 ; build HL7 Full Data Transmission (Z07) message
+84 DO BUILD^IVMPTRN8(DFN,IVMMTDT,.IVMCT,.IVMQUERY)
+85 ;
+86 ; log patient transmission
+87 Begin DoDot:1
+88 NEW IVMSTAT
+89 SET X=$$LST^DGMTCOU1(DFN,IVMMTDT,3)
+90 SET IVMSTAT=$SELECT($EXTRACT($PIECE(X,"^",2),1,3)=$EXTRACT(IVMMTDT,1,3):$PIECE($GET(^DGMT(408.31,+X,0)),"^",3),1:"")
+91 ;
+92 DO FILEPT^IVMPTRN3(DFN,$$LYR^DGMTSCU1(IVMMTDT),HLDT,IVMCNTID,.EVENTS,IVMSTAT,IVMINS)
End DoDot:1
+93 ;
+94 ;if number of HL7 events/msgs is 100 then call HL7 pkg to transmit batch
+95 IF HLEVN=100
Begin DoDot:1
+96 NEW IVMEVENT
+97 ; event code for Full Data Transmission
+98 SET IVMEVENT="Z07"
+99 IF $GET(IVMFLL)
DO FILE1^IVMPTRN3
QUIT
+100 DO FILE^IVMPTRN3
End DoDot:1
+101 QUIT
+102 ;
SNDPSSN(DFN) ; check SSN and patient eligibility
+1 ;
+2 ; Input:
+3 ; DFN Patient file (#2) IEN
+4 ; Output:
+5 ; <expression> 1: Pseudo SSN and Eligibility verified or
+6 ; not a Pseudo SSN
+7 ; 0: Psuedo SSN and Eligibility Pending verification
+8 ; Pending re-verification
+9 ;
+10 NEW SSN,PFLG
+11 ;
+12 ; Don't process records with corrupted nodes
+13 IF '$DATA(^DPT(DFN,0))
DO REM
QUIT 0
+14 ;
+15 SET SSN=$PIECE(^DPT(DFN,0),U,9)
+16 SET PFLG=($EXTRACT(SSN,$LENGTH(SSN))="P")
IF 'PFLG
QUIT 1
+17 IF ($PIECE($GET(^DPT(DFN,.361)),U)="V")
QUIT 1
+18 ;
+19 DO REM
+20 QUIT 0
+21 ;
REM ; Remove Psuedo SSN from Queue
+1 ; Set TRANSMISSION STATUS to transmission not required
+2 SET PDATA(.03)=1
IF $$UPD^DGENDBS(301.5,IVMDA,.PDATA,.ERR)
+3 KILL PDATA,ERR
+4 QUIT