| 1 | IVMPTRN4 ;ALB/SEK - SEND RE-TRANSMISSIONS TO THE IVM CENTER ; 08/20/2003
 | 
|---|
| 2 |  ;;2.0;INCOME VERIFICATION MATCH;**9,11,17,34,66,81,86**; 21-OCT-94
 | 
|---|
| 3 |  ;;Per VHA Directive 10-93-142, this routine should not be modified.
 | 
|---|
| 4 |  ;
 | 
|---|
| 5 |  ; This routine checks STATUS field of IVM TRANSMISSION LOG file (301.6)
 | 
|---|
| 6 |  ; to see if acknowledgment of the transmission has been received from
 | 
|---|
| 7 |  ; the IVM Center.  If transmission is waiting at the site, a message is
 | 
|---|
| 8 |  ; sent to the recipients of the IVM MESSAGES mail group.  Else the
 | 
|---|
| 9 |  ; message is re-transmitted to the IVM Center.
 | 
|---|
| 10 |  ;
 | 
|---|
| 11 |  ;
 | 
|---|
| 12 | ENTRY ; Check if message transmission has not been acknowledged for the 
 | 
|---|
| 13 |  ; following date range (IVMDMT3 through  IVM14) where:
 | 
|---|
| 14 |  ;     IVMDMT3 - First Date Checked
 | 
|---|
| 15 |  ;     IVM14   - Last Date Checked
 | 
|---|
| 16 |  ;
 | 
|---|
| 17 |  S IVMDTM3=$$FMADD^XLFDT(DT,-14),IVM14=$$FMADD^XLFDT(DT,-14)
 | 
|---|
| 18 |  S IVMDTMST=+$P($G(^IVM(301.9,1,0)),"^",6)
 | 
|---|
| 19 |  S:IVMDTMST<IVM14 IVMDTMST=IVM14
 | 
|---|
| 20 |  ;
 | 
|---|
| 21 |  ; INITIALIZE HL7 VARIABLES
 | 
|---|
| 22 |  N HL,HLEID
 | 
|---|
| 23 |  S HLEID="VAMC "_$P($$SITE^VASITE,"^",3)_" ORU-Z07 SERVER"
 | 
|---|
| 24 |  S HLEID=$O(^ORD(101,"B",HLEID,0))
 | 
|---|
| 25 |  D INIT^IVMUFNC(HLEID,.HL) S HLMTN="ORU" ; Initialize variables for HL7/IVM
 | 
|---|
| 26 |  ;
 | 
|---|
| 27 |  ; check Transmission Date/Time in AB x-ref
 | 
|---|
| 28 |  ; Note 2 oddities about this loop:
 | 
|---|
| 29 |  ;   1) Only checks back 2 weeks, if somehow retransmission not done within this window then it won't be done.
 | 
|---|
| 30 |  ;   2) Assumes IVMDAT will map to exactly one msgid for HL7 message - assumption made in $$MSGN^IVMPTRN4.
 | 
|---|
| 31 |  ;
 | 
|---|
| 32 |  S IVMDAT=IVMDTMST F  S IVMDAT=$O(^IVM(301.6,"AB",IVMDAT)) Q:'IVMDAT!($P(IVMDAT,".")>IVMDTM3)  D MAILMSGN
 | 
|---|
| 33 |  ;
 | 
|---|
| 34 |  ;
 | 
|---|
| 35 |  ;transmit remaining records
 | 
|---|
| 36 |  D
 | 
|---|
| 37 |  .N IVMEVENT
 | 
|---|
| 38 |  .; event code for Full Data Transmission
 | 
|---|
| 39 |  .S IVMEVENT="Z07"
 | 
|---|
| 40 |  .D FILE^IVMPTRN3
 | 
|---|
| 41 |  ;
 | 
|---|
| 42 |  ;clean-up
 | 
|---|
| 43 |  D END^IVMPTRN
 | 
|---|
| 44 |  ;
 | 
|---|
| 45 | ENTRYQ K IVMDAT,IVMMAILF,IVMDTM3,IVMDTMST,IVM14
 | 
|---|
| 46 |  Q
 | 
|---|
| 47 |  ;
 | 
|---|
| 48 |  ;
 | 
|---|
| 49 | MAILMSGN ; Get Mailman message number related to this transmission
 | 
|---|
| 50 |  S IVMMAILN=$$MSGN(IVMDAT)  ;returns #773 IEN for v1.6
 | 
|---|
| 51 |  ;
 | 
|---|
| 52 |  Q:'IVMMAILN                                   ; if no #773 IEN found
 | 
|---|
| 53 |  ;
 | 
|---|
| 54 |  ; find if awaiting initial transmission
 | 
|---|
| 55 |  N SLLN
 | 
|---|
| 56 |  S SLLN=+$P($G(^HLMA(IVMMAILN,0)),"^",7)       ; sending logical link
 | 
|---|
| 57 |  I SLLN,$D(^HLMA("AC","O",SLLN,IVMMAILN)) D  Q
 | 
