RORTSK11 ;HCIOFO/SG - REPORT CREATION UTILITIES ; 11/14/06 1:16pm
;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
;
Q
;
;***** ADDS THE ATTRIBUTE TO THE ELEMENT
;
; TASK Task number
;
; ELMTIEN IEN of the element
;
; NAME Attribute name
;
; VALUE Value of the attribute
;
; Return Values:
; <0 Error code
; 0 Invalid attribute name
; >0 Attribute IEN
;
ADDATTR(TASK,ELMTIEN,NAME,VALUE) ;
I $G(ELMTIEN)<0 Q:$QUIT 0 Q
N IENS,RC,RORFDA,RORIEN,RORMSG
I $D(^RORDATA(798.8,+TASK,"RI",+ELMTIEN))<10 Q:$QUIT 0 Q
S IENS="?+1,"_(+ELMTIEN)_","_(+TASK)_","
S (RORIEN(1),RORFDA(798.872,IENS,.01))=$$XEC(NAME)
I RORIEN(1)'>0 Q:$QUIT 0 Q
S RORFDA(798.872,IENS,1)=VALUE
D UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
I $G(DIERR) D Q:$QUIT RC Q
. S RC=$$DBS^RORERR("RORMSG",-9,,,798.872,IENS)
Q:$QUIT +$G(RORIEN(1)) Q
;
;***** ADDS THE TEXT ELEMENT TO THE REPORT
;
; TASK Task number
;
; NAME Element name
;
; [.]ROR8TXT Either a closed root or a reference to an array
; that contains the text in word processing format.
;
; [PARENT] IEN of the parent element
;
; The text should be properly encoded beforehand (use the
; $$XMLENC^RORUTL03 function).
;
; Return Values:
; <0 Error code
; 0 Invalid element name
; >0 IEN of the report element
;
ADDTEXT(TASK,NAME,ROR8TXT,PARENT) ;
I $G(PARENT)<0 Q:$QUIT 0 Q
N IENS,RC,RORFDA,RORIEN,RORMSG,TMP
S IENS="+1,"_(+TASK)_","
S (RORFDA(798.87,IENS,.01),TMP)=$$XEC(NAME)
I TMP'>0 Q:$QUIT 0 Q
S RORFDA(798.87,IENS,.02)=+$G(PARENT)
S RORFDA(798.87,IENS,3)=$S($D(ROR8TXT)>1:"ROR8TXT",1:ROR8TXT)
D UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
I $G(DIERR) D Q:$QUIT RC Q
. S RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
Q:$QUIT +$G(RORIEN(1)) Q
;
;***** ADDS THE SINGLE-LINE ELEMENT TO THE REPORT
;
; TASK Task number
;
; NAME Element name
;
; [VALUE] Value of the element
;
; [PARENT] IEN of the parent element
;
; [SORTBY] Parent element is sorted by the value of the element
; that is being added:
; 1 Sort "as is"
; 2 Sort as strings
; 3 Sort as numbers
;
; Return Values:
; <0 Error code
; 0 Invalid element name
; >0 IEN of the report element
;
ADDVAL(TASK,NAME,VALUE,PARENT,SORTBY,ID) ;
I $G(PARENT)<0 Q:$QUIT 0 Q
N IENS,RC,RORFDA,RORIEN,RORMSG,TMP
S IENS="+1,"_(+TASK)_","
S (RORFDA(798.87,IENS,.01),TMP)=$$XEC(NAME)
I TMP'>0 Q:$QUIT 0 Q
S RORFDA(798.87,IENS,.02)=+$G(PARENT)
S:$G(SORTBY) RORFDA(798.87,IENS,.03)=SORTBY
S:$G(VALUE)'="" RORFDA(798.87,IENS,1)=VALUE
D:$G(ID)'=""
. S TMP="+2,"_IENS
. S (RORIEN(2),RORFDA(798.872,TMP,.01))=$$XEC("ID")
. S RORFDA(798.872,TMP,1)=ID
D UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
I $G(DIERR) D Q:$QUIT RC Q
. S RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
Q:$QUIT +$G(RORIEN(1)) Q
;
;***** CHECKS IF THE ELEMENT HAS "CHILDREN"
;
; TASK Task number
;
; ELMTIEN IEN of the element
;
; Return Values:
; 0 Leaf element
; >0 Has children
;
HASCHLD(TASK,ELMTIEN) ;
Q:ELMTIEN<0 0
Q $D(^RORDATA(798.8,+TASK,"RI","APSV",+ELMTIEN))>1
;
;***** UPDATES VALUE OF THE ELEMENT
;
; TASK Task number
;
; ELMTIEN IEN of the element
;
; [VALUE] Value of the element
;
; [SORTBY] Parent element is sorted by the value of the element
; that is being added:
; 1 Sort "as is"
; 2 Sort as strings
; 3 Sort as numbers
;
; [IGNORE] Do not render this element into the resulting XML
; document.
;
; Return Values:
; <0 Error code
; >0 IEN of the report element
;
UPDVAL(TASK,ELMTIEN,VALUE,SORTBY,IGNORE) ;
I $G(ELMTIEN)<0 Q:$QUIT 0 Q
N IENS,RORFDA,RORIEN,RORMSG,TMP
I $D(^RORDATA(798.8,+TASK,"RI",+ELMTIEN))<10 Q:$QUIT 0 Q
S IENS=(+ELMTIEN)_","_(+TASK)_","
S:$G(SORTBY) RORFDA(798.87,IENS,.03)=SORTBY
S RORFDA(798.87,IENS,.04)=$S($G(IGNORE):1,1:"")
S RORFDA(798.87,IENS,1)=$G(VALUE)
D FILE^DIE(,"RORFDA","RORMSG")
I $G(DIERR) D Q:$QUIT RC Q
. S RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
Q:$QUIT +$G(RORIEN(1)) Q
;
;***** DUMPS THE VARIABLE
;
; TASK Task number
;
; ROOT Closed root of the variable
;
; [PARENT] IEN of the parent element (0, by default)
;
; [NAME] Element name ("VARDUMP", by default)
;
; Return Values:
; <0 Error code
; >0 IEN of the element
;
VARDUMP(TASK,ROOT,PARENT,NAME) ;
N DUMP,FLT,LFLT,PI
S:$G(NAME)="" NAME="VARDUMP"
S:$G(PARENT)'>0 PARENT=0
;---
S LFLT=$L(ROOT)
S:$E(ROOT,LFLT)=")" LFLT=LFLT-1
S FLT=$E(ROOT,1,LFLT)
;---
S DUMP=$$ADDVAL^RORTSK11(TASK,NAME,,PARENT)
I DUMP<0 Q:$QUIT DUMP Q
S PI=ROOT
F S PI=$Q(@PI) Q:$E(PI,1,LFLT)'=FLT D
. D ADDVAL^RORTSK11(TASK,"ITEM",PI_"="_@PI,DUMP)
Q:$QUIT DUMP Q
;
;***** RETURNS TYPE (CODE) OF THE ELEMENT
;
; NAME Element name
;
XEC(NAME) ;
S:'$D(RORCACHE("XMLENT",NAME)) RORCACHE("XMLENT",NAME)=+$O(^ROR(799.31,"B",$E(NAME,1,30),0))
Q RORCACHE("XMLENT",NAME)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORTSK11 5417 printed Dec 13, 2024@01:43:33 Page 2
RORTSK11 ;HCIOFO/SG - REPORT CREATION UTILITIES ; 11/14/06 1:16pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
+2 ;
+3 QUIT
+4 ;
+5 ;***** ADDS THE ATTRIBUTE TO THE ELEMENT
+6 ;
+7 ; TASK Task number
+8 ;
+9 ; ELMTIEN IEN of the element
+10 ;
+11 ; NAME Attribute name
+12 ;
+13 ; VALUE Value of the attribute
+14 ;
+15 ; Return Values:
+16 ; <0 Error code
+17 ; 0 Invalid attribute name
+18 ; >0 Attribute IEN
+19 ;
ADDATTR(TASK,ELMTIEN,NAME,VALUE) ;
+1 IF $GET(ELMTIEN)<0
if $QUIT
QUIT 0
QUIT
+2 NEW IENS,RC,RORFDA,RORIEN,RORMSG
+3 IF $DATA(^RORDATA(798.8,+TASK,"RI",+ELMTIEN))<10
if $QUIT
QUIT 0
QUIT
+4 SET IENS="?+1,"_(+ELMTIEN)_","_(+TASK)_","
+5 SET (RORIEN(1),RORFDA(798.872,IENS,.01))=$$XEC(NAME)
+6 IF RORIEN(1)'>0
if $QUIT
QUIT 0
QUIT
+7 SET RORFDA(798.872,IENS,1)=VALUE
+8 DO UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
+9 IF $GET(DIERR)
Begin DoDot:1
+10 SET RC=$$DBS^RORERR("RORMSG",-9,,,798.872,IENS)
End DoDot:1
if $QUIT
QUIT RC
QUIT
+11 if $QUIT
QUIT +$GET(RORIEN(1))
QUIT
+12 ;
+13 ;***** ADDS THE TEXT ELEMENT TO THE REPORT
+14 ;
+15 ; TASK Task number
+16 ;
+17 ; NAME Element name
+18 ;
+19 ; [.]ROR8TXT Either a closed root or a reference to an array
+20 ; that contains the text in word processing format.
+21 ;
+22 ; [PARENT] IEN of the parent element
+23 ;
+24 ; The text should be properly encoded beforehand (use the
+25 ; $$XMLENC^RORUTL03 function).
+26 ;
+27 ; Return Values:
+28 ; <0 Error code
+29 ; 0 Invalid element name
+30 ; >0 IEN of the report element
+31 ;
ADDTEXT(TASK,NAME,ROR8TXT,PARENT) ;
+1 IF $GET(PARENT)<0
if $QUIT
QUIT 0
QUIT
+2 NEW IENS,RC,RORFDA,RORIEN,RORMSG,TMP
+3 SET IENS="+1,"_(+TASK)_","
+4 SET (RORFDA(798.87,IENS,.01),TMP)=$$XEC(NAME)
+5 IF TMP'>0
if $QUIT
QUIT 0
QUIT
+6 SET RORFDA(798.87,IENS,.02)=+$GET(PARENT)
+7 SET RORFDA(798.87,IENS,3)=$SELECT($DATA(ROR8TXT)>1:"ROR8TXT",1:ROR8TXT)
+8 DO UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
+9 IF $GET(DIERR)
Begin DoDot:1
+10 SET RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
End DoDot:1
if $QUIT
QUIT RC
QUIT
+11 if $QUIT
QUIT +$GET(RORIEN(1))
QUIT
+12 ;
+13 ;***** ADDS THE SINGLE-LINE ELEMENT TO THE REPORT
+14 ;
+15 ; TASK Task number
+16 ;
+17 ; NAME Element name
+18 ;
+19 ; [VALUE] Value of the element
+20 ;
+21 ; [PARENT] IEN of the parent element
+22 ;
+23 ; [SORTBY] Parent element is sorted by the value of the element
+24 ; that is being added:
+25 ; 1 Sort "as is"
+26 ; 2 Sort as strings
+27 ; 3 Sort as numbers
+28 ;
+29 ; Return Values:
+30 ; <0 Error code
+31 ; 0 Invalid element name
+32 ; >0 IEN of the report element
+33 ;
ADDVAL(TASK,NAME,VALUE,PARENT,SORTBY,ID) ;
+1 IF $GET(PARENT)<0
if $QUIT
QUIT 0
QUIT
+2 NEW IENS,RC,RORFDA,RORIEN,RORMSG,TMP
+3 SET IENS="+1,"_(+TASK)_","
+4 SET (RORFDA(798.87,IENS,.01),TMP)=$$XEC(NAME)
+5 IF TMP'>0
if $QUIT
QUIT 0
QUIT
+6 SET RORFDA(798.87,IENS,.02)=+$GET(PARENT)
+7 if $GET(SORTBY)
SET RORFDA(798.87,IENS,.03)=SORTBY
+8 if $GET(VALUE)'=""
SET RORFDA(798.87,IENS,1)=VALUE
+9 if $GET(ID)'=""
Begin DoDot:1
+10 SET TMP="+2,"_IENS
+11 SET (RORIEN(2),RORFDA(798.872,TMP,.01))=$$XEC("ID")
+12 SET RORFDA(798.872,TMP,1)=ID
End DoDot:1
+13 DO UPDATE^DIE(,"RORFDA","RORIEN","RORMSG")
+14 IF $GET(DIERR)
Begin DoDot:1
+15 SET RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
End DoDot:1
if $QUIT
QUIT RC
QUIT
+16 if $QUIT
QUIT +$GET(RORIEN(1))
QUIT
+17 ;
+18 ;***** CHECKS IF THE ELEMENT HAS "CHILDREN"
+19 ;
+20 ; TASK Task number
+21 ;
+22 ; ELMTIEN IEN of the element
+23 ;
+24 ; Return Values:
+25 ; 0 Leaf element
+26 ; >0 Has children
+27 ;
HASCHLD(TASK,ELMTIEN) ;
+1 if ELMTIEN<0
QUIT 0
+2 QUIT $DATA(^RORDATA(798.8,+TASK,"RI","APSV",+ELMTIEN))>1
+3 ;
+4 ;***** UPDATES VALUE OF THE ELEMENT
+5 ;
+6 ; TASK Task number
+7 ;
+8 ; ELMTIEN IEN of the element
+9 ;
+10 ; [VALUE] Value of the element
+11 ;
+12 ; [SORTBY] Parent element is sorted by the value of the element
+13 ; that is being added:
+14 ; 1 Sort "as is"
+15 ; 2 Sort as strings
+16 ; 3 Sort as numbers
+17 ;
+18 ; [IGNORE] Do not render this element into the resulting XML
+19 ; document.
+20 ;
+21 ; Return Values:
+22 ; <0 Error code
+23 ; >0 IEN of the report element
+24 ;
UPDVAL(TASK,ELMTIEN,VALUE,SORTBY,IGNORE) ;
+1 IF $GET(ELMTIEN)<0
if $QUIT
QUIT 0
QUIT
+2 NEW IENS,RORFDA,RORIEN,RORMSG,TMP
+3 IF $DATA(^RORDATA(798.8,+TASK,"RI",+ELMTIEN))<10
if $QUIT
QUIT 0
QUIT
+4 SET IENS=(+ELMTIEN)_","_(+TASK)_","
+5 if $GET(SORTBY)
SET RORFDA(798.87,IENS,.03)=SORTBY
+6 SET RORFDA(798.87,IENS,.04)=$SELECT($GET(IGNORE):1,1:"")
+7 SET RORFDA(798.87,IENS,1)=$GET(VALUE)
+8 DO FILE^DIE(,"RORFDA","RORMSG")
+9 IF $GET(DIERR)
Begin DoDot:1
+10 SET RC=$$DBS^RORERR("RORMSG",-9,,,798.87,IENS)
End DoDot:1
if $QUIT
QUIT RC
QUIT
+11 if $QUIT
QUIT +$GET(RORIEN(1))
QUIT
+12 ;
+13 ;***** DUMPS THE VARIABLE
+14 ;
+15 ; TASK Task number
+16 ;
+17 ; ROOT Closed root of the variable
+18 ;
+19 ; [PARENT] IEN of the parent element (0, by default)
+20 ;
+21 ; [NAME] Element name ("VARDUMP", by default)
+22 ;
+23 ; Return Values:
+24 ; <0 Error code
+25 ; >0 IEN of the element
+26 ;
VARDUMP(TASK,ROOT,PARENT,NAME) ;
+1 NEW DUMP,FLT,LFLT,PI
+2 if $GET(NAME)=""
SET NAME="VARDUMP"
+3 if $GET(PARENT)'>0
SET PARENT=0
+4 ;---
+5 SET LFLT=$LENGTH(ROOT)
+6 if $EXTRACT(ROOT,LFLT)=")"
SET LFLT=LFLT-1
+7 SET FLT=$EXTRACT(ROOT,1,LFLT)
+8 ;---
+9 SET DUMP=$$ADDVAL^RORTSK11(TASK,NAME,,PARENT)
+10 IF DUMP<0
if $QUIT
QUIT DUMP
QUIT
+11 SET PI=ROOT
+12 FOR
SET PI=$QUERY(@PI)
if $EXTRACT(PI,1,LFLT)'=FLT
QUIT
Begin DoDot:1
+13 DO ADDVAL^RORTSK11(TASK,"ITEM",PI_"="_@PI,DUMP)
End DoDot:1
+14 if $QUIT
QUIT DUMP
QUIT
+15 ;
+16 ;***** RETURNS TYPE (CODE) OF THE ELEMENT
+17 ;
+18 ; NAME Element name
+19 ;
XEC(NAME) ;
+1 if '$DATA(RORCACHE("XMLENT",NAME))
SET RORCACHE("XMLENT",NAME)=+$ORDER(^ROR(799.31,"B",$EXTRACT(NAME,1,30),0))
+2 QUIT RORCACHE("XMLENT",NAME)