BSTSTST ;GDIT/HS/BEE-Standard Terminology Web Service Test ; 19 Nov 2012 9:54 AM
;;2.0;IHS STANDARD TERMINOLOGY;;Dec 01, 2016;Build 62
Q
;
TEST ;EP - BSTS TEST WEB SERVICE Option
;
; Select an existing web service and run sample calls for testing
;
NEW DIC,Y,DIR,QUIT,DEBUG,SR,RES,SERV,IADT,SCNT,RESULT,DLAYGO
NEW DIROUT,DIRUT,DTOUT,DUOUT
;
;First Select the web service
SRV S DIC="^BSTS(9002318.2,",DIC(0)="AEMNZ"
S DLAYGO=9002318.2 D ^DIC S SERV=+Y
I SERV=-1 Q
;
;Check if active
S IADT=$$GET1^DIQ(9002318.2,SERV_",",".1","I")
I IADT]"",IADT<DT W !!,"This Web Service is not Active",! H 2 G SRV
;
;Check for debug mode
S DIR(0)="Y",DIR("B")="N"
S DIR("A",1)=""
S DIR("A")="Display DTS connection log (Y/N): "
D ^DIR
S QUIT=$$CKANS()
;
;Check for "^", "^^", timeout
I QUIT>1 Q
S DEBUG=$S(Y=1:1,1:"")
;
;Perform test searches
S SCNT=0,RES=2 F SR="HEART DISEASE DISORDER","ANTENATAL CARE","EDEMA","DIABETES" D I RES<2 Q
. S SCNT=SCNT+1
. W !!,"Performing search on term: ",SR
. S RES=$$CALL(SERV,SR,DEBUG)
. S RESULT(SCNT)=SR_U_RES
;
;Loop through and display results
W !!,"TEST RESULTS FOR ",$$GET1^DIQ(9002318.2,SERV_",",.01,"I")
S SCNT="" F S SCNT=$O(RESULT(SCNT)) Q:SCNT="" D
. N RES
. S RES=RESULT(SCNT)
. W !!,"Search Term: ",$P(RES,U)
. W !,"Search Result: ",$S(+$P(RES,U,2)=2:"Success",1:"Fail")
. W !,"Error Message: ",$S($P(RES,U,3)]"":$P(RES,U,3),1:"N/A")
. W !,"Call Completion Time: ",$P(RES,U,4)
;
;Check for new test
S DIR(0)="Y",DIR("B")="N"
S DIR("A",1)=""
S DIR("A")="Run another test (Y/N): "
D ^DIR
S QUIT=$$CKANS()
;
;Check for "^", "^^", timeout
I QUIT>1!('Y) Q
K RESULT
G SRV
;
CKANS() ;EP - Check answer "^", "^^", and timeout
;
;User typed "^^"
I $G(DIROUT) Q 3
;
;User typed "^" or timed out
I $G(DUOUT)!$G(DTOUT) Q 2
;
;User hit ENTER
I $G(DIRUT) Q 1
;
Q 0
;
CALL(SERV,SEARCH,DEBUG) ;EP - Perform Test Search
;
N RESULT,BSTSR,BSTSWS,RES
;
S BSTSWS("SEARCH")=SEARCH
S BSTSWS("STYPE")="S"
S BSTSWS("NAMESPACEID")=36
S BSTSWS("SUBSET")="IHS Problem List"
S BSTSWS("SNAPDT")=""
S BSTSWS("MAXRECS")=100
S BSTSWS("BCTCHRC")=""
S BSTSWS("BCTCHCT")=""
S BSTSWS("RET")="PSCBIXAV"
S BSTSWS("DAT")=""
S BSTSWS("SERVICE")=SERV
;
;Make DTS search call
S BSTSR=1
;
;Perform Test Lookup
S BSTSR=$$TEST^BSTSWSV("RESULT",.BSTSWS,DEBUG) S:+BSTSR $P(BSTSR,U)=2
;
Q BSTSR
BSTSTST ;GDIT/HS/BEE-Standard Terminology Web Service Test ; 19 Nov 2012 9:54 AM
+1 ;;2.0;IHS STANDARD TERMINOLOGY;;Dec 01, 2016;Build 62
+2 QUIT
+3 ;
TEST ;EP - BSTS TEST WEB SERVICE Option
+1 ;
+2 ; Select an existing web service and run sample calls for testing
+3 ;
+4 NEW DIC,Y,DIR,QUIT,DEBUG,SR,RES,SERV,IADT,SCNT,RESULT,DLAYGO
+5 NEW DIROUT,DIRUT,DTOUT,DUOUT
+6 ;
+7 ;First Select the web service
SRV SET DIC="^BSTS(9002318.2,"
SET DIC(0)="AEMNZ"
+1 SET DLAYGO=9002318.2
DO ^DIC
SET SERV=+Y
+2 IF SERV=-1
QUIT
+3 ;
+4 ;Check if active
+5 SET IADT=$$GET1^DIQ(9002318.2,SERV_",",".1","I")
+6 IF IADT]""
IF IADT<DT
WRITE !!,"This Web Service is not Active",!
HANG 2
GOTO SRV
+7 ;
+8 ;Check for debug mode
+9 SET DIR(0)="Y"
SET DIR("B")="N"
+10 SET DIR("A",1)=""
+11 SET DIR("A")="Display DTS connection log (Y/N): "
+12 DO ^DIR
+13 SET QUIT=$$CKANS()
+14 ;
+15 ;Check for "^", "^^", timeout
+16 IF QUIT>1
QUIT
+17 SET DEBUG=$SELECT(Y=1:1,1:"")
+18 ;
+19 ;Perform test searches
+20 SET SCNT=0
SET RES=2
FOR SR="HEART DISEASE DISORDER","ANTENATAL CARE","EDEMA","DIABETES"
Begin DoDot:1
+21 SET SCNT=SCNT+1
+22 WRITE !!,"Performing search on term: ",SR
+23 SET RES=$$CALL(SERV,SR,DEBUG)
+24 SET RESULT(SCNT)=SR_U_RES
End DoDot:1
IF RES<2
QUIT
+25 ;
+26 ;Loop through and display results
+27 WRITE !!,"TEST RESULTS FOR ",$$GET1^DIQ(9002318.2,SERV_",",.01,"I")
+28 SET SCNT=""
FOR
SET SCNT=$ORDER(RESULT(SCNT))
IF SCNT=""
QUIT
Begin DoDot:1
+29 NEW RES
+30 SET RES=RESULT(SCNT)
+31 WRITE !!,"Search Term: ",$PIECE(RES,U)
+32 WRITE !,"Search Result: ",$SELECT(+$PIECE(RES,U,2)=2:"Success",1:"Fail")
+33 WRITE !,"Error Message: ",$SELECT($PIECE(RES,U,3)]"":$PIECE(RES,U,3),1:"N/A")
+34 WRITE !,"Call Completion Time: ",$PIECE(RES,U,4)
End DoDot:1
+35 ;
+36 ;Check for new test
+37 SET DIR(0)="Y"
SET DIR("B")="N"
+38 SET DIR("A",1)=""
+39 SET DIR("A")="Run another test (Y/N): "
+40 DO ^DIR
+41 SET QUIT=$$CKANS()
+42 ;
+43 ;Check for "^", "^^", timeout
+44 IF QUIT>1!('Y)
QUIT
+45 KILL RESULT
+46 GOTO SRV
+47 ;
CKANS() ;EP - Check answer "^", "^^", and timeout
+1 ;
+2 ;User typed "^^"
+3 IF $GET(DIROUT)
QUIT 3
+4 ;
+5 ;User typed "^" or timed out
+6 IF $GET(DUOUT)!$GET(DTOUT)
QUIT 2
+7 ;
+8 ;User hit ENTER
+9 IF $GET(DIRUT)
QUIT 1
+10 ;
+11 QUIT 0
+12 ;
CALL(SERV,SEARCH,DEBUG) ;EP - Perform Test Search
+1 ;
+2 NEW RESULT,BSTSR,BSTSWS,RES
+3 ;
+4 SET BSTSWS("SEARCH")=SEARCH
+5 SET BSTSWS("STYPE")="S"
+6 SET BSTSWS("NAMESPACEID")=36
+7 SET BSTSWS("SUBSET")="IHS Problem List"
+8 SET BSTSWS("SNAPDT")=""
+9 SET BSTSWS("MAXRECS")=100
+10 SET BSTSWS("BCTCHRC")=""
+11 SET BSTSWS("BCTCHCT")=""
+12 SET BSTSWS("RET")="PSCBIXAV"
+13 SET BSTSWS("DAT")=""
+14 SET BSTSWS("SERVICE")=SERV
+15 ;
+16 ;Make DTS search call
+17 SET BSTSR=1
+18 ;
+19 ;Perform Test Lookup
+20 SET BSTSR=$$TEST^BSTSWSV("RESULT",.BSTSWS,DEBUG)
IF +BSTSR
SET $PIECE(BSTSR,U)=2
+21 ;
+22 QUIT BSTSR