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

VAFCMS03.m

Go to the documentation of this file.
  1. VAFCMS03 ;BPFO/JRP - GENERAL ADT-A08 MESSAGE SENDER ; 22 Jan 2002 10:32 AM
  1. ;;5.3;Registration;**494**;Aug 13, 1993
  1. ;
  1. BULKA08(ARRAY,EVNTPROT,USER,OUTARR) ;Build/send ADT-A08 messages
  1. ;Input : ARRAY - List of patients to send (full global reference)
  1. ; ARRAY(x) = yyy
  1. ; x is pointer to Patient file (#2)
  1. ; yyy can be anything (it's ignored)
  1. ; EVNTPROT - HL7 event protocol to post message to (name or ptr)
  1. ; USER - User causing message generation (DUZ or name)
  1. ; Defaults to current DUZ
  1. ; OUTARR - Array to return message IDs in (full global ref)
  1. ; HLL("LINKS") - Refer to HL7 Dev Guide for definition
  1. ; Use of this array is optional
  1. ;Output : OUTARR - Array containing assigned message IDs or error text
  1. ; OUTARR(x) = HL7 message ID
  1. ; OUTARR(x) = 0^ErrorText
  1. ; x is pointer to Patient file
  1. ;Notes : OUTARR will be initialized (KILLed) on input
  1. ; : OUTARR will be not be returned if USER evaluates to a number
  1. ; and that number is not a valid DUZ
  1. ; : OUTARR will not be returned on bad input
  1. ; : It is assumed that EVNTPROT is defined to have a message
  1. ; type of 'ADT' and event type of 'A08'
  1. ;
  1. ;Check input
  1. Q:'$D(OUTARR)
  1. K @OUTARR
  1. Q:$G(ARRAY)=""
  1. Q:'$D(EVNTPROT)
  1. I '$D(USER) S USER=+$G(DUZ) S:'USER USER=""
  1. I USER S USER=$$GET1^DIQ(200,(USER_","),.01) D CLEAN^DILF
  1. Q:USER=""
  1. ;Declare variables
  1. N DFN,MSGID,COUNT,STOP
  1. ;Loop through list of patients
  1. S DFN=0
  1. S STOP=0
  1. F COUNT=1:1 S DFN=+$O(@ARRAY@(DFN)) Q:'DFN D Q:STOP
  1. .;Build/send ADT-A08 message
  1. .S @OUTARR@(DFN)=$$SNDA08(DFN,EVNTPROT,USER)
  1. .;Check for request to stop every 100th patient (allows for queuing)
  1. .I '(COUNT#100) S STOP=$$S^%ZTLOAD(COUNT_"th DFN = "_DFN)
  1. Q
  1. ;
  1. SNDA08(DFN,EVNTPROT,USER) ;Build/send ADT-A08 message for patient
  1. ;Input : DFN - Pointer to Patient file (#2)
  1. ; EVNTPROT - HL7 event protocol to post message to (name or ptr)
  1. ; USER - User causing message generation (DUZ or name)
  1. ; Defaults to current DUZ
  1. ; HLL("LINKS") - Refer to HL7 Dev Guide for definition
  1. ; Use of this array is optional
  1. ;Output : MsgID - HL7 message ID
  1. ; 0^Text - Error
  1. ;Notes : An error will be returned if USER evaluates to a number and
  1. ; that number is not a valid DUZ
  1. ; : It is assumed that EVNTPROT is defined to have a message
  1. ; type of 'ADT' and event type of 'A08'
  1. ;
  1. ;Check input
  1. S DFN=+$G(DFN)
  1. I '$D(^DPT(DFN,0)) Q "0^Did not pass valid DFN"
  1. I '$D(EVNTPROT) Q "0^Did not pass reference to HL7 event protocol"
  1. I '$D(USER) S USER=+$G(DUZ) S:'USER USER=""
  1. I USER S USER=$$GET1^DIQ(200,(USER_","),.01) D CLEAN^DILF
  1. I USER="" Q "0^Did not pass reference to user causing event"
  1. ;Declare variables
  1. N VARPTR,PIVOTNUM,PIVOTPTR,INFOARR,MSGARR,TMP,RESULT
  1. ;Create entry in ADT/HL7 PIVOT file
  1. S VARPTR=DFN_";DPT("
  1. S PIVOTNUM=+$$PIVNW^VAFHPIVT(DFN,$P(DT,"."),4,VARPTR)
  1. I (PIVOTNUM<0) Q "0^Unable to create/find entry in ADT/HL7 PIVOT file"
  1. ;Convert pivot number to pointer
  1. S PIVOTPTR=+$O(^VAT(391.71,"D",PIVOTNUM,0))
  1. I ('PIVOTPTR) Q "0^Unable to create/find entry in ADT/HL7 PIVOT file"
  1. ;Set variables needed to build HL7 message
  1. S INFOARR=$NA(^TMP("DG53494",$J,"INFO"))
  1. S MSGARR=$NA(^TMP("HLS",$J))
  1. K @INFOARR,@MSGARR
  1. S @INFOARR@("PIVOT")=PIVOTPTR
  1. S @INFOARR@("EVENT-NUM")=PIVOTNUM
  1. S @INFOARR@("VAR-PTR")=VARPTR
  1. S @INFOARR@("SERVER PROTOCOL")=EVNTPROT
  1. S @INFOARR@("REASON",1)=""
  1. S @INFOARR@("USER")=USER
  1. S @INFOARR@("DFN")=DFN
  1. S @INFOARR@("EVENT")="A08"
  1. S @INFOARR@("DATE")=$$NOW^XLFDT()
  1. ;Build message
  1. S TMP=$$BLDMSG^VAFCMSG1(DFN,"A08",$$NOW^XLFDT(),INFOARR,MSGARR)
  1. I (TMP<1) K @INFOARR,@MSGARR Q "0^"_$P(TMP,"^",2)
  1. ;Send message
  1. D GENERATE^HLMA(EVNTPROT,"GM",1,.RESULT)
  1. ;Store message ID (or error text) in pivot file
  1. S TMP=$S($P(RESULT,"^",2):$P(RESULT,"^",3),1:+RESULT)
  1. D FILERM^VAFCUTL(PIVOTPTR,TMP)
  1. ;Done
  1. K @INFOARR,@MSGARR
  1. I '$P(RESULT,"^",2) S RESULT=+RESULT
  1. I $P(RESULT,"^",2) S RESULT="0^"_$P(RESULT,"^",3)
  1. Q RESULT
  1. ;
  1. TASK ;Entry point for TaskMan to do bulk send
  1. ;Input : ARRAY - List of patients to send (full global reference)
  1. ; ARRAY(x) = yyy
  1. ; x is pointer to Patient file (#2)
  1. ; yyy can be anything (it's ignored)
  1. ; EVNTPROT - Pointer to event protocol
  1. ; DUZ - User that caused name changes
  1. ;Notes : Contents of ARRAY will be deleted upon completion
  1. ;
  1. ;Make sure partition contains input
  1. Q:'$D(ARRAY)
  1. Q:'$D(EVNTPROT)
  1. Q:'$D(DUZ)
  1. ;Declare variables
  1. N IENS,ITEM,SUBS,OUT
  1. ;Make sure event protocol has subscribers
  1. S IENS=","_EVNTPROT_","
  1. D LIST^DIC(101.01,IENS,.01,"I",,,,,,,"ITEM")
  1. D LIST^DIC(101.0775,IENS,.01,"I",,,,,,,"SUBS")
  1. D CLEAN^DILF
  1. ;No subscribers - delete contents of ARRAY and quit
  1. I ('$G(ITEM("DILIST",0)))&('$G(SUBS("DILIST",0))) D Q
  1. .K @ARRAY
  1. ;Send messages
  1. K MULT,IENS
  1. S OUT=$NA(^TMP("VAFCMS03",$J))
  1. D BULKA08(ARRAY,EVNTPROT,DUZ,OUT)
  1. K @ARRAY,@OUT
  1. S ZTREQ="@"
  1. Q