source: FOIAVistA/trunk/r/PATIENT_DATA_EXCHANGE-VAQ/VAQCON4.m@ 1722

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

initial load of FOIAVistA 6/30/08 version

File size: 4.5 KB
Line 
1VAQCON4 ;ALB/JRP - MESSAGE CONSTRUCTION;12-APR-93
2 ;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
3DOMAIN(TRANPTR,MESSNUM,ARRAY,OFFSET) ;CONSTRUCT DOMAIN BLOCK
4 ;INPUT : TRANPTR - Pointer to VAQ - TRANSACTION file
5 ; MESSNUM - Message number to place block into
6 ; (if 0, block will be placed in ARRAY)
7 ; ARRAY - Array to store block in (full global reference)
8 ; OFFSET - Where to begin placing information (defaults to 0)
9 ;OUTPUT : N - Number of lines in block
10 ; -1^Error_Text - Error
11 ;NOTES : If MESSNUM=0, then the block will be placed into
12 ; ARRAY(LineNumber)=Line_of_info
13 ; If MESSNUM>0 then the block will be placed into
14 ; ^XMB(3.9,MESSNUM,2,LineNumber,0)=Line_of_info
15 ;
16 ;CHECK INPUT
17 S TRANPTR=+$G(TRANPTR)
18 Q:(('TRANPTR)!('$D(^VAT(394.61,TRANPTR)))) "-1^Did not pass a valid pointer to VAQ - TRANSACTION file"
19 S MESSNUM=+$G(MESSNUM)
20 I (('MESSNUM)&($G(ARRAY)="")) Q "-1^Did not pass message number of reference to array"
21 I (MESSNUM) Q:('$D(^XMB(3.9,MESSNUM))) "-1^Valid message number not passed"
22 S OFFSET=+$G(OFFSET)
23 ;DECLARE VARIABLES
24 N TMP,TYPE,LINE,X,SENDTO,SENTFRM,STATUS
25 S LINE=OFFSET
26 ;DETERMINE MESSAGE STATUS & TYPE (USED TO DETERMINE RECEIVER OF MESSAGE)
27 S TMP=$$STATYPE^VAQCON1(TRANPTR)
28 S STATUS=$P(TMP,"^",1)
29 S TYPE=$P(TMP,"^",2)
30 Q:(STATUS="-1") "-1^Could not determine message status or type"
31 Q:(TYPE="REC") "-1^Transaction is being received, not transmitted"
32 ;DETERMINE RETURN ADDRESS
33 S TMP=+$O(^VAT(394.81,0))
34 Q:('TMP) "-1^Could not determine return address"
35 S X=+$P($G(^VAT(394.81,TMP,0)),"^",2)
36 Q:('X) "-1^Could not determine return address"
37 S SENTFRM=$P($G(^DIC(4.2,X,0)),"^",1)
38 Q:(SENTFRM="") "-1^Could not determine return address"
39 ;DETERMINE DESTINATION FOR MESSAGE
40 S SENDTO=""
41 S:((TYPE="REQ")!(TYPE="RET")) SENDTO=$P($G(^VAT(394.61,TRANPTR,"ATHR2")),"^",2)
42 S:(TYPE="RES")!(TYPE="UNS") SENDTO=$P($G(^VAT(394.61,TRANPTR,"RQST2")),"^",2)
43 S:((TYPE="ACK")&(STATUS="VAQ-UNACK")) SENDTO=$P($G(^VAT(394.61,TRANPTR,"ATHR2")),"^",2)
44 S:((TYPE="ACK")&(STATUS="VAQ-RQACK")) SENDTO=$P($G(^VAT(394.61,TRANPTR,"RQST2")),"^",2)
45 Q:(SENDTO="") "-1^Could not determine destination of message"
46 ;LINE 1
47 S TMP="$DOMAIN"
48 S:('MESSNUM) @ARRAY@(LINE)=TMP
49 S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
50 S LINE=LINE+1
51 ;LINE 2
52 S TMP=SENTFRM
53 S:('MESSNUM) @ARRAY@(LINE)=TMP
54 S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
55 S LINE=LINE+1
56 ;LINE 3
57 S TMP=SENDTO
58 S:('MESSNUM) @ARRAY@(LINE)=TMP
59 S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
60 S LINE=LINE+1
61 ;LINE 4
62 S TMP="$$DOMAIN"
63 S:('MESSNUM) @ARRAY@(LINE)=TMP
64 S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
65 S LINE=LINE+1
66 Q (LINE-OFFSET)
67 ;
68COMMENT(TRANPTR,MESSNUM,ARRAY,OFFSET) ;CONSTRUCT COMMENT BLOCK
69 ;INPUT : TRANPTR - Pointer to VAQ - TRANSACTION file
70 ; MESSNUM - Message number to place block into
71 ; (if 0, block will be placed in ARRAY)
72 ; ARRAY - Array to store block in (full global reference)
73 ; OFFSET - Where to begin placing information (defaults to 0)
74 ;OUTPUT : N - Number of lines in block
75 ; -1^Error_Text - Error
76 ;NOTES : If MESSNUM=0, then the block will be placed into
77 ; ARRAY(LineNumber)=Line_of_info
78 ; If MESSNUM>0 then the block will be placed into
79 ; ^XMB(3.9,MESSNUM,2,LineNumber,0)=Line_of_info
80 ;
81 ;CHECK INPUT
82 S TRANPTR=+$G(TRANPTR)
83 Q:(('TRANPTR)!('$D(^VAT(394.61,TRANPTR)))) "-1^Did not pass a valid pointer to VAQ - TRANSACTION file"
84 S MESSNUM=+$G(MESSNUM)
85 I (('MESSNUM)&($G(ARRAY)="")) Q "-1^Did not pass message number of reference to array"
86 I (MESSNUM) Q:('$D(^XMB(3.9,MESSNUM))) "-1^Valid message number not passed"
87 S OFFSET=+$G(OFFSET)
88 ;DECLARE VARIABLES
89 N TMP,LINE,COMLINE,TYPE,X
90 S LINE=OFFSET
91 ;DETERMINE MESSAGE TYPE
92 S TMP=$$STATYPE^VAQCON1(TRANPTR)
93 Q:($P(TMP,"^",1)="-1") "-1^Could not determine message type"
94 S TYPE=$P(TMP,"^",2)
95 Q:(TYPE="REC") "-1^Transaction is being received, not transmitted"
96 ;LINE 1
97 S TMP="$COMMENT"
98 S:('MESSNUM) @ARRAY@(LINE)=TMP
99 S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
100 S LINE=LINE+1
101 ;COMMENT LINES
102 I ((TYPE="RES")!(TYPE="UNS")) D
103 .S COMLINE=0
104 .F S COMLINE=$O(^VAT(394.61,TRANPTR,"CMNT",COMLINE)) Q:('COMLINE) D
105 ..S TMP=$G(^VAT(394.61,TRANPTR,"CMNT",COMLINE,0))
106 ..S:('MESSNUM) @ARRAY@(LINE)=TMP
107 ..S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
108 ..S LINE=LINE+1
109 ;LINE Z
110 S TMP="$$COMMENT"
111 S:('MESSNUM) @ARRAY@(LINE)=TMP
112 S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
113 S LINE=LINE+1
114 Q (LINE-OFFSET)
Note: See TracBrowser for help on using the repository browser.