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

VAQCON4.m

Go to the documentation of this file.
  1. VAQCON4 ;ALB/JRP - MESSAGE CONSTRUCTION;12-APR-93
  1. ;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
  1. DOMAIN(TRANPTR,MESSNUM,ARRAY,OFFSET) ;CONSTRUCT DOMAIN BLOCK
  1. ;INPUT : TRANPTR - Pointer to VAQ - TRANSACTION file
  1. ; MESSNUM - Message number to place block into
  1. ; (if 0, block will be placed in ARRAY)
  1. ; ARRAY - Array to store block in (full global reference)
  1. ; OFFSET - Where to begin placing information (defaults to 0)
  1. ;OUTPUT : N - Number of lines in block
  1. ; -1^Error_Text - Error
  1. ;NOTES : If MESSNUM=0, then the block will be placed into
  1. ; ARRAY(LineNumber)=Line_of_info
  1. ; If MESSNUM>0 then the block will be placed into
  1. ; ^XMB(3.9,MESSNUM,2,LineNumber,0)=Line_of_info
  1. ;
  1. ;CHECK INPUT
  1. S TRANPTR=+$G(TRANPTR)
  1. Q:(('TRANPTR)!('$D(^VAT(394.61,TRANPTR)))) "-1^Did not pass a valid pointer to VAQ - TRANSACTION file"
  1. S MESSNUM=+$G(MESSNUM)
  1. I (('MESSNUM)&($G(ARRAY)="")) Q "-1^Did not pass message number of reference to array"
  1. I (MESSNUM) Q:('$D(^XMB(3.9,MESSNUM))) "-1^Valid message number not passed"
  1. S OFFSET=+$G(OFFSET)
  1. ;DECLARE VARIABLES
  1. N TMP,TYPE,LINE,X,SENDTO,SENTFRM,STATUS
  1. S LINE=OFFSET
  1. ;DETERMINE MESSAGE STATUS & TYPE (USED TO DETERMINE RECEIVER OF MESSAGE)
  1. S TMP=$$STATYPE^VAQCON1(TRANPTR)
  1. S STATUS=$P(TMP,"^",1)
  1. S TYPE=$P(TMP,"^",2)
  1. Q:(STATUS="-1") "-1^Could not determine message status or type"
  1. Q:(TYPE="REC") "-1^Transaction is being received, not transmitted"
  1. ;DETERMINE RETURN ADDRESS
  1. S TMP=+$O(^VAT(394.81,0))
  1. Q:('TMP) "-1^Could not determine return address"
  1. S X=+$P($G(^VAT(394.81,TMP,0)),"^",2)
  1. Q:('X) "-1^Could not determine return address"
  1. S SENTFRM=$P($G(^DIC(4.2,X,0)),"^",1)
  1. Q:(SENTFRM="") "-1^Could not determine return address"
  1. ;DETERMINE DESTINATION FOR MESSAGE
  1. S SENDTO=""
  1. S:((TYPE="REQ")!(TYPE="RET")) SENDTO=$P($G(^VAT(394.61,TRANPTR,"ATHR2")),"^",2)
  1. S:(TYPE="RES")!(TYPE="UNS") SENDTO=$P($G(^VAT(394.61,TRANPTR,"RQST2")),"^",2)
  1. S:((TYPE="ACK")&(STATUS="VAQ-UNACK")) SENDTO=$P($G(^VAT(394.61,TRANPTR,"ATHR2")),"^",2)
  1. S:((TYPE="ACK")&(STATUS="VAQ-RQACK")) SENDTO=$P($G(^VAT(394.61,TRANPTR,"RQST2")),"^",2)
  1. Q:(SENDTO="") "-1^Could not determine destination of message"
  1. ;LINE 1
  1. S TMP="$DOMAIN"
  1. S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. S LINE=LINE+1
  1. ;LINE 2
  1. S TMP=SENTFRM
  1. S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. S LINE=LINE+1
  1. ;LINE 3
  1. S TMP=SENDTO
  1. S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. S LINE=LINE+1
  1. ;LINE 4
  1. S TMP="$$DOMAIN"
  1. S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. S LINE=LINE+1
  1. Q (LINE-OFFSET)
  1. ;
  1. COMMENT(TRANPTR,MESSNUM,ARRAY,OFFSET) ;CONSTRUCT COMMENT BLOCK
  1. ;INPUT : TRANPTR - Pointer to VAQ - TRANSACTION file
  1. ; MESSNUM - Message number to place block into
  1. ; (if 0, block will be placed in ARRAY)
  1. ; ARRAY - Array to store block in (full global reference)
  1. ; OFFSET - Where to begin placing information (defaults to 0)
  1. ;OUTPUT : N - Number of lines in block
  1. ; -1^Error_Text - Error
  1. ;NOTES : If MESSNUM=0, then the block will be placed into
  1. ; ARRAY(LineNumber)=Line_of_info
  1. ; If MESSNUM>0 then the block will be placed into
  1. ; ^XMB(3.9,MESSNUM,2,LineNumber,0)=Line_of_info
  1. ;
  1. ;CHECK INPUT
  1. S TRANPTR=+$G(TRANPTR)
  1. Q:(('TRANPTR)!('$D(^VAT(394.61,TRANPTR)))) "-1^Did not pass a valid pointer to VAQ - TRANSACTION file"
  1. S MESSNUM=+$G(MESSNUM)
  1. I (('MESSNUM)&($G(ARRAY)="")) Q "-1^Did not pass message number of reference to array"
  1. I (MESSNUM) Q:('$D(^XMB(3.9,MESSNUM))) "-1^Valid message number not passed"
  1. S OFFSET=+$G(OFFSET)
  1. ;DECLARE VARIABLES
  1. N TMP,LINE,COMLINE,TYPE,X
  1. S LINE=OFFSET
  1. ;DETERMINE MESSAGE TYPE
  1. S TMP=$$STATYPE^VAQCON1(TRANPTR)
  1. Q:($P(TMP,"^",1)="-1") "-1^Could not determine message type"
  1. S TYPE=$P(TMP,"^",2)
  1. Q:(TYPE="REC") "-1^Transaction is being received, not transmitted"
  1. ;LINE 1
  1. S TMP="$COMMENT"
  1. S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. S LINE=LINE+1
  1. ;COMMENT LINES
  1. I ((TYPE="RES")!(TYPE="UNS")) D
  1. .S COMLINE=0
  1. .F S COMLINE=$O(^VAT(394.61,TRANPTR,"CMNT",COMLINE)) Q:('COMLINE) D
  1. ..S TMP=$G(^VAT(394.61,TRANPTR,"CMNT",COMLINE,0))
  1. ..S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. ..S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. ..S LINE=LINE+1
  1. ;LINE Z
  1. S TMP="$$COMMENT"
  1. S:('MESSNUM) @ARRAY@(LINE)=TMP
  1. S:(MESSNUM) X=$$ADDLINE^VAQCON1(TMP,MESSNUM,LINE)
  1. S LINE=LINE+1
  1. Q (LINE-OFFSET)