RORTSK13 ;HIOFO/SG,VAC - PARSER FOR REPORT PARAMETERS ;4/7/09 2:05pm
;;1.5;CLINICAL CASE REGISTRIES;**1,8,19**;Feb 17, 2006;Build 43
;
; Modified March 2009 to support ICD9FILT parameter passed in
;
; This routine uses the following IAs:
;
; #1995 $$CODEN^ICPTCOD (supported)
; #3990 $$CODEN^ICDCODE (supported)
; #5747 $$CODEABA^ICDEX (controlled)
; #4149 EN^MXMLPRSE (supported)
;
; RORXML -------------- DESCRIPTOR FOR THE XML PARSING
;
; RORXML(
;
; "ERR") Number of parsing errors
;
; "PATH") Path to the current XML tag
;
; "RXGRP") Name of the current drug group
;
; "TI") Number of the current text line of
; the current tag value
;
;******************************************************************************
;******************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*19 FEB 2012 K GUPTA Support for ICD-10 Coding System
;******************************************************************************
;******************************************************************************
;
Q
;
;***** START DOCUMENT CALLBACK FOR THE SAX PARSER
DOCSTART ;
S RORXML("PATH")="",RORXML("ERR")=0
K RORXML("RXGRP")
Q
;
;***** DUMMY CALLBACKS FOR THE SAX PARSER
DUMMY(DUMMY1,DUMMY2,DUMMY3) ;
DUMMY1 Q
;
;***** END ELEMENT CALLBACK FOR THE SAX PARSER
;
; ELMT Name of the element
;
ELEND(ELMT) ;
;--- Reset the drug group name in the end of the group
K:RORXML("PATH")="PARAMS,DRUGS,GROUP" RORXML("RXGRP")
;--- Reset the ICD group name in the end of the group
K:RORXML("PATH")="PARAMS,ICDLST,GROUP" RORXML("ICDGRP")
K:RORXML("PATH")="PARAMS,ICDFILT,GROUP" RORXML("ICDGRP")
;--- Update the current element path
S RORXML("PATH")=$P(RORXML("PATH"),",",1,$L(RORXML("PATH"),",")-1)
Q
;
;***** START DOCUMENT CALLBACK FOR THE SAX PARSER
;
; ELMT Name of the element
; .ATTR List of attributes and their values
;
ELSTART(ELMT,ATTR) ;
N GROUP,ID,IEN,ITEM,LIST,LVL,RC,SECTION,TMP,RORICDTYPE,RORCODSYS,RORPROCMODE,RORROOTFILE
;--- Update the current element path
S RORXML("PATH")=RORXML("PATH")_$S(RORXML("PATH")'="":",",1:"")_ELMT
S RORXML("TI")=1
;--- Ignore everything except parameters
Q:$P(RORXML("PATH"),",")'="PARAMS"
S LVL=$L(RORXML("PATH"),",")
;
;=== Store 3-level lists
I LVL=5 D Q
. S LIST=$P(RORXML("PATH"),",",LVL-3,LVL-1)
. ;--- Medications and drug classes
. I $P(LIST,",",1,2)="DRUGS,GROUP" D Q
. . S GROUP=$G(RORXML("RXGRP")) Q:GROUP=""
. . S SECTION=$P(LIST,",",3) Q:SECTION=""
. . S ID=$G(ATTR("ID")) Q:ID=""
. . S RORTSK("PARAMS","DRUGS","G",GROUP,SECTION,ID)=$G(ATTR("CODE"))
;
;=== Store 2-level lists
I LVL=4 D Q
. S LIST=$P(RORXML("PATH"),",",LVL-2,LVL-1)
. ;--- ICD diagnosis or procedure codes
. I LIST="ICDLST,GROUP" D Q
. . S GROUP=$G(RORXML("ICDGRP")) Q:GROUP=""
. . S ID=$G(ATTR("ID")) Q:ID=""
. . S RORICDTYPE=$G(ATTR("VERSION"))
. . S RORPROCMODE=$G(RORTSK("PARAMS","ICDLST","A","PROCMODE"))
. . S RORCODSYS=$S(RORICDTYPE="ICD-10":$S(RORPROCMODE:"31",1:"30"),RORICDTYPE="ICD-9":$S(RORPROCMODE:"2",1:"1"),1:"")
. . Q:RORCODSYS=""
. . S RORROOTFILE=$S(RORPROCMODE:"80.1",1:"80")
. . S IEN=$$CODEABA^ICDEX(ID,RORROOTFILE,RORCODSYS)
. . S:IEN>0 RORTSK("PARAMS","ICDLST","G",GROUP,"C",IEN)=ID_U_RORCODSYS
.;--- ICD codes
. I LIST="ICDFILT,GROUP" D Q
. . S GROUP=$G(RORXML("ICDGRP")) Q:GROUP=""
. . S ID=$G(ATTR("ID")) Q:ID=""
. . S RORICDTYPE=$G(ATTR("VERSION"))
. . S RORCODSYS=$S(RORICDTYPE="ICD-10":"30",RORICDTYPE="ICD-9":"1",1:"")
. . Q:RORCODSYS=""
. . S IEN=$$CODEABA^ICDEX(ID,"80",RORCODSYS)
. . S:IEN>0 RORTSK("PARAMS","ICDFILT","G",GROUP,"C",IEN)=ID_U_RORCODSYS
;
;=== Store the lists
I LVL=3 D Q
. S LIST=$P(RORXML("PATH"),",",LVL-1)
. ;--- List of CPT codes
. I LIST="CPTLST" D:ELMT="CPT" Q
. . S ID=$G(ATTR("ID")) Q:ID=""
. . S IEN=+$$CODEN^ICPTCOD(ID)
. . S:IEN>0 RORTSK("PARAMS",LIST,"C",IEN)=ID
. ;--- Name of the current drug group and its attributes
. I LIST="DRUGS" D:ELMT="GROUP" Q
. . S (RORXML("RXGRP"),ID)=$G(ATTR("ID")) Q:ID=""
. . M RORTSK("PARAMS","DRUGS","G",ID,"A")=ATTR
. . K RORTSK("PARAMS","DRUGS","G",ID,"A","ID")
. ;--- Name of the current ICD group
. I (LIST="ICDLST")!(LIST="ICDFILT") D:ELMT="GROUP" Q
. . S RORXML("ICDGRP")=$G(ATTR("ID"))
. ;--- List of ICD-9 codes
. ;I LIST="ICD9LST" D:ELMT="ICD9" Q
. ;. S ID=$G(ATTR("ID")) Q:ID=""
. ;. S TMP=$S($G(RORTSK("PARAMS","ICD9LST","A","PROC")):80.1,1:80)
. ;. S IEN=+$$CODEN^ICDCODE(ID,TMP)
. ;. S:IEN>0 RORTSK("PARAMS",LIST,"C",IEN)=ID
. ;--- Lab tests
. I LIST="LABTESTS" D:ELMT="LT" Q
. . S ID=$G(ATTR("ID")) Q:ID=""
. . S RORTSK("PARAMS","LABTESTS","C",ID)=""
. . S TMP=$G(ATTR("LOW"))
. . S:TMP'="" RORTSK("PARAMS","LABTESTS","C",ID,"L")=TMP
. . S TMP=$G(ATTR("HIGH"))
. . S:TMP'="" RORTSK("PARAMS","LABTESTS","C",ID,"H")=TMP
. ;--- Laboratory test ranges
. I LIST="LRGRANGES" D:ELMT="LRGRANGE" Q
. . S ID=$G(ATTR("ID")) Q:'$G(ATTR("USE"))!(ID="")
. . S RORTSK("PARAMS",LIST,"C",ID)=""
. . S TMP=$G(ATTR("LOW"))
. . S:TMP'="" RORTSK("PARAMS",LIST,"C",ID,"L")=TMP
. . S TMP=$G(ATTR("HIGH"))
. . S:TMP'="" RORTSK("PARAMS",LIST,"C",ID,"H")=TMP
. ;--- "Include/Exclude" list processing
. I (LIST="LOCAL_FIELDS")!(LIST="OTHER_REGISTRIES") D Q
. . S ID=$G(ATTR("ID")) Q:ID=""
. . S TMP=+$G(ATTR("MODE")) ; 1 - Include; -1 - Exclude
. . S:TMP RORTSK("PARAMS",LIST,"C",ID)=TMP
. ;--- Default processing
. S TMP=","_LIST_","
. Q:'(",CLINICS,DIVISIONS,OPTIONAL_COLUMNS,PATIENTS,SELRULES,UTIL_TYPES,"[TMP)
. S ID=$G(ATTR("ID"))
. S:ID'="" RORTSK("PARAMS",LIST,"C",ID)=""
;
;=== Store the top-level attributes
I LVL=2 D Q
. ;--- Date range(s)
. I ELMT?1"DATE_RANGE".1(1"_"1.N) D Q
. . N STDT,ENDT
. . S RC=$$DTRANGE^RORTSK14(.ATTR,.STDT,.ENDT) Q:RC<0
. . S RORTSK("PARAMS",ELMT,"A","START")=STDT
. . S RORTSK("PARAMS",ELMT,"A","END")=ENDT
. ;--- Ignore internal nodes
. Q:ELMT="PANELS"
. ;--- Default processing
. M RORTSK("PARAMS",ELMT,"A")=ATTR
;
;--- Ignore everything else
Q
;
;***** TEXT CALLBACK FOR THE SAX PARSER
;
; TXT Line of unmarked text
;
ELTEXT(TXT) ;
N ITEM,LIST,LVL
S LVL=$L(RORXML("PATH"),",")
;--- Store top-level values
I LVL=2 D Q
. S ITEM=$P(RORXML("PATH"),",",LVL)
. S RORTSK("PARAMS",ITEM)=$G(RORTSK("PARAMS",ITEM))_TXT
;--- Ignore everything else
Q
;
;***** ERROR CALLBACK FOR THE SAX PARSER
;
; .ERR Reference to a local variable containing
; informations about the error
;
ERROR(ERR) ;
N ERRCODE,RORINFO,TMP
I ERR("SEV") D
. S ERRCODE=-105,RORXML("ERR")=$G(RORXML("ERR"))+1
E S ERRCODE=-104
;--- Prepare message details
S RORINFO(1)=$TR(ERR("MSG"),U,"~")
S TMP=$P("Warning^Validation Error^Conformance Error",U,ERR("SEV")+1)
S RORINFO(2)=TMP_" in line #"_ERR("LIN")_" (pos#"_ERR("POS")_")"
S RORINFO(3)=$TR(ERR("XML"),$C(9,10,13)," ")
;--- Record the error message
D ERROR^RORERR(ERRCODE,,.RORINFO)
Q
;
;***** PARSES AND PREPARES THE REPORT PARAMETERS
;
; .PARAMS Reference to a local variable that contains report
; parameters in XML format. This variable is KILL'ed
; by this function.
;
; .RORTSK Reference to a local variable that contains a task
; descriptor.
;
; Return Values:
; <0 Error code
; 0 Ok
;
PARSEPRM(PARAMS,RORTSK) ;
K RORTSK("PARAMS")
Q:$D(PARAMS)<10 0
;---
N CBK,RORSRC,RORSUBS,RORTMP,RORXML
S RORSRC=$$ALLOC^RORTMP() ; Source buffer for XML
S RORTMP=$$ALLOC^RORTMP(.RORSUBS) ; Temporary buffer
;--- Copy the XML document into a global since the parser
;--- cannot read it from a local variable
M @RORSRC=PARAMS K PARAMS
;--- Parse the parameters
S CBK("CHARACTERS")="ELTEXT^RORTSK13"
S CBK("COMMENT")="DUMMY^RORTSK13"
S CBK("DOCTYPE")="DUMMY^RORTSK13"
S CBK("ENDDOCUMENT")="DUMMY1^RORTSK13"
S CBK("ENDELEMENT")="ELEND^RORTSK13"
S CBK("ERROR")="ERROR^RORTSK13"
S CBK("EXTERNAL")="DUMMY^RORTSK13"
S CBK("NOTATION")="DUMMY^RORTSK13"
S CBK("PI")="DUMMY^RORTSK13"
S CBK("STARTDOCUMENT")="DOCSTART^RORTSK13"
S CBK("STARTELEMENT")="ELSTART^RORTSK13"
D EN^MXMLPRSE(RORSRC,.CBK,"W")
;--- Cleanup
D FREE^RORTMP(RORTMP),FREE^RORTMP(RORSRC)
Q $S($G(RORXML("ERR"))>0:$$ERROR^RORERR(-106),1:0)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORTSK13 8868 printed Oct 16, 2024@17:44:26 Page 2
RORTSK13 ;HIOFO/SG,VAC - PARSER FOR REPORT PARAMETERS ;4/7/09 2:05pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**1,8,19**;Feb 17, 2006;Build 43
+2 ;
+3 ; Modified March 2009 to support ICD9FILT parameter passed in
+4 ;
+5 ; This routine uses the following IAs:
+6 ;
+7 ; #1995 $$CODEN^ICPTCOD (supported)
+8 ; #3990 $$CODEN^ICDCODE (supported)
+9 ; #5747 $$CODEABA^ICDEX (controlled)
+10 ; #4149 EN^MXMLPRSE (supported)
+11 ;
+12 ; RORXML -------------- DESCRIPTOR FOR THE XML PARSING
+13 ;
+14 ; RORXML(
+15 ;
+16 ; "ERR") Number of parsing errors
+17 ;
+18 ; "PATH") Path to the current XML tag
+19 ;
+20 ; "RXGRP") Name of the current drug group
+21 ;
+22 ; "TI") Number of the current text line of
+23 ; the current tag value
+24 ;
+25 ;******************************************************************************
+26 ;******************************************************************************
+27 ; --- ROUTINE MODIFICATION LOG ---
+28 ;
+29 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+30 ;----------- ---------- ----------- ----------------------------------------
+31 ;ROR*1.5*19 FEB 2012 K GUPTA Support for ICD-10 Coding System
+32 ;******************************************************************************
+33 ;******************************************************************************
+34 ;
+35 QUIT
+36 ;
+37 ;***** START DOCUMENT CALLBACK FOR THE SAX PARSER
DOCSTART ;
+1 SET RORXML("PATH")=""
SET RORXML("ERR")=0
+2 KILL RORXML("RXGRP")
+3 QUIT
+4 ;
+5 ;***** DUMMY CALLBACKS FOR THE SAX PARSER
DUMMY(DUMMY1,DUMMY2,DUMMY3) ;
DUMMY1 QUIT
+1 ;
+2 ;***** END ELEMENT CALLBACK FOR THE SAX PARSER
+3 ;
+4 ; ELMT Name of the element
+5 ;
ELEND(ELMT) ;
+1 ;--- Reset the drug group name in the end of the group
+2 if RORXML("PATH")="PARAMS,DRUGS,GROUP"
KILL RORXML("RXGRP")
+3 ;--- Reset the ICD group name in the end of the group
+4 if RORXML("PATH")="PARAMS,ICDLST,GROUP"
KILL RORXML("ICDGRP")
+5 if RORXML("PATH")="PARAMS,ICDFILT,GROUP"
KILL RORXML("ICDGRP")
+6 ;--- Update the current element path
+7 SET RORXML("PATH")=$PIECE(RORXML("PATH"),",",1,$LENGTH(RORXML("PATH"),",")-1)
+8 QUIT
+9 ;
+10 ;***** START DOCUMENT CALLBACK FOR THE SAX PARSER
+11 ;
+12 ; ELMT Name of the element
+13 ; .ATTR List of attributes and their values
+14 ;
ELSTART(ELMT,ATTR) ;
+1 NEW GROUP,ID,IEN,ITEM,LIST,LVL,RC,SECTION,TMP,RORICDTYPE,RORCODSYS,RORPROCMODE,RORROOTFILE
+2 ;--- Update the current element path
+3 SET RORXML("PATH")=RORXML("PATH")_$SELECT(RORXML("PATH")'="":",",1:"")_ELMT
+4 SET RORXML("TI")=1
+5 ;--- Ignore everything except parameters
+6 if $PIECE(RORXML("PATH"),",")'="PARAMS"
QUIT
+7 SET LVL=$LENGTH(RORXML("PATH"),",")
+8 ;
+9 ;=== Store 3-level lists
+10 IF LVL=5
Begin DoDot:1
+11 SET LIST=$PIECE(RORXML("PATH"),",",LVL-3,LVL-1)
+12 ;--- Medications and drug classes
+13 IF $PIECE(LIST,",",1,2)="DRUGS,GROUP"
Begin DoDot:2
+14 SET GROUP=$GET(RORXML("RXGRP"))
if GROUP=""
QUIT
+15 SET SECTION=$PIECE(LIST,",",3)
if SECTION=""
QUIT
+16 SET ID=$GET(ATTR("ID"))
if ID=""
QUIT
+17 SET RORTSK("PARAMS","DRUGS","G",GROUP,SECTION,ID)=$GET(ATTR("CODE"))
End DoDot:2
QUIT
End DoDot:1
QUIT
+18 ;
+19 ;=== Store 2-level lists
+20 IF LVL=4
Begin DoDot:1
+21 SET LIST=$PIECE(RORXML("PATH"),",",LVL-2,LVL-1)
+22 ;--- ICD diagnosis or procedure codes
+23 IF LIST="ICDLST,GROUP"
Begin DoDot:2
+24 SET GROUP=$GET(RORXML("ICDGRP"))
if GROUP=""
QUIT
+25 SET ID=$GET(ATTR("ID"))
if ID=""
QUIT
+26 SET RORICDTYPE=$GET(ATTR("VERSION"))
+27 SET RORPROCMODE=$GET(RORTSK("PARAMS","ICDLST","A","PROCMODE"))
+28 SET RORCODSYS=$SELECT(RORICDTYPE="ICD-10":$SELECT(RORPROCMODE:"31",1:"30"),RORICDTYPE="ICD-9":$SELECT(RORPROCMODE:"2",1:"1"),1:"")
+29 if RORCODSYS=""
QUIT
+30 SET RORROOTFILE=$SELECT(RORPROCMODE:"80.1",1:"80")
+31 SET IEN=$$CODEABA^ICDEX(ID,RORROOTFILE,RORCODSYS)
+32 if IEN>0
SET RORTSK("PARAMS","ICDLST","G",GROUP,"C",IEN)=ID_U_RORCODSYS
End DoDot:2
QUIT
+33 ;--- ICD codes
+34 IF LIST="ICDFILT,GROUP"
Begin DoDot:2
+35 SET GROUP=$GET(RORXML("ICDGRP"))
if GROUP=""
QUIT
+36 SET ID=$GET(ATTR("ID"))
if ID=""
QUIT
+37 SET RORICDTYPE=$GET(ATTR("VERSION"))
+38 SET RORCODSYS=$SELECT(RORICDTYPE="ICD-10":"30",RORICDTYPE="ICD-9":"1",1:"")
+39 if RORCODSYS=""
QUIT
+40 SET IEN=$$CODEABA^ICDEX(ID,"80",RORCODSYS)
+41 if IEN>0
SET RORTSK("PARAMS","ICDFILT","G",GROUP,"C",IEN)=ID_U_RORCODSYS
End DoDot:2
QUIT
End DoDot:1
QUIT
+42 ;
+43 ;=== Store the lists
+44 IF LVL=3
Begin DoDot:1
+45 SET LIST=$PIECE(RORXML("PATH"),",",LVL-1)
+46 ;--- List of CPT codes
+47 IF LIST="CPTLST"
if ELMT="CPT"
Begin DoDot:2
+48 SET ID=$GET(ATTR("ID"))
if ID=""
QUIT
+49 SET IEN=+$$CODEN^ICPTCOD(ID)
+50 if IEN>0
SET RORTSK("PARAMS",LIST,"C",IEN)=ID
End DoDot:2
QUIT
+51 ;--- Name of the current drug group and its attributes
+52 IF LIST="DRUGS"
if ELMT="GROUP"
Begin DoDot:2
+53 SET (RORXML("RXGRP"),ID)=$GET(ATTR("ID"))
if ID=""
QUIT
+54 MERGE RORTSK("PARAMS","DRUGS","G",ID,"A")=ATTR
+55 KILL RORTSK("PARAMS","DRUGS","G",ID,"A","ID")
End DoDot:2
QUIT
+56 ;--- Name of the current ICD group
+57 IF (LIST="ICDLST")!(LIST="ICDFILT")
if ELMT="GROUP"
Begin DoDot:2
+58 SET RORXML("ICDGRP")=$GET(ATTR("ID"))
End DoDot:2
QUIT
+59 ;--- List of ICD-9 codes
+60 ;I LIST="ICD9LST" D:ELMT="ICD9" Q
+61 ;. S ID=$G(ATTR("ID")) Q:ID=""
+62 ;. S TMP=$S($G(RORTSK("PARAMS","ICD9LST","A","PROC")):80.1,1:80)
+63 ;. S IEN=+$$CODEN^ICDCODE(ID,TMP)
+64 ;. S:IEN>0 RORTSK("PARAMS",LIST,"C",IEN)=ID
+65 ;--- Lab tests
+66 IF LIST="LABTESTS"
if ELMT="LT"
Begin DoDot:2
+67 SET ID=$GET(ATTR("ID"))
if ID=""
QUIT
+68 SET RORTSK("PARAMS","LABTESTS","C",ID)=""
+69 SET TMP=$GET(ATTR("LOW"))
+70 if TMP'=""
SET RORTSK("PARAMS","LABTESTS","C",ID,"L")=TMP
+71 SET TMP=$GET(ATTR("HIGH"))
+72 if TMP'=""
SET RORTSK("PARAMS","LABTESTS","C",ID,"H")=TMP
End DoDot:2
QUIT
+73 ;--- Laboratory test ranges
+74 IF LIST="LRGRANGES"
if ELMT="LRGRANGE"
Begin DoDot:2
+75 SET ID=$GET(ATTR("ID"))
if '$GET(ATTR("USE"))!(ID="")
QUIT
+76 SET RORTSK("PARAMS",LIST,"C",ID)=""
+77 SET TMP=$GET(ATTR("LOW"))
+78 if TMP'=""
SET RORTSK("PARAMS",LIST,"C",ID,"L")=TMP
+79 SET TMP=$GET(ATTR("HIGH"))
+80 if TMP'=""
SET RORTSK("PARAMS",LIST,"C",ID,"H")=TMP
End DoDot:2
QUIT
+81 ;--- "Include/Exclude" list processing
+82 IF (LIST="LOCAL_FIELDS")!(LIST="OTHER_REGISTRIES")
Begin DoDot:2
+83 SET ID=$GET(ATTR("ID"))
if ID=""
QUIT
+84 ; 1 - Include; -1 - Exclude
SET TMP=+$GET(ATTR("MODE"))
+85 if TMP
SET RORTSK("PARAMS",LIST,"C",ID)=TMP
End DoDot:2
QUIT
+86 ;--- Default processing
+87 SET TMP=","_LIST_","
+88 if '(",CLINICS,DIVISIONS,OPTIONAL_COLUMNS,PATIENTS,SELRULES,UTIL_TYPES,"[TMP)
QUIT
+89 SET ID=$GET(ATTR("ID"))
+90 if ID'=""
SET RORTSK("PARAMS",LIST,"C",ID)=""
End DoDot:1
QUIT
+91 ;
+92 ;=== Store the top-level attributes
+93 IF LVL=2
Begin DoDot:1
+94 ;--- Date range(s)
+95 IF ELMT?1"DATE_RANGE".1(1"_"1.N)
Begin DoDot:2
+96 NEW STDT,ENDT
+97 SET RC=$$DTRANGE^RORTSK14(.ATTR,.STDT,.ENDT)
if RC<0
QUIT
+98 SET RORTSK("PARAMS",ELMT,"A","START")=STDT
+99 SET RORTSK("PARAMS",ELMT,"A","END")=ENDT
End DoDot:2
QUIT
+100 ;--- Ignore internal nodes
+101 if ELMT="PANELS"
QUIT
+102 ;--- Default processing
+103 MERGE RORTSK("PARAMS",ELMT,"A")=ATTR
End DoDot:1
QUIT
+104 ;
+105 ;--- Ignore everything else
+106 QUIT
+107 ;
+108 ;***** TEXT CALLBACK FOR THE SAX PARSER
+109 ;
+110 ; TXT Line of unmarked text
+111 ;
ELTEXT(TXT) ;
+1 NEW ITEM,LIST,LVL
+2 SET LVL=$LENGTH(RORXML("PATH"),",")
+3 ;--- Store top-level values
+4 IF LVL=2
Begin DoDot:1
+5 SET ITEM=$PIECE(RORXML("PATH"),",",LVL)
+6 SET RORTSK("PARAMS",ITEM)=$GET(RORTSK("PARAMS",ITEM))_TXT
End DoDot:1
QUIT
+7 ;--- Ignore everything else
+8 QUIT
+9 ;
+10 ;***** ERROR CALLBACK FOR THE SAX PARSER
+11 ;
+12 ; .ERR Reference to a local variable containing
+13 ; informations about the error
+14 ;
ERROR(ERR) ;
+1 NEW ERRCODE,RORINFO,TMP
+2 IF ERR("SEV")
Begin DoDot:1
+3 SET ERRCODE=-105
SET RORXML("ERR")=$GET(RORXML("ERR"))+1
End DoDot:1
+4 IF '$TEST
SET ERRCODE=-104
+5 ;--- Prepare message details
+6 SET RORINFO(1)=$TRANSLATE(ERR("MSG"),U,"~")
+7 SET TMP=$PIECE("Warning^Validation Error^Conformance Error",U,ERR("SEV")+1)
+8 SET RORINFO(2)=TMP_" in line #"_ERR("LIN")_" (pos#"_ERR("POS")_")"
+9 SET RORINFO(3)=$TRANSLATE(ERR("XML"),$CHAR(9,10,13)," ")
+10 ;--- Record the error message
+11 DO ERROR^RORERR(ERRCODE,,.RORINFO)
+12 QUIT
+13 ;
+14 ;***** PARSES AND PREPARES THE REPORT PARAMETERS
+15 ;
+16 ; .PARAMS Reference to a local variable that contains report
+17 ; parameters in XML format. This variable is KILL'ed
+18 ; by this function.
+19 ;
+20 ; .RORTSK Reference to a local variable that contains a task
+21 ; descriptor.
+22 ;
+23 ; Return Values:
+24 ; <0 Error code
+25 ; 0 Ok
+26 ;
PARSEPRM(PARAMS,RORTSK) ;
+1 KILL RORTSK("PARAMS")
+2 if $DATA(PARAMS)<10
QUIT 0
+3 ;---
+4 NEW CBK,RORSRC,RORSUBS,RORTMP,RORXML
+5 ; Source buffer for XML
SET RORSRC=$$ALLOC^RORTMP()
+6 ; Temporary buffer
SET RORTMP=$$ALLOC^RORTMP(.RORSUBS)
+7 ;--- Copy the XML document into a global since the parser
+8 ;--- cannot read it from a local variable
+9 MERGE @RORSRC=PARAMS
KILL PARAMS
+10 ;--- Parse the parameters
+11 SET CBK("CHARACTERS")="ELTEXT^RORTSK13"
+12 SET CBK("COMMENT")="DUMMY^RORTSK13"
+13 SET CBK("DOCTYPE")="DUMMY^RORTSK13"
+14 SET CBK("ENDDOCUMENT")="DUMMY1^RORTSK13"
+15 SET CBK("ENDELEMENT")="ELEND^RORTSK13"
+16 SET CBK("ERROR")="ERROR^RORTSK13"
+17 SET CBK("EXTERNAL")="DUMMY^RORTSK13"
+18 SET CBK("NOTATION")="DUMMY^RORTSK13"
+19 SET CBK("PI")="DUMMY^RORTSK13"
+20 SET CBK("STARTDOCUMENT")="DOCSTART^RORTSK13"
+21 SET CBK("STARTELEMENT")="ELSTART^RORTSK13"
+22 DO EN^MXMLPRSE(RORSRC,.CBK,"W")
+23 ;--- Cleanup
+24 DO FREE^RORTMP(RORTMP)
DO FREE^RORTMP(RORSRC)
+25 QUIT $SELECT($GET(RORXML("ERR"))>0:$$ERROR^RORERR(-106),1:0)