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

BSTSWSV1.m

Go to the documentation of this file.
  1. BSTSWSV1 ;GDIT/HS/BEE-Standard Terminology Web Service Handling (CONT) ; 5 Nov 2012 9:53 AM
  1. ;;2.0;IHS STANDARD TERMINOLOGY;;Dec 01, 2016;Build 62
  1. ;
  1. Q
  1. ;
  1. SCODE(NMID) ;EP - Get a list of concepts in subsets
  1. ;
  1. ;Input
  1. ; NMID (Optional) - Codeset to run
  1. ;
  1. ;Output
  1. ; Function returns - [1]^[2]^[3]
  1. ; [1] - 1:Successful remote call
  1. ; 0:Unsuccessful remote call
  1. ; [2] - Primary Remote Error Message
  1. ; [3] - Secondary Remote Error Message (if applicable)
  1. ;
  1. N BSTSSRV,PRI,STS,II
  1. ;
  1. S NMID=$G(NMID)
  1. ;
  1. ;Get list of servers
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,"")
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 S STS="0^No Active Server Found"
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS) I '+STS Q
  1. . ;
  1. . ;Call DTS
  1. . I TYPE="D" D
  1. .. I NMID=1552 S CSTS=$$RCODE^BSTSDTS5(.BSTSWS) Q
  1. .. S CSTS=$$SCODE^BSTSDTS4(.BSTSWS)
  1. . ;
  1. . ;Log call times (needs completed)
  1. . S TIME=$P(CSTS,U,3)
  1. . ;
  1. . ;Define status variable
  1. . S $P(STS,U)=+CSTS
  1. . I II<4 S $P(STS,U,II)=$P(CSTS,U,2)
  1. ;
  1. Q STS
  1. ;
  1. DILKP(OUT,IN,DEBUG) ;EP - Perform a Web Service Drug Ingredient Lookup
  1. ;
  1. ;Input
  1. ; OUT - Output variable/global to return information in (VAR)
  1. ; IN Array - List of search parameters
  1. ; DEBUG - 1:DEBUG mode
  1. ;
  1. ;Output
  1. ; Function returns - [1]^[2]^[3]
  1. ; [1] - 1:Successful remote call
  1. ; 0:Unsuccessful remote call
  1. ; [2] - Primary Remote Error Message
  1. ; [3] - Secondary Remote Error Message (if applicable)
  1. ;
  1. ; VAR(#) - [1]^[2]^[3]
  1. ; [1] - Concept ID
  1. ; [2] - DTS ID
  1. ; [3] - Description ID
  1. ;
  1. N BSTSSRV,PRI,STS,II
  1. ;
  1. ;Define DEBUG
  1. S DEBUG=$G(DEBUG,"")
  1. ;
  1. ;Get list of servers
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,DEBUG)
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 S STS="0^No Active Server Found"
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS) I '+STS Q
  1. . ;
  1. . ;Call DTS
  1. . I TYPE="D" S CSTS=$$DILKP^BSTSDTS1(OUT,.BSTSWS)
  1. . I $G(BSTSWS("DEBUG")) W !!,"DTS: ",CSTS,!
  1. . ;
  1. . ;Log call times (needs completed)
  1. . S TIME=$P(CSTS,U,3)
  1. . ;
  1. . ;Define status variable
  1. . S $P(STS,U)=+CSTS
  1. . I II<4 S $P(STS,U,II)=$P(CSTS,U,2)
  1. ;
  1. Q STS
  1. ;
  1. ;
  1. USEARCH(OUT,IN,DEBUG) ;EP - Perform a Web Service UNIVERSE Search
  1. ;
  1. ;Input
  1. ; OUT - Output variable/global to return information in (VAR)
  1. ; IN Array - List of search parameters
  1. ; DEBUG - 1:DEBUG mode
  1. ;
  1. ;Output
  1. ; Function returns - [1]^[2]^[3]
  1. ; [1] - 1:Successful remote call
  1. ; 0:Unsuccessful remote call
  1. ; [2] - Primary Remote Error Message
  1. ; [3] - Secondary Remote Error Message (if applicable)
  1. ;
  1. ; VAR(#) - [1]^[2]^[3]
  1. ; [1] - Concept ID
  1. ; [2] - DTS ID
  1. ; [3] - Description ID
  1. ;
  1. N BSTSSRV,PRI,STS,II
  1. ;
  1. ;Define DEBUG
  1. S DEBUG=$G(DEBUG,"")
  1. ;
  1. ;Get list of servers
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,DEBUG)
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 S STS="0^No Active Server Found"
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS) I '+STS Q
  1. . ;
  1. . ;Call DTS
  1. . S CSTS=$$USEARCH^BSTSDTS4(OUT,.BSTSWS)
  1. . I $G(BSTSWS("DEBUG")) W !!,"DTS: ",CSTS,!
  1. . ;
  1. . ;Log call times (needs completed)
  1. . S TIME=$P(CSTS,U,3)
  1. . ;
  1. . ;Define status variable
  1. . S $P(STS,U)=+CSTS
  1. . I II<4 S $P(STS,U,II)=$P(CSTS,U,2)
  1. ;
  1. Q STS
  1. ;
  1. CKDTS(BSTSWS) ;EP - Determine whether to perform remote call
  1. ;
  1. ;Input: BSTSWS Array of Web Service data
  1. ;
  1. ;Returns: 1 - Make call to DTS
  1. ; 0^Server Set to Local - Do not make DTS call
  1. ;
  1. NEW BIEN,SWCHLCL,%,VAR,STS,CKPRD,NWCK,BSTS,ERR
  1. ;
  1. ;Retrieve definition IEN
  1. S BIEN=$G(BSTSWS("IEN")) Q:BIEN="" 0
  1. ;
  1. ;If CHECK FOR DTS CONNECTION ON is blank allow it
  1. S SWCHLCL=$$GET1^DIQ(9002318.2,BIEN_",",.13,"I") Q:SWCHLCL="" 1
  1. ;
  1. ;Skip for overrides
  1. I $G(BSTSWS("TBYPASS"))=1 Q 1
  1. ;
  1. ;If there is a date/time see if check needs to be performed
  1. ;If date is in the future stay local
  1. D NOW^%DTC I SWCHLCL>% Q "0^Server Set To Local"
  1. ;
  1. ;Perform a DTS Remote lookup
  1. S STS=$$VERSIONS^BSTSAPI("VAR")
  1. ;
  1. ;If success, clear out CHECK FOR DTS CONNECTION ON
  1. I +STS=2 D UPDT(BIEN,"@") Q 1
  1. ;
  1. ;Update CHECK FOR CONNECTION AFTER value - if blank use 60 minutes in future
  1. D UPDT(BIEN,$P(STS,U,2))
  1. ;
  1. Q "0^Server Set To Local"
  1. ;
  1. SWLCL(BSTSWS,STS) ;EP - Switch To Local Check
  1. ;
  1. ;This call determines whether the DTS server should be switched to local
  1. ;
  1. NEW %,NWCK,BSTS,ERR,CKPRD,BIEN,MXSR,CTIME,SUCCESS
  1. ;
  1. ;Retrieve definition IEN
  1. S BIEN=$G(BSTSWS("IEN")) Q:BIEN=""
  1. ;
  1. ;Skip for overrides
  1. I $G(BSTSWS("TBYPASS"))=1 Q
  1. ;
  1. ;Check if call succeeded, if not switch to local
  1. S SUCCESS=$P(STS,U) I SUCCESS=0 D UPDT(BIEN,$S($P(STS,U,2)]"":$P(STS,U,2),1:"DTS call failed")) S $P(STS,U,2)="Switched Server to LOCAL" Q
  1. ;
  1. ;Get the call time
  1. S CTIME=$P(STS,U,3)
  1. ;
  1. ;Get the MAXIMUM REMOTE SEARCH TIME
  1. S MXSR=$$GET1^DIQ(9002318.2,BIEN_",",.15,"I") S:MXSR="" MXSR=60
  1. ;
  1. ;If time was too long, switch to local
  1. I CTIME>MXSR S $P(STS,U,2)="Switched Server to LOCAL" D UPDT(BIEN,"Call was successful but its duration exceeded the MAXIMUM REMOTE SEARCH TIME") Q
  1. ;
  1. Q
  1. ;
  1. UPDT(BIEN,VAL,OVMSG) ;EP - Update the CHECK FOR DTS CONNECTION ON
  1. ;
  1. ;Input: BIEN - Pointer to Web Service Entry
  1. ; VAL - Error Message - Switch Server to Local
  1. ; - @ - Switch Server back on
  1. ; OVMSG - Override message on @
  1. Q:BIEN=""
  1. I $G(VAL)'="@" D ^ZTER
  1. S OVMSG=$G(OVMSG)
  1. ;
  1. NEW BSTS,ERR,ERRMSG,LOG
  1. ;
  1. ;Log entry
  1. I VAL="@",OVMSG]"" S LOG=OVMSG
  1. E I VAL="@",OVMSG="" S LOG="Switched DTS connection on"
  1. E S LOG="Switched DTS Connection off: "_VAL
  1. D ELOG^BSTSVOFL(LOG)
  1. ;
  1. ;Get the error message
  1. S ERRMSG=$S(VAL="":"@",VAL'="@":VAL,1:"@")
  1. ;
  1. ;If value equals null, switch to local
  1. I $G(VAL)'="@" D
  1. . NEW CKPRD,%
  1. . ;
  1. . ;Retrieve CHECK FOR CONNECTION AFTER value - if blank use 60
  1. . S CKPRD=$$GET1^DIQ(9002318.2,BIEN_",",.14,"I") S:CKPRD="" CKPRD=60
  1. . ;
  1. . ;Get current date and time
  1. . D NOW^%DTC
  1. . ;
  1. . S VAL=$$FMADD^XLFDT(%,0,0,CKPRD,0)
  1. ;
  1. ;Update CHECK FOR DTS CONNECTION ON
  1. S BSTS(9002318.2,BIEN_",",.13)=VAL
  1. S BSTS(9002318.2,BIEN_",",3)=$E(ERRMSG,1,245)
  1. D FILE^DIE("","BSTS","ERR")
  1. ;
  1. Q
  1. ;
  1. CSTMCDST(OUT,IN) ;EP - Perform a Web Service Custom Codeset Listing
  1. ;
  1. ;Input
  1. ; OUT - Output variable/global to return information in (VAR)
  1. ; IN Array - List of search parameters
  1. ; DEBUG - 1:DEBUG mode
  1. ;
  1. ;Output
  1. ; Function returns - [1]^[2]^[3]
  1. ; [1] - 1:Successful remote call
  1. ; 0:Unsuccessful remote call
  1. ; [2] - Primary Remote Error Message
  1. ; [3] - Secondary Remote Error Message (if applicable)
  1. ;
  1. ; VAR(#) - [1]^[2]^[3]
  1. ; [1] - Concept ID
  1. ; [2] - DTS ID
  1. ; [3] - Description ID
  1. ;
  1. N BSTSSRV,PRI,STS,II
  1. ;
  1. ;Define DEBUG
  1. S DEBUG=$G(DEBUG,"")
  1. ;
  1. ;Get list of servers
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,DEBUG)
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 S STS="0^No Active Server Found"
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS) I '+STS Q
  1. . ;
  1. . ;Call DTS
  1. . S CSTS=$$CSTMCDST^BSTSDTS5(OUT,.BSTSWS)
  1. . I $G(BSTSWS("DEBUG")) W !!,"DTS: ",CSTS,!
  1. . ;
  1. . ;Log call times (needs completed)
  1. . S TIME=$P(CSTS,U,3)
  1. . ;
  1. . ;Define status variable
  1. . S $P(STS,U)=+CSTS
  1. . I II<4 S $P(STS,U,II)=$P(CSTS,U,2)
  1. ;
  1. Q STS
  1. ;
  1. ACODE(OUT,IN,DEBUG) ;EP - Perform a Web Service '36' auto-codable ICD10 Listing
  1. ;
  1. ;Input
  1. ; OUT - Output variable/global to return information in (VAR)
  1. ; IN Array - List of search parameters
  1. ; DEBUG - 1:DEBUG mode
  1. ;
  1. ;Output
  1. ; Function returns - [1]^[2]^[3]
  1. ; [1] - 1:Successful remote call
  1. ; 0:Unsuccessful remote call
  1. ; [2] - Primary Remote Error Message
  1. ; [3] - Secondary Remote Error Message (if applicable)
  1. ;
  1. ; VAR(#) - [1]^[2]^[3]
  1. ; [1] - Concept ID
  1. ; [2] - DTS ID
  1. ; [3] - Description ID
  1. ;
  1. N BSTSSRV,PRI,STS,II
  1. ;
  1. ;Define DEBUG
  1. S DEBUG=$G(DEBUG,"")
  1. ;
  1. ;Get list of servers
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,DEBUG)
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 S STS="0^No Active Server Found"
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS) I '+STS Q
  1. . ;
  1. . ;Call DTS
  1. . S CSTS=$$ACODE^BSTSDTS3(OUT,.BSTSWS)
  1. . I $G(BSTSWS("DEBUG")) W !!,"DTS: ",CSTS,!
  1. . ;
  1. . ;Log call times (needs completed)
  1. . S TIME=$P(CSTS,U,3)
  1. . ;
  1. . ;Define status variable
  1. . S $P(STS,U)=+CSTS
  1. . I II<4 S $P(STS,U,II)=$P(CSTS,U,2)
  1. ;
  1. Q STS
  1. ;
  1. A9CODE(OUT,IN,DEBUG) ;EP - Perform a Web Service '36' auto-codable ICD9 Listing
  1. ;
  1. ;Input
  1. ; OUT - Output variable/global to return information in (VAR)
  1. ; IN Array - List of search parameters
  1. ; DEBUG - 1:DEBUG mode
  1. ;
  1. ;Output
  1. ; Function returns - [1]^[2]^[3]
  1. ; [1] - 1:Successful remote call
  1. ; 0:Unsuccessful remote call
  1. ; [2] - Primary Remote Error Message
  1. ; [3] - Secondary Remote Error Message (if applicable)
  1. ;
  1. ; VAR(#) - [1]^[2]^[3]
  1. ; [1] - Concept ID
  1. ; [2] - DTS ID
  1. ; [3] - Description ID
  1. ;
  1. N BSTSSRV,PRI,STS,II
  1. ;
  1. ;Define DEBUG
  1. S DEBUG=$G(DEBUG,"")
  1. ;
  1. ;Get list of servers
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,DEBUG)
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 S STS="0^No Active Server Found"
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS) I '+STS Q
  1. . ;
  1. . ;Call DTS
  1. . S CSTS=$$A9CODE^BSTSDTS3(OUT,.BSTSWS)
  1. . I $G(BSTSWS("DEBUG")) W !!,"DTS: ",CSTS,!
  1. . ;
  1. . ;Log call times (needs completed)
  1. . S TIME=$P(CSTS,U,3)
  1. . ;
  1. . ;Define status variable
  1. . S $P(STS,U)=+CSTS
  1. . I II<4 S $P(STS,U,II)=$P(CSTS,U,2)
  1. ;
  1. Q STS
  1. ;
  1. ;BSTS*1.0*4;New tag to reset all links back on
  1. RESET ;EP - Turn all the links back on
  1. ;
  1. NEW SITE,SIEN
  1. ;
  1. S SITE=0 F S SITE=$O(^BSTS(9002318,SITE)) Q:'SITE S SIEN=0 F S SIEN=$O(^BSTS(9002318,SITE,1,SIEN)) Q:'SIEN D
  1. . NEW WIEN,IENS,DA
  1. . ;
  1. . ;Get the pointer to the web service entry
  1. . S DA(1)=SITE,DA=SIEN,IENS=$$IENS^DILF(.DA)
  1. . S WIEN=$$GET1^DIQ(9002318.01,IENS,".01","I") Q:WIEN=""
  1. . ;
  1. . ;Quit if online
  1. . I $$GET1^DIQ(9002318.2,WIEN_",",".13","I")="" Q
  1. . ;
  1. . ;Clear the status
  1. . D UPDT^BSTSWSV1(WIEN,"@","Reset DTS Link for connection retry")
  1. Q
  1. ;
  1. CKONOFF() ;Return when an online server is found
  1. ;
  1. NEW STS,BSTSSRV,PRI,II
  1. ;
  1. ;Get server list
  1. S STS=$$WSERVER^BSTSWSV(.BSTSSRV,"")
  1. ;
  1. ;Loop through list and make each call
  1. I $D(BSTSSRV)<10 Q 0
  1. I $D(BSTSSRV)>1 S STS=0,PRI="" F II=2:1 S PRI=$O(BSTSSRV(PRI)) Q:PRI="" D Q:+STS
  1. . ;
  1. . N BSTSWS,TYPE,TIME,CSTS
  1. . M BSTSWS=IN
  1. . M BSTSWS=BSTSSRV(PRI)
  1. . S TYPE=$G(BSTSWS("TYPE")),CSTS=""
  1. . ;
  1. . ;Check if DTS server is set to local
  1. . S STS=$$CKDTS(.BSTSWS)
  1. ;
  1. Q STS