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

BSTSSTA.m

Go to the documentation of this file.
  1. BSTSSTA ;GDIT/HSCD/ALA-Check status of a Web Service ; 27 Mar 2015 11:35 AM
  1. ;;2.0;IHS STANDARD TERMINOLOGY;**1**;Dec 01, 2016;Build 36
  1. ;
  1. EN ; EP
  1. ; Select an existing web service and run sample calls for testing
  1. ;
  1. NEW DIC,Y,DIR,QUIT,DEBUG,SR,RES,IADT,SCNT,RESULT,DLAYGO,CT,%H
  1. NEW DIROUT,DIRUT,DTOUT,DUOUT,STS,SERV,SDATA,DTSON,BSTUP,%I,ERROR
  1. ;
  1. ;First Select the web service
  1. SRV ;EP
  1. W !!
  1. S DIC="^BSTS(9002318.2,",DIC(0)="AEMNZ"
  1. S DLAYGO=9002318.2 D ^DIC S SERV=+Y
  1. I SERV=-1 Q
  1. ;
  1. ;Check if active
  1. S IADT=$$GET1^DIQ(9002318.2,SERV_",",".1","I")
  1. I IADT]"",IADT<DT W !!,"This Web Service is not Active",! H 2 G SRV
  1. ;
  1. DSP ;EP - Display information
  1. ;
  1. NEW BSTSRPT
  1. ;
  1. ;Retrieve status information
  1. D STATUS(SERV,.BSTSRPT)
  1. ;
  1. ;Write formfeed
  1. I $G(IOF)]"" W @IOF
  1. ;
  1. D EN^DDIOL(.BSTSRPT)
  1. K BSTSRPT
  1. ;
  1. NEW DIR,X,Y,ANS
  1. S DIR(0)="LO^1:5"
  1. S DIR("A")="Select number or return to quit"
  1. S DIR("A",1)=" "
  1. S DIR("A",2)="1. Refresh Current information"
  1. S DIR("A",3)="2. Check DTS and Enable if Available"
  1. S DIR("A",4)="3. Turn off the DTS Link"
  1. S DIR("A",5)="4. Edit Server Settings"
  1. S DIR("A",6)="5. Other Options..."
  1. S DIR("A",7)=" "
  1. D ^DIR
  1. I Y="" G SRV
  1. I $G(DTOUT)!$G(DUOUT)!$G(DIROUT)!$G(DIRUT) G SRV
  1. S ANS=+Y
  1. ;
  1. ;Refresh Display
  1. I ANS=1 G DSP
  1. ;
  1. ;Check Link and Enable
  1. I ANS=2 D G DSP
  1. . NEW SDATA,DTSON
  1. . S SDATA=^BSTS(9002318.2,SERV,0)
  1. . S DTSON=$P(SDATA,"^",13)
  1. . I DTSON="" D CHK Q
  1. . S BSTUP(9002318.2,SERV_",",.13)="@"
  1. . S BSTUP(9002318.2,SERV_",",3)="@"
  1. . D FILE^DIE("","BSTUP","ERROR")
  1. . D ELOG^BSTSVOFL($$GET1^DIQ(200,DUZ_",",".01","E")_" turned on DTS link from BSTS STS option")
  1. . D CHK
  1. ;
  1. ;Turn off the DTS Link
  1. I ANS=3 D G DSP
  1. . NEW DIR,X,Y,DTOUT,DUOUT,DIROUT,DIRUT
  1. . S DIR("A")="Turn off the DTS link until"
  1. . S DIR("A",1)="Enter a date and time more than 10 mins in the future. "
  1. . S DIR("A",2)=" [Current date and time is "_$$FMTE^XLFDT($$NOW^XLFDT())_"]"
  1. . S DIR(0)="D^"_$$FMADD^XLFDT($$NOW^XLFDT(),"","",10)_":"_$$FMADD^XLFDT(DT,7)_".2359:ERTX"
  1. . D ^DIR I $G(DTOUT)!$G(DUOUT)!$G(DIROUT)!$G(DIRUT) Q
  1. . S BSTUP(9002318.2,SERV_",",.13)=Y
  1. . D FILE^DIE("","BSTUP","ERROR")
  1. . D ELOG^BSTSVOFL($$GET1^DIQ(200,DUZ_",",".01","E")_" turned off DTS link from BSTS STS option")
  1. ;
  1. ;Edit Server Settings
  1. I ANS=4 D G DSP
  1. . NEW DIE,DA,DR
  1. . S DIE="^BSTS(9002318.2,",DA=SERV,DR=".14;.12;.15;.05;.16"
  1. . D ^DIE
  1. ;
  1. ;Other Options
  1. I ANS=5 D DSP1
  1. ;
  1. G DSP
  1. ;
  1. ;Prompt for other option
  1. DSP1 NEW DIR,X,Y,DTOUT,DUOUT,DIROUT,DIRUT,ANS
  1. W !!,"Other options menu"
  1. S DIR(0)="LO^1:6"
  1. S DIR("A")="Select number or return to quit"
  1. S DIR("A",1)=" "
  1. S DIR("A",2)="1. Run daily update checks"
  1. S DIR("A",3)="2. Kick off background process now"
  1. S DIR("A",4)="3. Terminate current background process"
  1. S DIR("A",5)="4. BSTS reporting..."
  1. S DIR("A",6)="5. Retrieve Search History from DTS"
  1. S DIR("A",7)="6. Retrieve Log History from DTS"
  1. S DIR("A",8)=" "
  1. D ^DIR
  1. I Y="" Q
  1. I $G(DTOUT)!$G(DUOUT)!$G(DIROUT)!$G(DIRUT) Q
  1. S ANS=+Y
  1. ;
  1. ;Run daily update checks
  1. I ANS=1 D G DSP1
  1. . W !!,"Running update checks. This may take a minute or two"
  1. . D DAYCHK^BSTSVOF1(1) W !!,"Daily update checks completed" H 3
  1. ;
  1. ;Kick off a daily background process
  1. I ANS=2 D START G DSP1
  1. ;
  1. ;Terminate current background process
  1. I ANS=3 D STOP G DSP1
  1. ;
  1. ;BSTS Reporting
  1. I ANS=4 D DSP^BSTSDSP(SERV) G DSP1
  1. ;
  1. ;Retrieve search history
  1. I ANS=5 D SRSTRING G DSP1
  1. ;
  1. ;Retrieve log history
  1. I ANS=6 D LGHST^BSTSAPIL G DSP1
  1. ;
  1. Q
  1. ;
  1. ;Start a background process
  1. START NEW RUN,TRY
  1. ;
  1. ;First see if a process is running
  1. S RUN="" D
  1. . L +^XTMP("BSTSPROCQ",1):1 E S RUN=1 Q
  1. . L -^XTMP("BSTSPROCQ",1)
  1. . L +^BSTS(9002318.1,0):1 E S RUN=1 Q
  1. . L -^BSTS(9002318.1,0)
  1. . L +^TMP("BSTSICD2SMD"):1 E S RUN=1 Q
  1. . L -^TMP("BSTSICD2SMD")
  1. I RUN=1 W !!,"A background process is currently running" H 3 Q
  1. ;
  1. ;Job the process
  1. D JOBNOW^BSTSVOFL
  1. ;
  1. ;See if it started
  1. W !!,"Attempting to start the background process. This may take several minutes"
  1. S RUN="" F TRY=1:1:90 D H 1 Q:RUN
  1. . ;
  1. . W "."
  1. . ;
  1. . ;See if started
  1. . L +^XTMP("BSTSPROCQ",1):1 E S RUN=1 Q
  1. . L -^XTMP("BSTSPROCQ",1)
  1. ;
  1. ;Display status
  1. I RUN=1 W !!,"Background process has been started" H 3 Q
  1. E D
  1. . W !!,"The background process has been queued but has either not started"
  1. . W !,"or ran so quickly that its status wasn't captured. Verify Taskman"
  1. . W !,"is running and run the BSTSMENU/STS option again in a few minutes to see if"
  1. . W !,"it has started or display a history of completed processes to see if it"
  1. . W !,"finished already."
  1. ;
  1. Q
  1. ;
  1. ;Terminate the current background process
  1. STOP NEW TRY,STOP,RUN
  1. ;
  1. ;First see if a process is running
  1. S RUN="" D
  1. . L +^XTMP("BSTSPROCQ",1):1 E S RUN=1 Q
  1. . L -^XTMP("BSTSPROCQ",1)
  1. . L +^BSTS(9002318.1,0):1 E S RUN=1 Q
  1. . L -^BSTS(9002318.1,0)
  1. . L +^TMP("BSTSICD2SMD"):1 E S RUN=1 Q
  1. . L -^TMP("BSTSICD2SMD")
  1. I RUN="" W !!,"No background process is currently running" H 3 Q
  1. ;
  1. ;Set flag to stop the process
  1. S ^XTMP("BSTSLCMP","QUIT")=1
  1. S ^XTMP("BSTSPROCQ","QUIT")=1
  1. ;
  1. ;Check if process stopped
  1. W !!,"Attempting to stop the process"
  1. ;
  1. S STOP="" F TRY=1:1:90 D H 1 Q:STOP
  1. . ;
  1. . W "."
  1. . ;
  1. . ;Attempt to grab possible process lock1
  1. . L +^XTMP("BSTSPROCQ",1):1 E Q
  1. . L -^XTMP("BSTSPROCQ",1)
  1. . ;
  1. . ;Attempt to grab possible process lock2
  1. . L +^BSTS(9002318.1,0):1 E Q
  1. . L -^BSTS(9002318.1,0)
  1. . ;
  1. . ;Attempt to grab possible process lock3
  1. . L +^TMP("BSTSICD2SMD"):1 E Q
  1. . L -^TMP("BSTSICD2SMD")
  1. . ;
  1. . ;No process running
  1. . S STOP=1
  1. . ;
  1. . ;Reset quit flag
  1. . K ^XTMP("BSTSLCMP","QUIT")
  1. . K ^XTMP("BSTSPROCQ","QUIT")
  1. ;
  1. ;Display status
  1. I STOP W !!,"Background process has been terminated"
  1. E D
  1. . W !!,"Background process is still running but has been queued to stop."
  1. . W !,"Please wait for several minutes and run the STS option to check if the process has been stopped."
  1. ;
  1. Q
  1. ;
  1. CHK ;EP - Check the server status
  1. NEW STS,BSTUP
  1. S STS=$$CALL^BSTSTST(SERV,"COMMON COLD","")
  1. Q
  1. ;
  1. FRMT(VALUE) ;EP - Format the data
  1. S VALUE=$E(" ",$L(VALUE))_VALUE
  1. Q VALUE
  1. ;
  1. STATUS(SERV,BSTSRPT) ;Set up Server Status Display
  1. ;
  1. I '+$G(SERV) Q
  1. ;
  1. NEW SDATA,DTSON,CT
  1. ;
  1. S SDATA=^BSTS(9002318.2,SERV,0)
  1. S DTSON=$P(SDATA,"^",13)
  1. I DTSON="" D
  1. . D CHK
  1. . S SDATA=^BSTS(9002318.2,SERV,0)
  1. . S DTSON=$P(SDATA,"^",13)
  1. ;
  1. ;Get latest entry
  1. S CT=+$O(BSTSRPT(""),-1)
  1. ;
  1. S:CT=0 CT=1,BSTSRPT(CT)=" "
  1. S CT=CT+1,BSTSRPT(CT)=" "
  1. S CT=CT+1,BSTSRPT(1)="Current Server Status:"
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Web Service: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)=$P(SDATA,"^",1)
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Current Status: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)=$S(DTSON="":"ONLINE",1:"OFFLINE")
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Offline Until: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)=$S(DTSON="":"N/A",1:$$FMTE^XLFDT(DTSON))
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Last Error Message: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)=$S(DTSON="":"N/A",1:$$GET1^DIQ(9002318.2,SERV_",",3,"E"))
  1. ;
  1. ;Check if any processes are running
  1. L +^BSTS(9002318.1,0):0 E D
  1. . S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Background process: "
  1. . S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)=$P($G(^XTMP("BSTSLCMP",0)),U,3)
  1. . I $G(^XTMP("BSTSLCMP","STS"))]"" S CT=CT+1,BSTSRPT(CT,"F")="!?25",BSTSRPT(CT)=$G(^XTMP("BSTSLCMP","STS"))
  1. L -^BSTS(9002318.1,0)
  1. ;
  1. ;Check if Description Id Population Utility is running
  1. L +^XTMP("BSTSCFIX"):0 E D
  1. . NEW RUN
  1. . S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Background process: "
  1. . S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)="Description Id Population Utility is running"
  1. . S RUN=$G(^XTMP("BSTSCFIX","RUN")) Q:RUN=""
  1. . I $G(^XTMP("BSTSCFIX",RUN,"STS"))]"" S CT=CT+1,BSTSRPT(CT,"F")="!?25",BSTSRPT(CT)=$G(^XTMP("BSTSCFIX",RUN,"STS"))
  1. L -^XTMP("BSTSCFIX")
  1. ;
  1. ;Check if ICD9 to SNOMED process is running
  1. L +^TMP("BSTSICD2SMD"):0 E D
  1. . S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Background process: "
  1. . S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)="ICD9 to SNOMED process is running"
  1. L -^TMP("BSTSICD2SMD")
  1. ;
  1. ;Check if install conversion process is running
  1. L +^TMP("BSTSPBFH"):0 E D
  1. . S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="Background process: "
  1. . S CT=CT+1,BSTSRPT(CT,"F")="?25",BSTSRPT(CT)="Installation conversion process is running"
  1. L -^TMP("BSTSPBFH")
  1. ;
  1. S CT=CT+1,BSTSRPT(CT,"F")="!!",BSTSRPT(CT)="Current Server Settings: "
  1. S CT=CT+1,BSTSRPT(CT)=" "
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="CHECK FOR CONNECTION AFTER: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?35",BSTSRPT(CT)=$S($P(SDATA,"^",14)="":"60 minutes (default)",1:$$FRMT($P(SDATA,"^",14))_" minutes")
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="CONNECTION TIMEOUT OVERRIDE: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?35",BSTSRPT(CT)=$S($P(SDATA,"^",12)="":" 2 seconds (default)",1:$$FRMT($P(SDATA,"^",12))_" seconds")
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="MAXIMUM REMOTE SEARCH TIME: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?35",BSTSRPT(CT)=$S($P(SDATA,"^",15)="":"60 seconds (default)",1:$$FRMT($P(SDATA,"^",15))_" seconds")
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="TIMEOUT OVERRIDE: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?35",BSTSRPT(CT)=$S($P(SDATA,"^",5)="":"60 seconds (default)",1:$$FRMT($P(SDATA,"^",5))_" seconds")
  1. S CT=CT+1,BSTSRPT(CT,"F")="!?5",BSTSRPT(CT)="ENABLE SEARCH LOGGING: "
  1. S CT=CT+1,BSTSRPT(CT,"F")="?35",BSTSRPT(CT)=$S($P(SDATA,"^",16):"YES",1:"NO")
  1. ;
  1. Q
  1. ;
  1. SRSTRING ;Return list of search strings
  1. ;
  1. NEW FRDT,TODT,ESERV,SRV,SIEN,SNUM,RNAME,EXEC,ENSPACE,BSTSWS,SERVERS
  1. NEW SPACE,STS,POP,CT,BSTSRPT,ICNT,SRMAX,SCNT
  1. ;
  1. S $P(SPACE," ",80)=" "
  1. ;
  1. W !!,"DISPLAY BSTS SEARCH STRINGS USED"
  1. ;
  1. ;Get From Date
  1. S FRDT=$$DATE^BSTSDSP("From Date","T-7") Q:'FRDT
  1. ;
  1. ;Get To Date
  1. S TODT=$$DATE^BSTSDSP("To Date","T",FRDT) Q:'TODT
  1. ;
  1. ;Get maximum search results to display
  1. S SRMAX=$$SMAX() Q:'SRMAX
  1. ;
  1. S ENSPACE=36
  1. ;
  1. ;Get the server information
  1. S ESERV=$$WSERVER^BSTSWSV(.SERVERS,"") Q:'ESERV
  1. S SRV=$O(SERVERS(0)) Q:'SRV
  1. M BSTSWS=SERVERS(SRV)
  1. ;
  1. ;Get the site
  1. S SIEN=$O(^AUTTSITE(0)) Q:'+SIEN
  1. S SNUM=$$GET1^DIQ(9999999.39,SIEN_",",.01,"I") Q:SNUM=""
  1. ;
  1. ;Get search results
  1. S BSTSWS("FRDT")=$P($$FMTE^BSTSUTIL(FRDT),":",1,2)_" 00:00"
  1. S BSTSWS("TODT")=$P($$FMTE^BSTSUTIL(TODT),":",1,2)_" 23:59"
  1. S BSTSWS("ENSPACE")=ENSPACE
  1. S BSTSWS("ESITE")=SNUM
  1. S BSTSWS("EPROD")=$$PROD^XUPROD()
  1. S RNAME="",EXEC="S RNAME=$"_"ZNSPACE" X EXEC
  1. S BSTSWS("RNAME")=RNAME
  1. ;
  1. ;Pull the search list
  1. S STS=$$SRCNT^BSTSCMCL(.BSTSWS,.RES)
  1. ;
  1. ;Get device
  1. W !
  1. S POP="" D ^%ZIS I POP Q
  1. U IO
  1. ;
  1. ;Display results
  1. S (SCNT,CT)=0,CT=CT+1,BSTSRPT(CT)="BSTS SEARCH HISTORY: "_$$FMTE^XLFDT(FRDT,"2ZD")_" TO "_$$FMTE^XLFDT(TODT,"2ZD")_" - "_SRMAX_" MOST FREQUENTLY USED"
  1. S CT=CT+1,BSTSRPT(CT)=" "
  1. S CT=CT+1,BSTSRPT(CT)=$E("SEARCH STRING"_SPACE,1,50)_$E("COUNT"_SPACE,1,8)
  1. S CT=CT+1,BSTSRPT(CT)=" "
  1. S ICNT="" F S ICNT=$O(^TMP("BSTSCMCL",$J,ICNT)) Q:ICNT="" D I (SCNT+1)>SRMAX Q
  1. . ;
  1. . NEW NODE
  1. . ;
  1. . S NODE=$G(^TMP("BSTSCMCL",$J,ICNT))
  1. . S CT=CT+1,BSTSRPT(CT)=$E($P(NODE,U)_SPACE,1,50)_$E($P(NODE,U,2)_SPACE,1,8)
  1. . S SCNT=SCNT+1
  1. ;
  1. ;Check for no results
  1. I SCNT=0 D
  1. . S CT=CT+1,BSTSRPT(CT)="No results found. This could be because SEARCH LOGGING is disabled or the"
  1. . S CT=CT+1,BSTSRPT(CT)="report date range is too far in the past and the search history has been"
  1. . S CT=CT+1,BSTSRPT(CT)="purged from the DTS server. *Note also that the current day's search"
  1. . S CT=CT+1,BSTSRPT(CT)="history does not get sent until later in the evening so it will not be"
  1. . S CT=CT+1,BSTSRPT(CT)="immediately available."
  1. ;
  1. S CT=CT+1,BSTSRPT(CT)=" "
  1. S CT=CT+1,BSTSRPT(CT)="<END OF REPORT>"
  1. ;
  1. ;Display the report
  1. D EN^DDIOL(.BSTSRPT)
  1. ;
  1. ;Close the device
  1. D ^%ZISC
  1. ;
  1. I $D(IOST),IOST["C-",'$D(DIRUT),'$D(DTOUT) D
  1. . NEW DIR,X,Y
  1. . W ! S DIR(0)="E",DIR("A")="Press 'Return to continue'" D ^DIR
  1. ;
  1. Q
  1. ;
  1. SMAX() ;Prompt for maximum search results to display
  1. ;
  1. NEW DIR,DTOUT,DUOUT,DIRUT,DIROUT,X,Y
  1. ;
  1. W !
  1. S DIR(0)="N^1:9999:4"
  1. S DIR("A")="Maximum number of results to return: "
  1. S DIR("B")="25"
  1. D ^DIR
  1. I Y="" Q ""
  1. I $G(DTOUT)!$G(DUOUT)!$G(DIRUT)!$G(DIROUT) Q ""
  1. ;
  1. Q Y