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

VIAAQUE.m

Go to the documentation of this file.
  1. VIAAQUE ;ALB/CR - RTLS Queue General Utility ;5/04/16 10:00am
  1. ;;1.0;RTLS;**3**;April 22, 2013;Build 20
  1. ;
  1. Q
  1. ;
  1. ; create a task that can requeue itself and check file #6930
  1. ; every 3-6 minutes (180-360 seconds) or so
  1. ; =============== NOTICE ====================
  1. ; Per HPMO reference # OITIMB33554520, a waiver has been granted
  1. ; for the use of Cache ObjectScript along with standard MUMPS commands
  1. ;
  1. STR ; enter here to send a message right away if entries are found
  1. L +^VIAA(6930):5 Q:'$T ; we want just one job running
  1. N COUNT,DATA,ROOT
  1. I '$D(^VIAA(6930)) Q
  1. F COUNT=0:0 S COUNT=+$O(^VIAA(6930,COUNT)) Q:'COUNT D
  1. . S ROOT=$G(^VIAA(6930,COUNT,0))
  1. . ; get all 3 pieces for processing in Eng file
  1. . S DATA=$P(ROOT,U,1,3) ; take first 3 pieces at once
  1. . D MSG
  1. L -^VIAA(6930)
  1. ;
  1. ; -- if Mule is reachable, then call web service and deliver the
  1. ; -- entries. Otherwise, defer any action to the queue process.
  1. Q
  1. ;
  1. SEND ; come here to place the entries in the queue for the Mule service
  1. ;
  1. N ZTRTN,ZTIO,ZTSAVE,ZTDESC,ZTDTH
  1. I $D(^VIAA(6930)) D
  1. . S ZTDESC="Pending RTLS File Queue Transmission"
  1. . S ZTRTN="STR^VIAAQUE"
  1. . S ZTIO="NULL",ZTDTH=$H ; need the null device for HWSC call
  1. . S ZTSAVE("*")=""
  1. . D ^%ZTLOAD
  1. Q
  1. ;
  1. ; for transmission to Mule:
  1. ; if status = 500, we have to hold the entries for the next round
  1. ; of the queue; if status = 200, Mule has accepted the record and we
  1. ; can clean it from the file PENDING RTLS EVENTS (#6930)
  1. MSG N MSG,STATUS,XCODE
  1. ;
  1. S MSG="?siteID="_$P(DATA,U,1)_"&"_"fileNumber="_$P(DATA,U,2)_"&"_"IEN="_$P(DATA,U,3)
  1. S XCODE=$$XMIT(MSG)
  1. S STATUS=$S(XCODE=200:"OK",XCODE=500:"NOK",1:XCODE)
  1. I STATUS'="OK" Q
  1. D DEL^VIAATRI(COUNT) ; clear entry from file #6930
  1. Q
  1. ;
  1. XMIT(DATA) ; Transmit the RESTful request.
  1. ;
  1. N $ETRAP,$ESTACK,ERR,REST,XCODE,XOBREADR,XOBREAK,XOBSTAT
  1. S $ETRAP="D XERR^VIAAQUE"
  1. ;
  1. S XCODE=0
  1. S REST=$$GETREST^XOBWLIB("VIAA VISTA TRIGGER SERVICE","VIAA VISTA TRIGGER SERVER")
  1. S REST.Timeout=60
  1. I $$POST^XOBWLIB(REST,DATA,.ERR) D
  1. . S XOBSTAT=##class(%XML.TextReader).ParseStream(REST.HttpResponse.Data,.XOBREADR)
  1. . I ($$STATCHK^XOBWLIB(XOBSTAT,.ERR)) D
  1. .. S XOBREAK=0 F Q:XOBREAK!XOBREADR.EOF!'XOBREADR.Read() D
  1. ... I (XOBREADR.NodeType="element"),(XOBREADR.LocalName="code") D
  1. .... I XOBREADR.MoveToContent() D
  1. ..... S XCODE=XOBREADR.Value,XOBREAK=1
  1. Q XCODE
  1. ;
  1. XERR ; -- Error trap handler --
  1. ;
  1. S $ECODE=""
  1. Q