BSTSVOF1 ;GDIT/HS/BEE-Standard Terminology - Versioning handling overflow 2 ; 5 Nov 2012 9:53 AM
;;2.0;IHS STANDARD TERMINOLOGY;**1**;Dec 01, 2016;Build 36
;
Q
;
;BSTS*1.0*6;Change to updates
;Run the PCC update option
;BSTS*2.0*1;CR#8457;Switch DUZ to PCC UIFS UPDATE USER (or ADAM,ADAM)
UIFS(ZTQUEUED) ;Run the PCC UIFS option
;
S:'$D(ZTQUEUED) ZTQUEUED=1
;
NEW NDUZ,ODUZ,DA
;
;Retrieve the default BSTS,PROXY USER
S NDUZ=$O(^VA(200,"B","BSTS,PROXY USER",""))
S:NDUZ="" NDUZ=DUZ ;Default to existing user if BSTS,PROXY USER cannot be found
;
;Switch users, run PCC UIFS option, and switch back to original user
S ^XTMP("BSTSLCMP","STS")="Running the PCC Update ICD-10 Diagnoses from SNOMED Concept ID (UIFS) option"
EX1 M ODUZ=DUZ K DUZ S DUZ=NDUZ D DUZ^XUP(.DUZ) D QUEUE^APCDPLFH K DUZ M DUZ=ODUZ ;SAC Exemption Granted 1/31/17-See bsts0200.01t
Q
;
ASKSB() ;Ask Individual Subset
;
NEW DIR,X,Y,SUBSET,DIRUT,DUOUT,SLIST,STS,I
;
;Get subsets
S STS=$$SUBSET^BSTSAPI("SLIST","^2")
;
S SLIST="" F S SLIST=$O(SLIST(SLIST)) Q:'SLIST I SLIST(SLIST)]"" S SLIST("B",SLIST(SLIST))="" ;Sort
S SLIST="" F I=1:1 S SLIST=$O(SLIST("B",SLIST)) Q:SLIST="" S DIR("?",I)=SLIST
;
S SUBSET=""
;
ASKSB1 W !! S DIR("?")="Select a subset from the following list or type ALL for all subsets"
S DIR("A")="Enter the exact name of the subset to refresh or ALL: "
S DIR("B")="ALL"
S DIR(0)="F^3:50"
D ^DIR I $G(DIRUT)!$G(DUOUT)!(Y="") Q "-1"
;
;BSTS*1.0*4;Filter out IHS PROBLEM ALL SNOMED
I Y="IHS PROBLEM ALL SNOMED" W !!,"CANNOT DOWNLOAD IHS PROBLEM ALL SNOMED" H 3 G ASKSB1
I Y]"",Y'="ALL",'$D(SLIST("B",Y)) W !!,"INVALID SUBSET" H 3 G ASKSB1
;
S SUBSET=Y
;
Q SUBSET
;
ISCHK(SUBSET) ;EP - Recompile one subset
;
NEW STS,VAR,ZTDTH,ZTDESC,ZTRTN,ZTIO,ZTSAVE,BSTSUPD,ERROR,FIELD,ZTSK,TR
;
;Only one SNOMED background process can be running at a time
L +^BSTS(9002318.1,0):0 E W !!,"A Local Cache Refresh is Already Running. Please Try Later" H 3 Q
L -^BSTS(9002318.1,0)
;
;Make sure ICD9 to SNOMED background process isn't running
L +^TMP("BSTSICD2SMD"):0 E W !!,"An ICD9 to SNOMED Background Process is Already Running. Please Try Later" H 3 Q
L -^TMP("BSTSICD2SMD")
;
;Only run if server set up
S STS="" F TR=1:1:60 D I +STS=2 Q
. D RESET^BSTSWSV1 ;Reset the DTS link to on
. S STS=$$VERSIONS^BSTSAPI("VAR") ;Try a quick call to see if call works
. I +STS'=2 H TR
I +STS'=2 W !!,"The DTS server link is down. Aborting..." G XISCHK
;
;Queue the process off in the background
S ZTRTN="ISUB^BSTSVOF1",ZTDESC="BSTS - Refresh BSTS subset "_SUBSET
S ZTSAVE("SUBSET")=""
;
S ZTIO=""
S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT(),,,2)
D ^%ZTLOAD
I $G(ZTSK)]"" W !!,"Task: ",ZTSK," scheduled to start in two minutes"
;
XISCHK Q
;
ISUB ;Recompile one subset
;
;Perform lock so only one process is allowed
L +^BSTS(9002318.1,0):1 E Q
;
NEW BSTSBPRC,MFAIL,FWAIT,TRY,STS,ABORT,NMIEN,CIEN
;
I $G(SUBSET)="" G XISUB
;
;Save current entries
K ^TMP("BSTSISUB",$J)
S NMIEN=$O(^BSTS(9002318.1,"B",36,"")) I NMIEN="" G XISUB
S CIEN="" F S CIEN=$O(^BSTS(9002318.4,"E",NMIEN,SUBSET,CIEN)) Q:CIEN="" S ^TMP("BSTSISUB",$J,CIEN)=$$GET1^DIQ(9002318.4,CIEN_",",.08,"I")
;
;Retrieve Failover Variables
S MFAIL=$$FPARMS^BSTSVOFL()
S FWAIT=$P(MFAIL,U,2)
S MFAIL=$P(MFAIL,U)
;
;Make the call until success - Hang max of 12 times
S ABORT=0 F TRY=1:1:(12*MFAIL) D Q:$D(^XTMP("BSTSLCMP","QUIT")) I +STS=2!(STS="0^") Q
. NEW IN,OUT
. S IN=SUBSET_"^^2",FCNT=0
. S OUT=$NA(^TMP("BSTSSUPD",$J)) K @OUT
. S BSTSBPRC=1 ;Set variable showing background call
. D RESET^BSTSWSV1 ;Make sure the link is on
. S STS=$$SUBLST^BSTSAPI(OUT,IN) I +STS=2 Q ;Quit if success
. Q:$D(^XTMP("BSTSLCMP","QUIT"))
. S FCNT=FCNT+1 I FCNT'<MFAIL D ;Fail handling
.. S ABORT=$$FAIL^BSTSVOFL(MFAIL,FWAIT,TRY,"SUB^BSTSVOD1 - Processing subset: "_SUBSET)
. I ABORT=1 S ^XTMP("BSTSLCMP","QUIT")=1 D ELOG^BSTSVOFL("SUBSET REFRESH FAILED ON SUBSET: "_SUBSET)
. S FCNT=0
;
;Look for removed entries
I ABORT=0 S CIEN="" F S CIEN=$O(^TMP("BSTSISUB",$J,CIEN)) Q:CIEN="" D Q:$D(^XTMP("BSTSLCMP","QUIT"))
. NEW LMOD,DTSID,ABORT,FCNT,TRY
. S DTSID=$G(^TMP("BSTSISUB",$J,CIEN)) Q:DTSID=""
. ;
. ;Check last modified - skip if today
. S LMOD=$$GET1^DIQ(9002318.4,CIEN_",",.12,"I") I LMOD'<DT Q
. ;
. ;Pull detail from DTS - Hang max of 12 times
. S (ABORT,FCNT)=0 F TRY=1:1:(12*MFAIL) D I +STS=2!(STS="0^") Q
.. D RESET^BSTSWSV1 ;Reset the DTS link to on
.. S STS=$$DTSLKP^BSTSAPI("VAR",DTSID_"^36^^^^1") I +STS=2!(STS="0^") Q
.. S FCNT=FCNT+1 I FCNT'<MFAIL D ;Fail handling
... S ABORT=$$FAIL^BSTSVOFL(MFAIL,FWAIT,TRY,"ISUB^BSTSVRSN - Getting Update for entry: "_DTSID)
... I ABORT=1 S ^XTMP("BSTSLCMP","QUIT")=1 D ELOG^BSTSVOFL(SUBSET_" SUBSET REFRESH FAILED ON DETAIL LOOKUP: "_DTSID)
... S FCNT=0
;
XISUB L -^BSTS(9002318.1,0)
K ^TMP("BSTSISUB",$J)
Q
;
UPCNC ;Refresh any outdated concepts
;
NEW DTSID,ABORT,CIEN,STS,MFAIL,FWAIT,X1,X2,X
;
;
;Perform lock
L +^BSTS(9002318.1,0):0 E Q
;
;Reset Monitoring Global
K ^XTMP("BSTSLCMP")
;
;Get later date
S X1=DT,X2=60 D C^%DTC
;
;Set up Monitoring Global
S ^XTMP("BSTSLCMP",0)=X_U_DT_U_"Updating concepts found to be out of date"
;
;Retrieve Failover Variables
S MFAIL=$$FPARMS^BSTSVOFL()
S FWAIT=$P(MFAIL,U,2)
S MFAIL=$P(MFAIL,U)
;
;Look for removed entries
S ABORT=0,STS="" S CIEN="" F S CIEN=$O(^XTMP("BSTSPROCQ","C",CIEN)) Q:CIEN="" D Q:$D(^XTMP("BSTSLCMP","QUIT"))
. NEW LMOD,DTSID,FCNT,TRY,DTSID,NMID,OOD
. ;
. ;Get DTSId
. S DTSID=$$GET1^DIQ(9002318.4,CIEN_",",".08","I") I DTSID="" K ^XTMP("BSTSPROCQ","C",CIEN) Q
. ;
. ;Get NMID
. S NMID=$$GET1^DIQ(9002318.4,CIEN_",",.07,"E") I NMID="" K ^XTMP("BSTSPROCQ","C",CIEN) Q
. ;
. ;Check last modified - skip if today
. S OOD=$$GET1^DIQ(9002318.4,CIEN_",",".11","I")
. S LMOD=$$GET1^DIQ(9002318.4,CIEN_",",.12,"I") I OOD'="Y",LMOD'<DT K ^XTMP("BSTSPROCQ","C",CIEN) Q
. ;
. S ^XTMP("BSTSLCMP","STS")="Updating out of date entry with DTSID: "_DTSID
. ;Pull detail from DTS - Hang max of 12 times
. S (ABORT,FCNT)=0 F TRY=1:1:(12*MFAIL) D I +STS=2!(STS="0^") Q
.. D RESET^BSTSWSV1 ;Reset the DTS link to on
.. S STS=$$DTSLKP^BSTSAPI("VAR",DTSID_"^"_NMID_"^^^^1") I +STS=2!(STS="0^") Q
.. S FCNT=FCNT+1 I FCNT'<MFAIL D ;Fail handling
... S ABORT=$$FAIL^BSTSVOFL(MFAIL,FWAIT,TRY,"UPCNC^BSTSVOF1 - Getting Update for entry: "_DTSID)
... I ABORT=1 S ^XTMP("BSTSLCMP","QUIT")=1 D ELOG^BSTSVOFL("UPCNC^BSTSVOF1 Refresh failed on entry: "_DTSID)
... S FCNT=0
. ;
. ;Clear entry
. I +STS=2!(STS="0^") K ^XTMP("BSTSPROCQ","C",CIEN)
;
XUPCNC ;
;
;Unlock entry
L -^BSTS(9002318.1,0)
;
;Reset Monitoring Global
K ^XTMP("BSTSLCMP")
;
Q
;
CLLMDT(NMID) ;Mark CODESET concepts last modified date to null
;
I $G(NMID)="" Q
;
NEW ICONC,CIEN
;
;Loop through concepts and clear out modified date for codes in codeset
S ^XTMP("BSTSLCMP","STS")="Marking entries as out of date"
S ICONC="" F S ICONC=$O(^BSTS(9002318.4,"C",NMID,ICONC)) Q:ICONC="" D
. S CIEN="" F S CIEN=$O(^BSTS(9002318.4,"C",NMID,ICONC,CIEN)) Q:CIEN="" D
.. NEW CDSET,BSTS,ERR,LMD,OOD
.. ;
.. ;Skip partial entries
.. I $$GET1^DIQ(9002318.4,CIEN_",",.03,"I")="P" Q
.. ;
.. ;Don't clear if updated today (or later as process could run across days)
.. S OOD=$$GET1^DIQ(9002318.4,CIEN_",",.11,"I")
.. S LMD=$$GET1^DIQ(9002318.4,CIEN_",",.12,"I")
.. I OOD'="Y",LMD'<DT Q
.. ;
.. ;Mark as out of date
.. S ^XTMP("BSTSLCMP","STS")="Marking entry "_CIEN_" as out of date"
.. S BSTS(9002318.4,CIEN_",",".12")="@"
.. D FILE^DIE("","BSTS","ERR")
;
Q
;
;BSTS*2.0*1;Added override checking
DAYCHK(OVRRID) ;Perform daily update checks - jobbed off by CHECK^BSTSVRSN
;
S OVRRID=+$G(OVRRID)
;
NEW BSTS,STS,NMIEN,ZTSK,SITE,ERROR,ZTRTN,ZTDESC,ZTIO,ZTDTH,TFND,ZT1,ZTS
;
;Get Site Parameter IEN
S SITE=$O(^BSTS(9002318,0)) I 'SITE G XDAYCHK
;
;Check for new SNOMED CT US Extension '36' version - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(36,OVRRID)
;
;Check for new RxNorm R '1552' version - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(1552,OVRRID)
;
;Check for new UNII '5180' version - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(5180,OVRRID)
;
;Check for new IHS VANDF '32771' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32771,OVRRID)
;
;Check for new GMRA Signs Symptoms '32772' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32772,OVRRID)
;
;Check for new GMRA Allergies with Maps '32773' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32773,OVRRID)
;
;Check for new IHS Med Route '32774' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32774,OVRRID)
;
;Check for new CPT Meds with Maps '32775' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32775,OVRRID)
;
;Check for new SNOMED CT to ICD-10-CM Auto-Codeables '32777' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32777,OVRRID)
;
;Check for new SNOMED CT to ICD-10-CM Auto-Codeables '32779' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32779,OVRRID)
;
;BSTS*1.0*7;Added 32780 check
;Check for new SNOMED CT to ICD-10-CM Auto-Codeables '32780' - Quit if check performed or DTS timed out
S STS=$$VCHK^BSTSVRSN(32780,OVRRID)
;
;Check for new SNOMED CT to ICD-9-CM Auto-Codeables '32778' - Quit if check performed or DTS timed out
;BSTS*1.0*6;No longer look for ICD9 updates
;S STS=$$VCHK(32778) I STS G XCHECK
;
;Check for needed subset refresh - Also refresh VUID/NDC entries
S NMIEN=$O(^BSTS(9002318.1,"B",36,"")) I NMIEN="" G XDAYCHK
I ($$GET1^DIQ(9002318.1,NMIEN_",",.06,"I")'=DT)!(OVRRID) D SCHK^BSTSVRSN(36,1)
;
;Check for needed RxNorm subset refresh
S NMIEN=$O(^BSTS(9002318.1,"B",1552,"")) I NMIEN="" G XDAYCHK
I ($$GET1^DIQ(9002318.1,NMIEN_",",.06,"I")'=DT)!(OVRRID) D SCHK^BSTSVRXN(1552,1)
;
;BSTS*1.0*8;Process no longer works
;Check to see if ICD9 to SMD process needs run - Only run once
;I $$GET1^DIQ(9002318.1,NMIEN_",",".09","I")="" D QUEUE^BSTSVOFL("ICD")
;
;Schedule daily error purge
D QUEUE^BSTSVOFL("PRG")
;
;Schedule status logging
D QUEUE^BSTSVOFL("STS")
;
;Completed checks for day - mark parameter
S BSTS(9002318,SITE_",",.03)=DT
D FILE^DIE("","BSTS","ERROR")
;
;Schedule the process to run at 6:02
I '$$PSCHD("BSTSVOFL") S ZTSK=$$JOB^BSTSVOFL()
;
;Schedule job to run tomorrow if not already scheduled
I '$$PSCHD("BSTSVRSN") D
. S ZTRTN="CHECK^BSTSVRSN"
. S ZTDESC="BSTS - Schedule check to run"
. S ZTIO=""
. S ZTDTH=$$FMADD^XLFDT(DT_".1030",,24)
. D ^%ZTLOAD
;
XDAYCHK Q
;
PSCHD(RTN) ;Check if process already scheduled to run
;
I $G(RTN)="" Q ""
;
NEW TFND,ZT1,ZTS
;
S TFND="",ZT1=$$H3^%ZTM($H) F S ZT1=$O(^%ZTSCH(ZT1)) Q:'ZT1 D
. S ZTS=0 F S ZTS=$O(^%ZTSCH(ZT1,ZTS)) Q:'ZTS D
.. ;
.. NEW TASKND,SCHDT,RUNDT
.. ;
.. ;Get the task
.. S TASKND=$G(^%ZTSK(ZTS,0)) Q:TASKND=""
.. I $P(TASKND,U,2)'=RTN Q
.. S TFND=1
;
Q TFND
BSTSVOF1 ;GDIT/HS/BEE-Standard Terminology - Versioning handling overflow 2 ; 5 Nov 2012 9:53 AM
+1 ;;2.0;IHS STANDARD TERMINOLOGY;**1**;Dec 01, 2016;Build 36
+2 ;
+3 QUIT
+4 ;
+5 ;BSTS*1.0*6;Change to updates
+6 ;Run the PCC update option
+7 ;BSTS*2.0*1;CR#8457;Switch DUZ to PCC UIFS UPDATE USER (or ADAM,ADAM)
UIFS(ZTQUEUED) ;Run the PCC UIFS option
+1 ;
+2 IF '$DATA(ZTQUEUED)
SET ZTQUEUED=1
+3 ;
+4 NEW NDUZ,ODUZ,DA
+5 ;
+6 ;Retrieve the default BSTS,PROXY USER
+7 SET NDUZ=$ORDER(^VA(200,"B","BSTS,PROXY USER",""))
+8 ;Default to existing user if BSTS,PROXY USER cannot be found
IF NDUZ=""
SET NDUZ=DUZ
+9 ;
+10 ;Switch users, run PCC UIFS option, and switch back to original user
+11 SET ^XTMP("BSTSLCMP","STS")="Running the PCC Update ICD-10 Diagnoses from SNOMED Concept ID (UIFS) option"
EX1 ;SAC Exemption Granted 1/31/17-See bsts0200.01t
MERGE ODUZ=DUZ
KILL DUZ
SET DUZ=NDUZ
DO DUZ^XUP(.DUZ)
DO QUEUE^APCDPLFH
KILL DUZ
MERGE DUZ=ODUZ
+1 QUIT
+2 ;
ASKSB() ;Ask Individual Subset
+1 ;
+2 NEW DIR,X,Y,SUBSET,DIRUT,DUOUT,SLIST,STS,I
+3 ;
+4 ;Get subsets
+5 SET STS=$$SUBSET^BSTSAPI("SLIST","^2")
+6 ;
+7 ;Sort
SET SLIST=""
FOR
SET SLIST=$ORDER(SLIST(SLIST))
IF 'SLIST
QUIT
IF SLIST(SLIST)]""
SET SLIST("B",SLIST(SLIST))=""
+8 SET SLIST=""
FOR I=1:1
SET SLIST=$ORDER(SLIST("B",SLIST))
IF SLIST=""
QUIT
SET DIR("?",I)=SLIST
+9 ;
+10 SET SUBSET=""
+11 ;
ASKSB1 WRITE !!
SET DIR("?")="Select a subset from the following list or type ALL for all subsets"
+1 SET DIR("A")="Enter the exact name of the subset to refresh or ALL: "
+2 SET DIR("B")="ALL"
+3 SET DIR(0)="F^3:50"
+4 DO ^DIR
IF $GET(DIRUT)!$GET(DUOUT)!(Y="")
QUIT "-1"
+5 ;
+6 ;BSTS*1.0*4;Filter out IHS PROBLEM ALL SNOMED
+7 IF Y="IHS PROBLEM ALL SNOMED"
WRITE !!,"CANNOT DOWNLOAD IHS PROBLEM ALL SNOMED"
HANG 3
GOTO ASKSB1
+8 IF Y]""
IF Y'="ALL"
IF '$DATA(SLIST("B",Y))
WRITE !!,"INVALID SUBSET"
HANG 3
GOTO ASKSB1
+9 ;
+10 SET SUBSET=Y
+11 ;
+12 QUIT SUBSET
+13 ;
ISCHK(SUBSET) ;EP - Recompile one subset
+1 ;
+2 NEW STS,VAR,ZTDTH,ZTDESC,ZTRTN,ZTIO,ZTSAVE,BSTSUPD,ERROR,FIELD,ZTSK,TR
+3 ;
+4 ;Only one SNOMED background process can be running at a time
+5 LOCK +^BSTS(9002318.1,0):0
IF '$TEST
WRITE !!,"A Local Cache Refresh is Already Running. Please Try Later"
HANG 3
QUIT
+6 LOCK -^BSTS(9002318.1,0)
+7 ;
+8 ;Make sure ICD9 to SNOMED background process isn't running
+9 LOCK +^TMP("BSTSICD2SMD"):0
IF '$TEST
WRITE !!,"An ICD9 to SNOMED Background Process is Already Running. Please Try Later"
HANG 3
QUIT
+10 LOCK -^TMP("BSTSICD2SMD")
+11 ;
+12 ;Only run if server set up
+13 SET STS=""
FOR TR=1:1:60
Begin DoDot:1
+14 ;Reset the DTS link to on
DO RESET^BSTSWSV1
+15 ;Try a quick call to see if call works
SET STS=$$VERSIONS^BSTSAPI("VAR")
+16 IF +STS'=2
HANG TR
End DoDot:1
IF +STS=2
QUIT
+17 IF +STS'=2
WRITE !!,"The DTS server link is down. Aborting..."
GOTO XISCHK
+18 ;
+19 ;Queue the process off in the background
+20 SET ZTRTN="ISUB^BSTSVOF1"
SET ZTDESC="BSTS - Refresh BSTS subset "_SUBSET
+21 SET ZTSAVE("SUBSET")=""
+22 ;
+23 SET ZTIO=""
+24 SET ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT(),,,2)
+25 DO ^%ZTLOAD
+26 IF $GET(ZTSK)]""
WRITE !!,"Task: ",ZTSK," scheduled to start in two minutes"
+27 ;
XISCHK QUIT
+1 ;
ISUB ;Recompile one subset
+1 ;
+2 ;Perform lock so only one process is allowed
+3 LOCK +^BSTS(9002318.1,0):1
IF '$TEST
QUIT
+4 ;
+5 NEW BSTSBPRC,MFAIL,FWAIT,TRY,STS,ABORT,NMIEN,CIEN
+6 ;
+7 IF $GET(SUBSET)=""
GOTO XISUB
+8 ;
+9 ;Save current entries
+10 KILL ^TMP("BSTSISUB",$JOB)
+11 SET NMIEN=$ORDER(^BSTS(9002318.1,"B",36,""))
IF NMIEN=""
GOTO XISUB
+12 SET CIEN=""
FOR
SET CIEN=$ORDER(^BSTS(9002318.4,"E",NMIEN,SUBSET,CIEN))
IF CIEN=""
QUIT
SET ^TMP("BSTSISUB",$JOB,CIEN)=$$GET1^DIQ(9002318.4,CIEN_",",.08,"I")
+13 ;
+14 ;Retrieve Failover Variables
+15 SET MFAIL=$$FPARMS^BSTSVOFL()
+16 SET FWAIT=$PIECE(MFAIL,U,2)
+17 SET MFAIL=$PIECE(MFAIL,U)
+18 ;
+19 ;Make the call until success - Hang max of 12 times
+20 SET ABORT=0
FOR TRY=1:1:(12*MFAIL)
Begin DoDot:1
+21 NEW IN,OUT
+22 SET IN=SUBSET_"^^2"
SET FCNT=0
+23 SET OUT=$NAME(^TMP("BSTSSUPD",$JOB))
KILL @OUT
+24 ;Set variable showing background call
SET BSTSBPRC=1
+25 ;Make sure the link is on
DO RESET^BSTSWSV1
+26 ;Quit if success
SET STS=$$SUBLST^BSTSAPI(OUT,IN)
IF +STS=2
QUIT
+27 IF $DATA(^XTMP("BSTSLCMP","QUIT"))
QUIT
+28 ;Fail handling
SET FCNT=FCNT+1
IF FCNT'<MFAIL
Begin DoDot:2
+29 SET ABORT=$$FAIL^BSTSVOFL(MFAIL,FWAIT,TRY,"SUB^BSTSVOD1 - Processing subset: "_SUBSET)
End DoDot:2
+30 IF ABORT=1
SET ^XTMP("BSTSLCMP","QUIT")=1
DO ELOG^BSTSVOFL("SUBSET REFRESH FAILED ON SUBSET: "_SUBSET)
+31 SET FCNT=0
End DoDot:1
IF $DATA(^XTMP("BSTSLCMP","QUIT"))
QUIT
IF +STS=2!(STS="0^")
QUIT
+32 ;
+33 ;Look for removed entries
+34 IF ABORT=0
SET CIEN=""
FOR
SET CIEN=$ORDER(^TMP("BSTSISUB",$JOB,CIEN))
IF CIEN=""
QUIT
Begin DoDot:1
+35 NEW LMOD,DTSID,ABORT,FCNT,TRY
+36 SET DTSID=$GET(^TMP("BSTSISUB",$JOB,CIEN))
IF DTSID=""
QUIT
+37 ;
+38 ;Check last modified - skip if today
+39 SET LMOD=$$GET1^DIQ(9002318.4,CIEN_",",.12,"I")
IF LMOD'<DT
QUIT
+40 ;
+41 ;Pull detail from DTS - Hang max of 12 times
+42 SET (ABORT,FCNT)=0
FOR TRY=1:1:(12*MFAIL)
Begin DoDot:2
+43 ;Reset the DTS link to on
DO RESET^BSTSWSV1
+44 SET STS=$$DTSLKP^BSTSAPI("VAR",DTSID_"^36^^^^1")
IF +STS=2!(STS="0^")
QUIT
+45 ;Fail handling
SET FCNT=FCNT+1
IF FCNT'<MFAIL
Begin DoDot:3
+46 SET ABORT=$$FAIL^BSTSVOFL(MFAIL,FWAIT,TRY,"ISUB^BSTSVRSN - Getting Update for entry: "_DTSID)
+47 IF ABORT=1
SET ^XTMP("BSTSLCMP","QUIT")=1
DO ELOG^BSTSVOFL(SUBSET_" SUBSET REFRESH FAILED ON DETAIL LOOKUP: "_DTSID)
+48 SET FCNT=0
End DoDot:3
End DoDot:2
IF +STS=2!(STS="0^")
QUIT
End DoDot:1
IF $DATA(^XTMP("BSTSLCMP","QUIT"))
QUIT
+49 ;
XISUB LOCK -^BSTS(9002318.1,0)
+1 KILL ^TMP("BSTSISUB",$JOB)
+2 QUIT
+3 ;
UPCNC ;Refresh any outdated concepts
+1 ;
+2 NEW DTSID,ABORT,CIEN,STS,MFAIL,FWAIT,X1,X2,X
+3 ;
+4 ;
+5 ;Perform lock
+6 LOCK +^BSTS(9002318.1,0):0
IF '$TEST
QUIT
+7 ;
+8 ;Reset Monitoring Global
+9 KILL ^XTMP("BSTSLCMP")
+10 ;
+11 ;Get later date
+12 SET X1=DT
SET X2=60
DO C^%DTC
+13 ;
+14 ;Set up Monitoring Global
+15 SET ^XTMP("BSTSLCMP",0)=X_U_DT_U_"Updating concepts found to be out of date"
+16 ;
+17 ;Retrieve Failover Variables
+18 SET MFAIL=$$FPARMS^BSTSVOFL()
+19 SET FWAIT=$PIECE(MFAIL,U,2)
+20 SET MFAIL=$PIECE(MFAIL,U)
+21 ;
+22 ;Look for removed entries
+23 SET ABORT=0
SET STS=""
SET CIEN=""
FOR
SET CIEN=$ORDER(^XTMP("BSTSPROCQ","C",CIEN))
IF CIEN=""
QUIT
Begin DoDot:1
+24 NEW LMOD,DTSID,FCNT,TRY,DTSID,NMID,OOD
+25 ;
+26 ;Get DTSId
+27 SET DTSID=$$GET1^DIQ(9002318.4,CIEN_",",".08","I")
IF DTSID=""
KILL ^XTMP("BSTSPROCQ","C",CIEN)
QUIT
+28 ;
+29 ;Get NMID
+30 SET NMID=$$GET1^DIQ(9002318.4,CIEN_",",.07,"E")
IF NMID=""
KILL ^XTMP("BSTSPROCQ","C",CIEN)
QUIT
+31 ;
+32 ;Check last modified - skip if today
+33 SET OOD=$$GET1^DIQ(9002318.4,CIEN_",",".11","I")
+34 SET LMOD=$$GET1^DIQ(9002318.4,CIEN_",",.12,"I")
IF OOD'="Y"
IF LMOD'<DT
KILL ^XTMP("BSTSPROCQ","C",CIEN)
QUIT
+35 ;
+36 SET ^XTMP("BSTSLCMP","STS")="Updating out of date entry with DTSID: "_DTSID
+37 ;Pull detail from DTS - Hang max of 12 times
+38 SET (ABORT,FCNT)=0
FOR TRY=1:1:(12*MFAIL)
Begin DoDot:2
+39 ;Reset the DTS link to on
DO RESET^BSTSWSV1
+40 SET STS=$$DTSLKP^BSTSAPI("VAR",DTSID_"^"_NMID_"^^^^1")
IF +STS=2!(STS="0^")
QUIT
+41 ;Fail handling
SET FCNT=FCNT+1
IF FCNT'<MFAIL
Begin DoDot:3
+42 SET ABORT=$$FAIL^BSTSVOFL(MFAIL,FWAIT,TRY,"UPCNC^BSTSVOF1 - Getting Update for entry: "_DTSID)
+43 IF ABORT=1
SET ^XTMP("BSTSLCMP","QUIT")=1
DO ELOG^BSTSVOFL("UPCNC^BSTSVOF1 Refresh failed on entry: "_DTSID)
+44 SET FCNT=0
End DoDot:3
End DoDot:2
IF +STS=2!(STS="0^")
QUIT
+45 ;
+46 ;Clear entry
+47 IF +STS=2!(STS="0^")
KILL ^XTMP("BSTSPROCQ","C",CIEN)
End DoDot:1
IF $DATA(^XTMP("BSTSLCMP","QUIT"))
QUIT
+48 ;
XUPCNC ;
+1 ;
+2 ;Unlock entry
+3 LOCK -^BSTS(9002318.1,0)
+4 ;
+5 ;Reset Monitoring Global
+6 KILL ^XTMP("BSTSLCMP")
+7 ;
+8 QUIT
+9 ;
CLLMDT(NMID) ;Mark CODESET concepts last modified date to null
+1 ;
+2 IF $GET(NMID)=""
QUIT
+3 ;
+4 NEW ICONC,CIEN
+5 ;
+6 ;Loop through concepts and clear out modified date for codes in codeset
+7 SET ^XTMP("BSTSLCMP","STS")="Marking entries as out of date"
+8 SET ICONC=""
FOR
SET ICONC=$ORDER(^BSTS(9002318.4,"C",NMID,ICONC))
IF ICONC=""
QUIT
Begin DoDot:1
+9 SET CIEN=""
FOR
SET CIEN=$ORDER(^BSTS(9002318.4,"C",NMID,ICONC,CIEN))
IF CIEN=""
QUIT
Begin DoDot:2
+10 NEW CDSET,BSTS,ERR,LMD,OOD
+11 ;
+12 ;Skip partial entries
+13 IF $$GET1^DIQ(9002318.4,CIEN_",",.03,"I")="P"
QUIT
+14 ;
+15 ;Don't clear if updated today (or later as process could run across days)
+16 SET OOD=$$GET1^DIQ(9002318.4,CIEN_",",.11,"I")
+17 SET LMD=$$GET1^DIQ(9002318.4,CIEN_",",.12,"I")
+18 IF OOD'="Y"
IF LMD'<DT
QUIT
+19 ;
+20 ;Mark as out of date
+21 SET ^XTMP("BSTSLCMP","STS")="Marking entry "_CIEN_" as out of date"
+22 SET BSTS(9002318.4,CIEN_",",".12")="@"
+23 DO FILE^DIE("","BSTS","ERR")
End DoDot:2
End DoDot:1
+24 ;
+25 QUIT
+26 ;
+27 ;BSTS*2.0*1;Added override checking
DAYCHK(OVRRID) ;Perform daily update checks - jobbed off by CHECK^BSTSVRSN
+1 ;
+2 SET OVRRID=+$GET(OVRRID)
+3 ;
+4 NEW BSTS,STS,NMIEN,ZTSK,SITE,ERROR,ZTRTN,ZTDESC,ZTIO,ZTDTH,TFND,ZT1,ZTS
+5 ;
+6 ;Get Site Parameter IEN
+7 SET SITE=$ORDER(^BSTS(9002318,0))
IF 'SITE
GOTO XDAYCHK
+8 ;
+9 ;Check for new SNOMED CT US Extension '36' version - Quit if check performed or DTS timed out
+10 SET STS=$$VCHK^BSTSVRSN(36,OVRRID)
+11 ;
+12 ;Check for new RxNorm R '1552' version - Quit if check performed or DTS timed out
+13 SET STS=$$VCHK^BSTSVRSN(1552,OVRRID)
+14 ;
+15 ;Check for new UNII '5180' version - Quit if check performed or DTS timed out
+16 SET STS=$$VCHK^BSTSVRSN(5180,OVRRID)
+17 ;
+18 ;Check for new IHS VANDF '32771' - Quit if check performed or DTS timed out
+19 SET STS=$$VCHK^BSTSVRSN(32771,OVRRID)
+20 ;
+21 ;Check for new GMRA Signs Symptoms '32772' - Quit if check performed or DTS timed out
+22 SET STS=$$VCHK^BSTSVRSN(32772,OVRRID)
+23 ;
+24 ;Check for new GMRA Allergies with Maps '32773' - Quit if check performed or DTS timed out
+25 SET STS=$$VCHK^BSTSVRSN(32773,OVRRID)
+26 ;
+27 ;Check for new IHS Med Route '32774' - Quit if check performed or DTS timed out
+28 SET STS=$$VCHK^BSTSVRSN(32774,OVRRID)
+29 ;
+30 ;Check for new CPT Meds with Maps '32775' - Quit if check performed or DTS timed out
+31 SET STS=$$VCHK^BSTSVRSN(32775,OVRRID)
+32 ;
+33 ;Check for new SNOMED CT to ICD-10-CM Auto-Codeables '32777' - Quit if check performed or DTS timed out
+34 SET STS=$$VCHK^BSTSVRSN(32777,OVRRID)
+35 ;
+36 ;Check for new SNOMED CT to ICD-10-CM Auto-Codeables '32779' - Quit if check performed or DTS timed out
+37 SET STS=$$VCHK^BSTSVRSN(32779,OVRRID)
+38 ;
+39 ;BSTS*1.0*7;Added 32780 check
+40 ;Check for new SNOMED CT to ICD-10-CM Auto-Codeables '32780' - Quit if check performed or DTS timed out
+41 SET STS=$$VCHK^BSTSVRSN(32780,OVRRID)
+42 ;
+43 ;Check for new SNOMED CT to ICD-9-CM Auto-Codeables '32778' - Quit if check performed or DTS timed out
+44 ;BSTS*1.0*6;No longer look for ICD9 updates
+45 ;S STS=$$VCHK(32778) I STS G XCHECK
+46 ;
+47 ;Check for needed subset refresh - Also refresh VUID/NDC entries
+48 SET NMIEN=$ORDER(^BSTS(9002318.1,"B",36,""))
IF NMIEN=""
GOTO XDAYCHK
+49 IF ($$GET1^DIQ(9002318.1,NMIEN_",",.06,"I")'=DT)!(OVRRID)
DO SCHK^BSTSVRSN(36,1)
+50 ;
+51 ;Check for needed RxNorm subset refresh
+52 SET NMIEN=$ORDER(^BSTS(9002318.1,"B",1552,""))
IF NMIEN=""
GOTO XDAYCHK
+53 IF ($$GET1^DIQ(9002318.1,NMIEN_",",.06,"I")'=DT)!(OVRRID)
DO SCHK^BSTSVRXN(1552,1)
+54 ;
+55 ;BSTS*1.0*8;Process no longer works
+56 ;Check to see if ICD9 to SMD process needs run - Only run once
+57 ;I $$GET1^DIQ(9002318.1,NMIEN_",",".09","I")="" D QUEUE^BSTSVOFL("ICD")
+58 ;
+59 ;Schedule daily error purge
+60 DO QUEUE^BSTSVOFL("PRG")
+61 ;
+62 ;Schedule status logging
+63 DO QUEUE^BSTSVOFL("STS")
+64 ;
+65 ;Completed checks for day - mark parameter
+66 SET BSTS(9002318,SITE_",",.03)=DT
+67 DO FILE^DIE("","BSTS","ERROR")
+68 ;
+69 ;Schedule the process to run at 6:02
+70 IF '$$PSCHD("BSTSVOFL")
SET ZTSK=$$JOB^BSTSVOFL()
+71 ;
+72 ;Schedule job to run tomorrow if not already scheduled
+73 IF '$$PSCHD("BSTSVRSN")
Begin DoDot:1
+74 SET ZTRTN="CHECK^BSTSVRSN"
+75 SET ZTDESC="BSTS - Schedule check to run"
+76 SET ZTIO=""
+77 SET ZTDTH=$$FMADD^XLFDT(DT_".1030",,24)
+78 DO ^%ZTLOAD
End DoDot:1
+79 ;
XDAYCHK QUIT
+1 ;
PSCHD(RTN) ;Check if process already scheduled to run
+1 ;
+2 IF $GET(RTN)=""
QUIT ""
+3 ;
+4 NEW TFND,ZT1,ZTS
+5 ;
+6 SET TFND=""
SET ZT1=$$H3^%ZTM($HOROLOG)
FOR
SET ZT1=$ORDER(^%ZTSCH(ZT1))
IF 'ZT1
QUIT
Begin DoDot:1
+7 SET ZTS=0
FOR
SET ZTS=$ORDER(^%ZTSCH(ZT1,ZTS))
IF 'ZTS
QUIT
Begin DoDot:2
+8 ;
+9 NEW TASKND,SCHDT,RUNDT
+10 ;
+11 ;Get the task
+12 SET TASKND=$GET(^%ZTSK(ZTS,0))
IF TASKND=""
QUIT
+13 IF $PIECE(TASKND,U,2)'=RTN
QUIT
+14 SET TFND=1
End DoDot:2
End DoDot:1
+15 ;
+16 QUIT TFND