source: FOIAVistA/tag/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGHTRTX.m@ 821

Last change on this file since 821 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1DGHTRTX ;ALB/JRC - Home Telehealth HL7 Message Monitoring Routine ;10 January 2005 ; 9/14/06 12:52pm
2 ;;5.3;Registration;**644**;Aug 13, 1993;Build 11
3 ;
4 ;This routine when tasked will run at predetermined time intervals
5 ;and check to see if there are any HTH HL7 messages that have not
6 ;received an application acknowledgment. If it finds messages that
7 ;have not received AAs, it will retransmit the HL7 messages up to the
8 ;number of times defined in the "DG HTH # OF RETRANSMITS" parameter.
9 ;If no AA is received after the 5th try an alert is sent to the
10 ;DGHTERR mailgroup. After the 5th try an extended wait time is used
11 ;(12 hours) and the process starts a new.
12 ;
13EN ;entry point from tasked option, $O thru home telehealth file
14 ;(#391.31) "HTHNOACK" xref and find mnessages to retransmit
15 N MSGID,NODE,STATUS,RECORD,TRANS,TYPE,ERROR,RETRANS,DTIME,XTIME
16 N DGCOUNT,DGDATE,CNT
17 S (MSGID,NODE,TRANS,ERROR)="",TYPE=1,CNT=0
18 K ^TMP($J,"DGHT")
19 ;Get number of allowed retransmissions from parameter file
20 S RETRANS=$$GET^XPAR("SYS","DG HTH # OF RETRANSMITS")
21 ;Get time interval parameters, convert them to seconds
22 S DTIME=$$GET^XPAR("SYS","DG HTH DEFAULT WAIT TIME")*60
23 S XTIME=$$GET^XPAR("SYS","DG HTH EXTENDED WAIT TIME")*60
24 ;Resolve record to update using MSGID cross reference
25 F S MSGID=$O(^DGHT(391.31,"HTHNOACK",MSGID)) Q:MSGID="" D
26 .S RECORD=$O(^DGHT(391.31,"D",MSGID,0)) Q:'RECORD
27 .S TRANS=$O(^DGHT(391.31,"D",MSGID,RECORD,0)) Q:'TRANS
28 .S NODE=$G(^DGHT(391.31,"HTHNOACK",MSGID,RECORD,TRANS))
29 .Q:NODE=""
30 .S DGCOUNT=$P(NODE,U,1),DGDATE=$P(NODE,U,2)
31 .;Check outgoing message status
32 .; 0 = message doesn't exist
33 .; 1 = waiting in queue
34 .; 1.5 = opening connection
35 .; 1.7 = awaiting response, # of retries
36 .; 2 = awaiting application ack
37 .; 3 = successfully completed
38 .; 4 = error
39 .; 8 = being generated
40 .; 9 = awaiting processing
41 .S STATUS=+$$MSGSTAT^HLUTIL(MSGID)
42 .;If status=3 kill xref and quit
43 .I STATUS=3 D KILLXREF^DGHTXREF(MSGID) Q
44 .D CHKMSG
45 I $O(^TMP($J,"DGHT",0)) D MESSAGE K ^TMP($J)
46 Q
47 ;
48RTX ;Retransmit message
49 N X,DGDATE
50 S X=$$MSGACT^HLUTIL(MSGID,2)
51 ;Update counter and trans date
52 S DGDATE=$$NOW^XLFDT()
53 D SETXREF^DGHTXREF(MSGID,1,1)
54 Q
55 ;
56MESSAGE ;Build bulletin and send to mail group
57 ; Input: Home telehealth patient record
58 ; Output:
59 ;
60 N MSGTEXT,XMTEXT,XMSUB,XMY,XMCHAN,XMZ,XMDUZ,MSGTYPE,NODE0,NODE1
61 N RECORD,TNODE
62 ;Get records from ^tmp global
63 S (RECORD,CNT)=0 F S RECORD=$O(^TMP($J,"DGHT",RECORD)) Q:'RECORD D
64 .S TRANS=0 F S TRANS=$O(^TMP($J,"DGHT",RECORD,TRANS)) Q:'TRANS D
65 ..S TNODE=^TMP($J,"DGHT",RECORD,TRANS)
66 ..S MSGID=$P(TNODE,U,2),ERROR=$P(TNODE,U,2)
67 ..;Get 0th node and trans nodes
68 ..S NODE0=$G(^DGHT(391.31,RECORD,0))
69 ..S NODE1=$G(^DGHT(391.31,RECORD,"TRAN",TRANS,0)),MSGTYPE=$P(NODE1,U,4)
70 ..S MSGTYPE=$S(MSGTYPE="A":"Sign-up/Activation",MSGTYPE="I":"Inactivation",1:""),CNT=CNT+1
71 ..S MSGTEXT(CNT)="Home Telehealth "_MSGTYPE_" was REJECTED",CNT=CNT+1
72 ..S MSGTEXT(CNT)=" ",CNT=CNT+1
73 ..S MSGTEXT(CNT)="Date: "_$$FMTE^XLFDT($$NOW^XLFDT(),1),CNT=CNT+1
74 ..S MSGTEXT(CNT)="Patient: "_$$GET1^DIQ(2,$P(NODE0,U,2),.01,"E")
75 ..S CNT=CNT+1,MSGTEXT(CNT+1)="Message ID: "_MSGID,CNT=CNT+1
76 ..S MSGTEXT(CNT)="Error Code: "_ERROR,CNT=CNT+1
77 ..S MSGTEXT(CNT)="",CNT=CNT+1
78 ;Send message to mail group
79 S XMSUB="Home Telehealth Patient "_MSGTYPE_" Reject"
80 S XMTEXT="MSGTEXT("
81 S XMY("G.DGHTERR")=""
82 S XMCHAN=1
83 S XMDUZ="Home Telehealth Patient "_MSGTYPE
84 D ^XMD
85 Q
86 ;
87CHKMSG ;Check message for retransmission
88 N DIFF
89 S DIFF=$$FMDIFF^XLFDT($$NOW^XLFDT(),DGDATE,2)
90 I DGCOUNT<RETRANS D Q
91 .I DIFF>DTIME D RTX I (DGCOUNT+1)=RETRANS D Q
92 ..S ERROR=$S('STATUS:"HL7 MESSAGE DOES NOT EXIST. REQUIRES MANUAL RETRANSMISSION",1:"DEFAULT MAXIMUM RETRANSMISSIONS REACHED")
93 ..S ^TMP($J,"DGHT",RECORD,TRANS)=MSGID_U_ERROR
94 I DIFF>XTIME S DGCOUNT=0 D RTX Q
95 Q
Note: See TracBrowser for help on using the repository browser.