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

IVMPTRN3.m

Go to the documentation of this file.
  1. IVMPTRN3 ;ALB/KCL - SEND INITIAL TRANSMISSION TO IVM CENTER ; 9/24/03
  1. ;;2.0;INCOME VERIFICATION MATCH;**1,9,34,92**; 21-OCT-94
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. FILE ; - call HL7 to send batch of segments
  1. ;
  1. I IVMCT'>0 Q
  1. ;
  1. N HLRESLT
  1. ;
  1. ; - send batch of HL7 messages
  1. D GENERATE^HLMA(HLEID,"GB",1,.HLRESLT,MTIEN)
  1. ;
  1. K ^TMP("HLS",$J)
  1. S IVMGTOT=$G(IVMGTOT)+HLEVN
  1. S (HLEVN,IVMCT)=0
  1. Q
  1. ;
  1. FILE1 ; - call HL7 to send batch of segments
  1. ; (V1.6 - call this if non-ack batch but still has an MSA segment.)
  1. ; Called by ^IVMPTRN and ^IVMPTRN7 with ^TMP("HLS",$J) global set.
  1. ; Must convert ^TMP("HLS" into ^TMP("HLA" for GENACK^HLMA1 to work.
  1. ;
  1. I IVMCT'>0 Q
  1. ;
  1. N HLP,HLRESLTA
  1. S HLEIDS=$O(^ORD(101,HLEID,775,"B",0))
  1. ;
  1. ; - send batch of HL7 messages
  1. K ^TMP("HLA",$J)
  1. M ^TMP("HLA",$J)=^TMP("HLS",$J)
  1. D GENACK^HLMA1(HLEID,MTIEN,HLEIDS,"GB",1,.HLRESLTA,.HLP)
  1. ;
  1. K ^TMP("HLS",$J)
  1. K ^TMP("HLA",$J)
  1. S IVMGTOT=$G(IVMGTOT)+HLEVN
  1. S (HLEVN,IVMCT)=0
  1. Q
  1. ;
  1. FILEPT(DFN,IVMYR,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
  1. ;Description: File patient in IVM PATIENT (#301.5) file and file
  1. ;TRANSMISSION LOG entry.
  1. ;
  1. ;Input:
  1. ; DFN - ien of record in the PATIENT file.
  1. ; IVMYR - income year of the ORU~Z07 message.
  1. ; WHEN - date/time message sent, in FM format.
  1. ; MSGID - message id used for message, in format used by MESSAGE CONTROL ID field.
  1. ; EVENTS () - an array of reasons for transmission, pass by reference.
  1. ; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
  1. ; EVENTS(" "DCD")=1 if transmission due to DCD criteria, 0 otherwise
  1. ; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
  1. ; MTSTAT - pointer to the MEANS TEST STATUS file. Is the status of the patient's means test at the time of the transmission for the income year of the transmission.
  1. ; INSSTAT - 1 if the patient had active insurance at the time of the transmission, 0 otherwise.
  1. ;
  1. N IVMPTR,DGSENFLG
  1. ;
  1. ; - ignore security checks in MAS (DGSEC)
  1. S DGSENFLG=1
  1. ;
  1. ;find or create entry in IVM PATIENT file
  1. S IVMPTR=$$FIND^IVMPLOG(DFN,IVMYR)
  1. S:'IVMPTR IVMPTR=$$LOG^IVMPLOG(DFN,IVMYR,.EVENTS)
  1. Q:'IVMPTR
  1. ;
  1. ; Check the 301.5 record for Transmission Status
  1. N TRSTAT S TRSTAT=+$P(^IVM(301.5,IVMPTR,0),U,3)
  1. ;
  1. ; If this record is not updated, update it only
  1. I 'TRSTAT D UPDTLOG(IVMPTR,WHEN,MSGID,.EVENTS,MTSTAT,INSSTAT)
  1. ;
  1. ; If this record is already updated, check all other records
  1. ; for this patient that should be updated.
  1. I TRSTAT D
  1. .N NXTPTR,NXTYR S NXTPTR=0
  1. .F S NXTPTR=$O(^IVM(301.5,"B",DFN,NXTPTR)) Q:'NXTPTR D
  1. ..Q:NXTPTR=IVMPTR
  1. ..S TRSTAT=+$P(^IVM(301.5,NXTPTR,0),U,3)
  1. ..Q:TRSTAT
  1. ..S NXTYR=$P(^IVM(301.5,NXTPTR,0),U,2)
  1. ..I $$LOG^IVMPLOG(DFN,NXTYR,.EVENTS)
  1. ..D UPDTLOG(NXTPTR,WHEN,MSGID,.EVENTS,MTSTAT,INSSTAT)
  1. ;
  1. Q
  1. ;
  1. UPDTLOG(IVMPTR,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
  1. ; Update record to TRANSMITTED, and remove duplicates
  1. ;
  1. ; Update the IVM PATIENT (#301.5) record to a TRANSMITTED status.
  1. I $$CLEAR^IVMPLOG(IVMPTR,WHEN)
  1. ;
  1. ; Add an entry in the IVM TRANSMISSION LOG (#301.6) File.
  1. I $$LOG^IVMTLOG(IVMPTR,WHEN,MSGID,.EVENTS,MTSTAT,INSSTAT)
  1. ;
  1. D DUP(DFN,IVMYR,IVMPTR) ; remove duplicates
  1. ;
  1. Q
  1. ;
  1. DUP(DFN,IVMYR,IVMPTR) ; remove duplicate entries in file 301.5
  1. ;
  1. ; Input - IVMPTR - IEN of original entry in file 301.5
  1. ; DFN - IEN of PATIENT file
  1. ; IVMYR - income year
  1. ;
  1. N DA,DIE,DIK,DR,IVMIEN,X,Y
  1. ;
  1. S IVMIEN=IVMPTR
  1. F S IVMIEN=$O(^IVM(301.5,"APT",DFN,IVMYR,IVMIEN)) Q:'IVMIEN D
  1. .;remove 301.5 entry
  1. .I $$DELETE^IVMPLOG2(IVMIEN) F DA=0:0 S DA=$O(^IVM(301.6,"B",IVMIEN,DA)) Q:'DA D ; reset ptrs
  1. ..S DIE="^IVM(301.6,",DR=".01///^S X=IVMPTR" D ^DIE
  1. Q