ONCSAPIS ;Hines OIFO/SG - COLLABORATIVE STAGING (SCHEMAS) ;08/12/10
;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
;
Q
;
;***** RETURNS SCHEMA NUMBER AND NAME
;
; [.ONCSAPI] Reference to the API descriptor (see ^ONCSAPI)
;
; SITE Primary site
; HIST Histology
;
; The ^TMP("ONCSAPIS",$J) global node is used by this function.
;
; Return Values:
; >0 SchemaNumber^SchemaName
; <0 Error code
;
SCHEMA(ONCSAPI,SITE,HIST,DISCRIM) ;
;N DST,NODE,ONCREQ,ONCRSP,ONCXML,RC,SCHEMA,SCHNAME,TMP,URL,XHIST,XSITE
N DISCRIMINATOR,DST,NODE,ONCREQ,ONCRSP,ONCXML,RC,SCHEMA,TMP,URL,XDISC
N XHIST,XSITE
D CLEAR^ONCSAPIE()
;--- Initialize constants and variables
S NODE=$NA(^XTMP("ONCSAPI","SCHEMAS"))
S XSITE=$S(SITE'="":SITE,1:" ")
S XHIST=$S(HIST'="":HIST,1:" ")
S XDISC=$S(DISCRIM'="":DISCRIM,1:" ")
;--- Check if the schema is available in the local cache
;S SCHEMA=+$G(@NODE@("SH",XSITE,XHIST))
;
S SCHEMA=+$G(@NODE@("SH",XSITE,XHIST,XDISC))
;
I SCHEMA>0 D Q:SCHNAME'="" SCHEMA_U_SCHNAME
. S SCHNAME=$P($G(@NODE@(SCHEMA)),U)
S ONCRSP=$NA(^TMP("ONCSAPIS",$J)) K @ONCRSP
;--- Get the server URL
S URL=$$GETCSURL^ONCSAPIU()
;
S RC=0 D
. ;--- Prepare the request data
. S DST="ONCREQ"
. D HEADER^ONCSAPIR(.DST,"CS-GET-SCHEMA")
. S DISCRIMINATOR=DISCRIM
. D PUT^ONCSAPIR(.DST,"SITE",SITE)
. D PUT^ONCSAPIR(.DST,"HIST",HIST)
. D PUT^ONCSAPIR(.DST,"DISCRIMINATOR",DISCRIMINATOR)
. D TRAILER^ONCSAPIR(.DST)
. ;--- Request the schema number
. D:$G(ONCSAPI("DEBUG"))
. . D ZW^ONCSAPIU("ONCREQ","*** 'SCHEMA' REQUEST ***",1)
. S RC=$$REQUEST^ONCSAPIR(URL,ONCRSP,"ONCREQ") Q:RC<0
. D:$G(ONCSAPI("DEBUG"))
. . D ZW^ONCSAPIU(ONCRSP,"*** 'SCHEMA' RESPONSE ***",1)
. K DST,ONCREQ
. ;--- Parse the response
. D SETCBK(.CBK),EN^MXMLPRSE(ONCRSP,.CBK,"W")
. ;--- Check for parsing and web service errors
. S RC=$$CHKERR^ONCSAPIR(.ONCXML) Q:RC<0
. ;--- Check the schema number and name
. S SCHEMA=+$G(ONCXML("SCHEMA"))
. S SCHNAME=$G(ONCXML("SCHEMA-NAME"))
. I (SCHEMA'>0)!(SCHNAME="") S RC=$$ERROR^ONCSAPIE(-14) Q
. ;--- Update the local cache
. S @NODE@(SCHEMA)=SCHNAME
. S @NODE@("SH",XSITE,XHIST,XDISC)=SCHEMA
. S @NODE@("N",SCHNAME)=SCHEMA
;
;--- Cleanup
K @ONCRSP
Q $S(RC<0:RC,1:SCHEMA_U_SCHNAME)
;
;***** SETS THE EVENT INTERFACE ENTRY POINTS
;
; .CBK Reference to the destination list
;
SETCBK(CBK) ;
;;CHARACTERS^TEXT^ONCSAPIS
;
D SETCBK^ONCSAPIX(.CBK,"SETCBK^ONCSAPIS")
Q
;
;***** TEXT CALLBACK FOR THE SAX PARSER
;
; TXT Line of unmarked text
;
TEXT(TXT) ;
N L,L2E
S L=$L(ONCXML("PATH"),","),L2E=$P(ONCXML("PATH"),",",L-1,L)
;--- Schema number and name
I L2E="CS-RESPONSE,SCHEMA" S ONCXML("SCHEMA")=TXT Q
I L2E="CS-RESPONSE,SCHEMA-NAME" S ONCXML("SCHEMA-NAME")=TXT Q
;--- Default processing
D TEXT^ONCSAPIX(TXT)
Q
;
CLEANUP ;Cleanup
K SCHNAME
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCSAPIS 3003 printed Dec 13, 2024@02:27:48 Page 2
ONCSAPIS ;Hines OIFO/SG - COLLABORATIVE STAGING (SCHEMAS) ;08/12/10
+1 ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
+2 ;
+3 QUIT
+4 ;
+5 ;***** RETURNS SCHEMA NUMBER AND NAME
+6 ;
+7 ; [.ONCSAPI] Reference to the API descriptor (see ^ONCSAPI)
+8 ;
+9 ; SITE Primary site
+10 ; HIST Histology
+11 ;
+12 ; The ^TMP("ONCSAPIS",$J) global node is used by this function.
+13 ;
+14 ; Return Values:
+15 ; >0 SchemaNumber^SchemaName
+16 ; <0 Error code
+17 ;
SCHEMA(ONCSAPI,SITE,HIST,DISCRIM) ;
+1 ;N DST,NODE,ONCREQ,ONCRSP,ONCXML,RC,SCHEMA,SCHNAME,TMP,URL,XHIST,XSITE
+2 NEW DISCRIMINATOR,DST,NODE,ONCREQ,ONCRSP,ONCXML,RC,SCHEMA,TMP,URL,XDISC
+3 NEW XHIST,XSITE
+4 DO CLEAR^ONCSAPIE()
+5 ;--- Initialize constants and variables
+6 SET NODE=$NAME(^XTMP("ONCSAPI","SCHEMAS"))
+7 SET XSITE=$SELECT(SITE'="":SITE,1:" ")
+8 SET XHIST=$SELECT(HIST'="":HIST,1:" ")
+9 SET XDISC=$SELECT(DISCRIM'="":DISCRIM,1:" ")
+10 ;--- Check if the schema is available in the local cache
+11 ;S SCHEMA=+$G(@NODE@("SH",XSITE,XHIST))
+12 ;
+13 SET SCHEMA=+$GET(@NODE@("SH",XSITE,XHIST,XDISC))
+14 ;
+15 IF SCHEMA>0
Begin DoDot:1
+16 SET SCHNAME=$PIECE($GET(@NODE@(SCHEMA)),U)
End DoDot:1
if SCHNAME'=""
QUIT SCHEMA_U_SCHNAME
+17 SET ONCRSP=$NAME(^TMP("ONCSAPIS",$JOB))
KILL @ONCRSP
+18 ;--- Get the server URL
+19 SET URL=$$GETCSURL^ONCSAPIU()
+20 ;
+21 SET RC=0
Begin DoDot:1
+22 ;--- Prepare the request data
+23 SET DST="ONCREQ"
+24 DO HEADER^ONCSAPIR(.DST,"CS-GET-SCHEMA")
+25 SET DISCRIMINATOR=DISCRIM
+26 DO PUT^ONCSAPIR(.DST,"SITE",SITE)
+27 DO PUT^ONCSAPIR(.DST,"HIST",HIST)
+28 DO PUT^ONCSAPIR(.DST,"DISCRIMINATOR",DISCRIMINATOR)
+29 DO TRAILER^ONCSAPIR(.DST)
+30 ;--- Request the schema number
+31 if $GET(ONCSAPI("DEBUG"))
Begin DoDot:2
+32 DO ZW^ONCSAPIU("ONCREQ","*** 'SCHEMA' REQUEST ***",1)
End DoDot:2
+33 SET RC=$$REQUEST^ONCSAPIR(URL,ONCRSP,"ONCREQ")
if RC<0
QUIT
+34 if $GET(ONCSAPI("DEBUG"))
Begin DoDot:2
+35 DO ZW^ONCSAPIU(ONCRSP,"*** 'SCHEMA' RESPONSE ***",1)
End DoDot:2
+36 KILL DST,ONCREQ
+37 ;--- Parse the response
+38 DO SETCBK(.CBK)
DO EN^MXMLPRSE(ONCRSP,.CBK,"W")
+39 ;--- Check for parsing and web service errors
+40 SET RC=$$CHKERR^ONCSAPIR(.ONCXML)
if RC<0
QUIT
+41 ;--- Check the schema number and name
+42 SET SCHEMA=+$GET(ONCXML("SCHEMA"))
+43 SET SCHNAME=$GET(ONCXML("SCHEMA-NAME"))
+44 IF (SCHEMA'>0)!(SCHNAME="")
SET RC=$$ERROR^ONCSAPIE(-14)
QUIT
+45 ;--- Update the local cache
+46 SET @NODE@(SCHEMA)=SCHNAME
+47 SET @NODE@("SH",XSITE,XHIST,XDISC)=SCHEMA
+48 SET @NODE@("N",SCHNAME)=SCHEMA
End DoDot:1
+49 ;
+50 ;--- Cleanup
+51 KILL @ONCRSP
+52 QUIT $SELECT(RC<0:RC,1:SCHEMA_U_SCHNAME)
+53 ;
+54 ;***** SETS THE EVENT INTERFACE ENTRY POINTS
+55 ;
+56 ; .CBK Reference to the destination list
+57 ;
SETCBK(CBK) ;
+1 ;;CHARACTERS^TEXT^ONCSAPIS
+2 ;
+3 DO SETCBK^ONCSAPIX(.CBK,"SETCBK^ONCSAPIS")
+4 QUIT
+5 ;
+6 ;***** TEXT CALLBACK FOR THE SAX PARSER
+7 ;
+8 ; TXT Line of unmarked text
+9 ;
TEXT(TXT) ;
+1 NEW L,L2E
+2 SET L=$LENGTH(ONCXML("PATH"),",")
SET L2E=$PIECE(ONCXML("PATH"),",",L-1,L)
+3 ;--- Schema number and name
+4 IF L2E="CS-RESPONSE,SCHEMA"
SET ONCXML("SCHEMA")=TXT
QUIT
+5 IF L2E="CS-RESPONSE,SCHEMA-NAME"
SET ONCXML("SCHEMA-NAME")=TXT
QUIT
+6 ;--- Default processing
+7 DO TEXT^ONCSAPIX(TXT)
+8 QUIT
+9 ;
CLEANUP ;Cleanup
+1 KILL SCHNAME