|---|
| 58 |  .Q:$G(IVMMAILF)  ; already sent message once
 | 
|---|
| 59 |  .S XMSUB="MESSAGES 'AWAITING TRANSMISSION'"
 | 
|---|
| 60 |  .S IVMTEXT(1)="HL7 message number "_IVMMAILN_" is awaiting transmission."
 | 
|---|
| 61 |  .S IVMTEXT(2)="Please call the IVM Center (Atlanta, GA) to ensure the HL7 logical links and filers are running "
 | 
|---|
| 62 |  .S IVMTEXT(3)="if the HL7 logical link and filers are running at your station."
 | 
|---|
| 63 |  .S IVMTEXT(4)=" "
 | 
|---|
| 64 |  .S IVMTEXT(5)="Please note that you may have other messages that are awaiting transmission"
 | 
|---|
| 65 |  .S IVMTEXT(6)="to the IVM Center."
 | 
|---|
| 66 |  .D MAIL^IVMUFNC()
 | 
|---|
| 67 |  .S IVMMAILF=1
 | 
|---|
| 68 |  ;
 | 
|---|
| 69 |  ; Transmission has left site - get individual patient and re-transmit
 | 
|---|
| 70 |  K IVMQUERY("LTD"),IVMQUERY("OVIS") ;Variables needed to open/close last visit date and outpt visit QUERIES
 | 
|---|
| 71 |  F IVMDA=0:0 S IVMDA=$O(^IVM(301.6,"AB",IVMDAT,IVMDA)) Q:'IVMDA  D
 | 
|---|
| 72 |  .;
 | 
|---|
| 73 |  .N IVMTLOG,EVENTS
 | 
|---|
| 74 |  .;
 | 
|---|
| 75 |  .Q:'$$GET^IVMTLOG(IVMDA,.IVMTLOG)
 | 
|---|
| 76 |  .S IVM3015P=IVMTLOG("PAT") Q:'IVM3015P
 | 
|---|
| 77 |  .S IVMNODE=$G(^IVM(301.5,+IVM3015P,0)),IVMDT=+$P(IVMNODE,"^",2),DFN=+IVMNODE
 | 
|---|
| 78 |  .I 'DFN!'IVMDT Q
 | 
|---|
| 79 |  .S IVMMTDT=($E(IVMDT,1,3)+1)_"1231.9999"
 | 
|---|
| 80 |  .I $E(IVMMTDT,1,3)'=($E(IVMDT,1,3)+1) S IVMMTDT=$E(IVMDT,1,3)+1_"0101"
 | 
|---|
| 81 |  .;
 | 
|---|
| 82 |  .M EVENTS=IVMTLOG("EVENTS")
 | 
|---|
| 83 |  .;
 | 
|---|
| 84 |  .; Prepare FULL transmission
 | 
|---|
| 85 |  .D FULL^IVMPTRN7(DFN,IVMMTDT,.EVENTS,.IVMCT,.IVMGTOT,,,,.IVMQUERY)
 | 
|---|
| 86 |  .;
 | 
|---|
| 87 |  .;change status to retransmitted
 | 
|---|
| 88 |  .I $$SETSTAT^IVMTLOG(IVMDA,2)
 | 
|---|
| 89 |  F Z="LTD","OVIS" I $G(IVMQUERY(Z)) D CLOSE^SDQ(IVMQUERY(Z)) K IVMQUERY(Z)
 | 
|---|
| 90 |  Q
 | 
|---|
| 91 |  ;
 | 
|---|
| 92 | MSGN(IVMDT) ; Find the mailman message number for an HL7 message
 | 
|---|
| 93 |  ; Input:   IVMDT  --  The date/time (301.6;.02) the msg was sent
 | 
|---|
| 94 |  ; Output:  Pointer to the message in file #773, or zero if not found
 | 
|---|
| 95 |  N IVMMSG,X S IVMMSG=0
 | 
|---|
| 96 |  S X=+$O(^IVM(301.6,"AB",IVMDT,0)),X=$G(^IVM(301.6,X,0))
 | 
|---|
| 97 |  I X S IVMMSG=$$MMN(+$P($P(X,"^",5),"-"))
 | 
|---|
| 98 | MSGNQ Q IVMMSG
 | 
|---|
| 99 |  ;
 | 
|---|
| 100 | MMN(Y) ; Do look-up on file #772 and find mail message number.
 | 
|---|
| 101 |  ;  Input:   Y  --  Message Control ID
 | 
|---|
| 102 |  ;  Output:  Mail Message Number
 | 
|---|
| 103 |  N Z S Z=0
 | 
|---|
| 104 |  S Y=$O(^HL(772,"C",Y,0))
 | 
|---|
| 105 |  I Y S Z=+$O(^HLMA("B",Y,0))  ;Y=#772 IEN, Z=#773 IEN
 | 
|---|
| 106 | MMNQ Q Z
 | 
|---|