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

HMPHTTP.m

Go to the documentation of this file.
  1. HMPHTTP ;SLC/MKB,ASMR/BL,RRB,CK - HTTP interface;Aug 29, 2016 20:06:27
  1. ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**1,3**;May 15, 2016;Build 15
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; External References DBIA#
  1. ; ------------------- -----
  1. ; %ZTLOAD 10063
  1. ; DIR 10026
  1. ; VASITE 10112
  1. ; XLFCRC 3156
  1. ; XLFUTL 2622
  1. ; XPAR 2263
  1. ; XTHC10 5515
  1. ; XUPARAM 2541
  1. Q
  1. ;
  1. EN ; -- manage the background job
  1. N ZTSK,STS
  1. S ZTSK=+$G(^XTMP("HMP","ZTSK")),STS=$$STS
  1. W !,?24,"--- HMP Patient Data Monitor ---"
  1. W !!,"Task"_$S(ZTSK:" #"_ZTSK,1:"")_" is "_$P(STS,U,2)_".",!
  1. ;
  1. I ZTSK,+STS=1!(+STS=2) D:$$STOP Q
  1. . N X S X=$$ASKSTOP^%ZTLOAD(ZTSK)
  1. . W !,$P(X,U,2),!
  1. ;
  1. I $$START D
  1. . W !!,"Starting HMP Patient Data Monitor ... " D QUE
  1. . I $G(ZTSK) W "task #"_ZTSK_" started.",!
  1. . E W !,"ERROR: task NOT created. Try again later.",!
  1. . S ^XTMP("HMP","ZTSK")=$G(ZTSK)
  1. Q
  1. ;
  1. STS() ; -- get the status of ZTSK
  1. D STAT^%ZTLOAD
  1. N Y S Y=+$G(ZTSK(1))_U_$G(ZTSK(2))
  1. Q Y
  1. ;
  1. STOP() ; -- stop the task?
  1. N X,Y,DIR
  1. S DIR("A")="Do you want to stop the data monitor? ",DIR(0)="YA",DIR("B")="NO"
  1. S DIR("?",1)="Enter YES to stop or cancel the data monitor; please restart ASAP!"
  1. S DIR("?",3)="This job must be running in the background for AViVA to be notified"
  1. S DIR("?")="when new patient data is available.",DIR("?",2)=" "
  1. D ^DIR S:Y<1 Y=0
  1. Q Y
  1. ;
  1. START() ; -- [re]start the task?
  1. N X,Y,DIR
  1. S DIR(0)="YA",DIR("B")="YES"
  1. S DIR("A")="Do you want to "_$S(STS:"re",1:"")_"start the data monitor? "
  1. S DIR("?",1)="Enter YES to "_$S(STS:"re",1:"")_"start the HMP Patient Data Monitor."
  1. S DIR("?",3)="This job must be running in the background for AViVA to be notified"
  1. S DIR("?")="when new patient data is available.",DIR("?",2)=" "
  1. D ^DIR S:Y<1 Y=0
  1. Q Y
  1. ;
  1. QUE ; -- create the background task: returns ZTSK
  1. N IO,IOP,ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTUCI,ZTCPU,ZTPRI,ZTKIL,ZTSYNC,ZTSAVE,%ZIS
  1. S %ZIS="0H",IOP="NULL" D ^%ZIS I POP W !,"Null Device Not Found" Q
  1. S ZTDESC="HMP new data monitor for AViVA",ZTDTH=$H,ZTIO=""
  1. S ZTRTN="POKE^HMPHTTP" K ZTSK
  1. D ^%ZTLOAD
  1. Q
  1. ;
  1. POKE ; -- background job to poke the client when new data is available
  1. ; ^XTMP("HMP",DFN,TYPE,ID) = new data since last update
  1. N DIV,ID,DFN,DATA,IOP,X,DA,TOKEN,NEW K ZTSTOP,ZTREQ
  1. S IOP="NULL" D ^%ZIS
  1. S ID=(+$H)+$P($H,",",2)
  1. S DFN=0 F S DFN=$O(^XTMP("HMP",DFN)) Q:'(DFN>0) I $D(^(DFN))>9 D ;DE4496 19 August 2016
  1. . L +^XTMP("HMP",DFN):5 Q:'$T ;try again next cycle
  1. . K DATA M DATA=^XTMP("HMP",DFN)
  1. . S X=$G(^XTMP("HMP",DFN)) K ^(DFN) S ^(DFN)=X ;clear list, keep subscription
  1. . L -^XTMP("HMP",DFN)
  1. . ; add to list for URL
  1. . S DA=0 F S DA=$O(^HMP(800000,"ADFN",DFN,DA)) Q:DA<1 D
  1. .. S TOKEN=DA_"~"_ID,NEW(TOKEN)=""
  1. .. M ^XTMP("HMPX",TOKEN,DFN)=DATA
  1. D SEND(.NEW)
  1. I $$S^%ZTLOAD S ZTSTOP=1,ZTREQ="@" Q
  1. D HANG S ZTREQ="" ;re-queue
  1. Q
  1. ;
  1. SEND(LIST) ; send each list ID to its URL
  1. N SYS,ID,DA,URL,X
  1. S SYS=$$SYS^HMPUTILS
  1. ; DIV=$P($$SITE^VASITE,U,3) ;station#
  1. S ID="" F S ID=$O(LIST(ID)) Q:ID="" D
  1. . S DA=+ID,URL=$G(^HMP(800000,DA,.1)) Q:URL=""
  1. . S URL=URL_"?vistaId="_SYS_"&id="_ID
  1. . S X=$$GETURL^XTHC10(URL,,"HMPX") ;I X>200 = ERROR
  1. Q
  1. ;
  1. HANG ; -- wait #seconds
  1. N X S X=$$GET^XPAR("ALL","HMP TASK WAIT TIME") S:'X X=99
  1. H X
  1. Q
  1. ;
  1. KILL ; -- kill/reset ^HMP(800000) for testing
  1. K ^HMP(800000)
  1. S ^HMP(800000,0)="HMP SUBSCRIPTION^800000^^"
  1. Q