RORX016C ;HCIOFO/BH,SG - OUTPATIENT UTILIZATION (STORE) ;9/14/05 9:43am
;;1.5;CLINICAL CASE REGISTRIES;**21,31**;Feb 17, 2006;Build 62
;
Q
;
;******************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*21 SEP 2013 T KOPP Added ICN as last report column if
; additional identifier option selected
;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
; identifiers.
;******************************************************************************
;
;***** HIGHEST UTILIZATION
;
; PRNTELMT IEN of the parent element
;
; RORNODE Closed root of the section in the temporary global
;
; Return Values:
; <0 Error code
; 0 Ok
;
HIGHUTIL(PRNTELMT,RORNODE) ;
N BUF,COUNT,DFN,I,ITEM,NAME,NUM,RC,RORMAXUT,RORTCNT,SECTION,TABLE,TMP,AGETYPE
S RORMAXUT=$$PARAM^RORTSK01("MAXUTNUM")
Q:RORMAXUT'>0 0
S SECTION=$$ADDVAL^RORTSK11(RORTSK,"HIGHUTIL",,PRNTELMT)
Q:SECTION<0 SECTION
S (RC,RORTCNT)=0
S AGETYPE=$$PARAM^RORTSK01("AGE_RANGE","TYPE")
;--- Stops
I $D(@RORNODE@("OPS1"))>1 D Q:RC<0 RC
. S TABLE=$$ADDVAL^RORTSK11(RORTSK,"HU_STOPS",,SECTION)
. I TABLE<0 S RC=TABLE Q
. D ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","HU_STOPS")
. S RORTCNT=RORTCNT+1
. ;---
. S NUM="",(COUNT,RC)=0
. F S NUM=$O(@RORNODE@("OPS1",NUM),-1) Q:NUM="" D Q:RC
. . S NAME=""
. . F S NAME=$O(@RORNODE@("OPS1",NUM,NAME)) Q:NAME="" D Q:RC
. . . S DFN=""
. . . F S DFN=$O(@RORNODE@("OPS1",NUM,NAME,DFN)) Q:DFN="" D Q:RC
. . . . S COUNT=COUNT+1 I COUNT>RORMAXUT S RC=1 Q
. . . . S BUF=$G(@RORNODE@("OP",DFN))
. . . . S ITEM=$$ADDVAL^RORTSK11(RORTSK,"PATIENT",,TABLE)
. . . . D ADDVAL^RORTSK11(RORTSK,"NAME",NAME,ITEM,1)
. . . . D ADDVAL^RORTSK11(RORTSK,"LAST4",$P(BUF,U,3),ITEM,2)
. . . . I AGETYPE'="ALL" D ADDVAL^RORTSK11(RORTSK,AGETYPE,$P(BUF,U,8),ITEM,1)
. . . . D ADDVAL^RORTSK11(RORTSK,"NV",+$P(BUF,U,4),ITEM,3)
. . . . D ADDVAL^RORTSK11(RORTSK,"NSC",NUM,ITEM,3)
. . . . D ADDVAL^RORTSK11(RORTSK,"NDS",+$P(BUF,U,2),ITEM,3)
. . . . I $$PARAM^RORTSK01("PATIENTS","ICN") D
. . . . . D ADDVAL^RORTSK11(RORTSK,"ICN",$P(BUF,U,5),ITEM,1)
. . . . I $$PARAM^RORTSK01("PATIENTS","PACT") D
. . . . . D ADDVAL^RORTSK11(RORTSK,"PACT",$P(BUF,U,6),ITEM,1)
. . . . I $$PARAM^RORTSK01("PATIENTS","PCP") D
. . . . . D ADDVAL^RORTSK11(RORTSK,"PCP",$P(BUF,U,7),ITEM,1)
;--- Disable the empty section
D:RORTCNT'>0 UPDVAL^RORTSK11(RORTSK,SECTION,"",,1)
Q 0
;
;***** STORES THE REPORT DATA
;
; REPORT IEN of the REPORT element
;
; Return Values:
; <0 Error code
; 0 Ok
; >0 Number of non-fatal errors
;
STORE(REPORT) ;
N RORSONLY ; Output summary only
;
N ECNT,NODE,RC,TMP
S NODE=$NA(^TMP("RORX016",$J))
Q:$D(@NODE)<10 0
S RORSONLY=$$SMRYONLY^RORXU006(),(ECNT,RC)=0
;--- Outpatients
S RC=$$LOOP^RORTSK01(0) Q:RC<0 RC
S RC=$$STOREOP(REPORT,NODE)
I RC Q:RC<0 RC S ECNT=ECNT+1
;--- Highest utilization
S RC=$$LOOP^RORTSK01(0.5) Q:RC<0 RC
S RC=$$HIGHUTIL(REPORT,NODE)
I RC Q:RC<0 RC S ECNT=ECNT+1
;---
Q ECNT
;
;***** OUTPATIENT DATA
;
; PRNTELMT IEN of the parent element
;
; NODE Closed root of the category section
; in the temporary global
;
; Return Values:
; <0 Error code
; 0 Ok
;
STOREOP(PRNTELMT,NODE) ;
Q:$D(@NODE@("OP"))<10 0
N ITEM,NSC,NV,RC,SECTION,STOP,TABLE,TMP
S SECTION=$$ADDVAL^RORTSK11(RORTSK,"OUTPATIENTS",,PRNTELMT)
Q:SECTION<0 SECTION
S RC=0
;--- Stop codes
I $D(@NODE@("OPS1"))>1 D Q:RC<0 RC
. S TABLE=$$ADDVAL^RORTSK11(RORTSK,"STOPS",,SECTION)
. I TABLE<0 S RC=TABLE Q
. D ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","STOPS")
. S NSC=""
. F S NSC=$O(@NODE@("OPS1",NSC),-1) Q:NSC="" D
. . S ITEM=$$ADDVAL^RORTSK11(RORTSK,"ITEM",,TABLE)
. . D ADDVAL^RORTSK11(RORTSK,"NP",$P(@NODE@("OPS1",NSC),U),ITEM,3)
. . D ADDVAL^RORTSK11(RORTSK,"NSC",NSC,ITEM,3)
;--- Clinics
I $D(@NODE@("OPS"))>1 D Q:RC<0 RC
. S TABLE=$$ADDVAL^RORTSK11(RORTSK,"CLINICS",,SECTION)
. I TABLE<0 S RC=TABLE Q
. D ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","CLINICS")
. S STOP=""
. F S STOP=$O(@NODE@("OPS",STOP)) Q:STOP="" D
. . S ITEM=$$ADDVAL^RORTSK11(RORTSK,"CLINIC",,TABLE)
. . D ADDVAL^RORTSK11(RORTSK,"STOP",STOP,ITEM,3)
. . D ADDVAL^RORTSK11(RORTSK,"NAME",$P(@NODE@("OPS",STOP),U),ITEM,1)
. . D ADDVAL^RORTSK11(RORTSK,"NP",+$G(@NODE@("OPS",STOP,"P")),ITEM,3)
. . S TMP=+$G(@NODE@("OPS",STOP,"V"))
. . D ADDVAL^RORTSK11(RORTSK,"NV",$J(TMP,0,2),ITEM,3)
. . D ADDVAL^RORTSK11(RORTSK,"NSC",+$G(@NODE@("OPS",STOP,"S")),ITEM,3)
;--- Summary
D ADDVAL^RORTSK11(RORTSK,"NP",+$G(@NODE@("OP")),SECTION)
D ADDVAL^RORTSK11(RORTSK,"NV",+$G(@NODE@("OPV")),SECTION)
D ADDVAL^RORTSK11(RORTSK,"NSC",+$G(@NODE@("OPS")),SECTION)
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX016C 5188 printed Dec 13, 2024@01:44:48 Page 2
RORX016C ;HCIOFO/BH,SG - OUTPATIENT UTILIZATION (STORE) ;9/14/05 9:43am
+1 ;;1.5;CLINICAL CASE REGISTRIES;**21,31**;Feb 17, 2006;Build 62
+2 ;
+3 QUIT
+4 ;
+5 ;******************************************************************************
+6 ; --- ROUTINE MODIFICATION LOG ---
+7 ;
+8 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+9 ;----------- ---------- ----------- ----------------------------------------
+10 ;ROR*1.5*21 SEP 2013 T KOPP Added ICN as last report column if
+11 ; additional identifier option selected
+12 ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
+13 ; identifiers.
+14 ;******************************************************************************
+15 ;
+16 ;***** HIGHEST UTILIZATION
+17 ;
+18 ; PRNTELMT IEN of the parent element
+19 ;
+20 ; RORNODE Closed root of the section in the temporary global
+21 ;
+22 ; Return Values:
+23 ; <0 Error code
+24 ; 0 Ok
+25 ;
HIGHUTIL(PRNTELMT,RORNODE) ;
+1 NEW BUF,COUNT,DFN,I,ITEM,NAME,NUM,RC,RORMAXUT,RORTCNT,SECTION,TABLE,TMP,AGETYPE
+2 SET RORMAXUT=$$PARAM^RORTSK01("MAXUTNUM")
+3 if RORMAXUT'>0
QUIT 0
+4 SET SECTION=$$ADDVAL^RORTSK11(RORTSK,"HIGHUTIL",,PRNTELMT)
+5 if SECTION<0
QUIT SECTION
+6 SET (RC,RORTCNT)=0
+7 SET AGETYPE=$$PARAM^RORTSK01("AGE_RANGE","TYPE")
+8 ;--- Stops
+9 IF $DATA(@RORNODE@("OPS1"))>1
Begin DoDot:1
+10 SET TABLE=$$ADDVAL^RORTSK11(RORTSK,"HU_STOPS",,SECTION)
+11 IF TABLE<0
SET RC=TABLE
QUIT
+12 DO ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","HU_STOPS")
+13 SET RORTCNT=RORTCNT+1
+14 ;---
+15 SET NUM=""
SET (COUNT,RC)=0
+16 FOR
SET NUM=$ORDER(@RORNODE@("OPS1",NUM),-1)
if NUM=""
QUIT
Begin DoDot:2
+17 SET NAME=""
+18 FOR
SET NAME=$ORDER(@RORNODE@("OPS1",NUM,NAME))
if NAME=""
QUIT
Begin DoDot:3
+19 SET DFN=""
+20 FOR
SET DFN=$ORDER(@RORNODE@("OPS1",NUM,NAME,DFN))
if DFN=""
QUIT
Begin DoDot:4
+21 SET COUNT=COUNT+1
IF COUNT>RORMAXUT
SET RC=1
QUIT
+22 SET BUF=$GET(@RORNODE@("OP",DFN))
+23 SET ITEM=$$ADDVAL^RORTSK11(RORTSK,"PATIENT",,TABLE)
+24 DO ADDVAL^RORTSK11(RORTSK,"NAME",NAME,ITEM,1)
+25 DO ADDVAL^RORTSK11(RORTSK,"LAST4",$PIECE(BUF,U,3),ITEM,2)
+26 IF AGETYPE'="ALL"
DO ADDVAL^RORTSK11(RORTSK,AGETYPE,$PIECE(BUF,U,8),ITEM,1)
+27 DO ADDVAL^RORTSK11(RORTSK,"NV",+$PIECE(BUF,U,4),ITEM,3)
+28 DO ADDVAL^RORTSK11(RORTSK,"NSC",NUM,ITEM,3)
+29 DO ADDVAL^RORTSK11(RORTSK,"NDS",+$PIECE(BUF,U,2),ITEM,3)
+30 IF $$PARAM^RORTSK01("PATIENTS","ICN")
Begin DoDot:5
+31 DO ADDVAL^RORTSK11(RORTSK,"ICN",$PIECE(BUF,U,5),ITEM,1)
End DoDot:5
+32 IF $$PARAM^RORTSK01("PATIENTS","PACT")
Begin DoDot:5
+33 DO ADDVAL^RORTSK11(RORTSK,"PACT",$PIECE(BUF,U,6),ITEM,1)
End DoDot:5
+34 IF $$PARAM^RORTSK01("PATIENTS","PCP")
Begin DoDot:5
+35 DO ADDVAL^RORTSK11(RORTSK,"PCP",$PIECE(BUF,U,7),ITEM,1)
End DoDot:5
End DoDot:4
if RC
QUIT
End DoDot:3
if RC
QUIT
End DoDot:2
if RC
QUIT
End DoDot:1
if RC<0
QUIT RC
+36 ;--- Disable the empty section
+37 if RORTCNT'>0
DO UPDVAL^RORTSK11(RORTSK,SECTION,"",,1)
+38 QUIT 0
+39 ;
+40 ;***** STORES THE REPORT DATA
+41 ;
+42 ; REPORT IEN of the REPORT element
+43 ;
+44 ; Return Values:
+45 ; <0 Error code
+46 ; 0 Ok
+47 ; >0 Number of non-fatal errors
+48 ;
STORE(REPORT) ;
+1 ; Output summary only
NEW RORSONLY
+2 ;
+3 NEW ECNT,NODE,RC,TMP
+4 SET NODE=$NAME(^TMP("RORX016",$JOB))
+5 if $DATA(@NODE)<10
QUIT 0
+6 SET RORSONLY=$$SMRYONLY^RORXU006()
SET (ECNT,RC)=0
+7 ;--- Outpatients
+8 SET RC=$$LOOP^RORTSK01(0)
if RC<0
QUIT RC
+9 SET RC=$$STOREOP(REPORT,NODE)
+10 IF RC
if RC<0
QUIT RC
SET ECNT=ECNT+1
+11 ;--- Highest utilization
+12 SET RC=$$LOOP^RORTSK01(0.5)
if RC<0
QUIT RC
+13 SET RC=$$HIGHUTIL(REPORT,NODE)
+14 IF RC
if RC<0
QUIT RC
SET ECNT=ECNT+1
+15 ;---
+16 QUIT ECNT
+17 ;
+18 ;***** OUTPATIENT DATA
+19 ;
+20 ; PRNTELMT IEN of the parent element
+21 ;
+22 ; NODE Closed root of the category section
+23 ; in the temporary global
+24 ;
+25 ; Return Values:
+26 ; <0 Error code
+27 ; 0 Ok
+28 ;
STOREOP(PRNTELMT,NODE) ;
+1 if $DATA(@NODE@("OP"))<10
QUIT 0
+2 NEW ITEM,NSC,NV,RC,SECTION,STOP,TABLE,TMP
+3 SET SECTION=$$ADDVAL^RORTSK11(RORTSK,"OUTPATIENTS",,PRNTELMT)
+4 if SECTION<0
QUIT SECTION
+5 SET RC=0
+6 ;--- Stop codes
+7 IF $DATA(@NODE@("OPS1"))>1
Begin DoDot:1
+8 SET TABLE=$$ADDVAL^RORTSK11(RORTSK,"STOPS",,SECTION)
+9 IF TABLE<0
SET RC=TABLE
QUIT
+10 DO ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","STOPS")
+11 SET NSC=""
+12 FOR
SET NSC=$ORDER(@NODE@("OPS1",NSC),-1)
if NSC=""
QUIT
Begin DoDot:2
+13 SET ITEM=$$ADDVAL^RORTSK11(RORTSK,"ITEM",,TABLE)
+14 DO ADDVAL^RORTSK11(RORTSK,"NP",$PIECE(@NODE@("OPS1",NSC),U),ITEM,3)
+15 DO ADDVAL^RORTSK11(RORTSK,"NSC",NSC,ITEM,3)
End DoDot:2
End DoDot:1
if RC<0
QUIT RC
+16 ;--- Clinics
+17 IF $DATA(@NODE@("OPS"))>1
Begin DoDot:1
+18 SET TABLE=$$ADDVAL^RORTSK11(RORTSK,"CLINICS",,SECTION)
+19 IF TABLE<0
SET RC=TABLE
QUIT
+20 DO ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","CLINICS")
+21 SET STOP=""
+22 FOR
SET STOP=$ORDER(@NODE@("OPS",STOP))
if STOP=""
QUIT
Begin DoDot:2
+23 SET ITEM=$$ADDVAL^RORTSK11(RORTSK,"CLINIC",,TABLE)
+24 DO ADDVAL^RORTSK11(RORTSK,"STOP",STOP,ITEM,3)
+25 DO ADDVAL^RORTSK11(RORTSK,"NAME",$PIECE(@NODE@("OPS",STOP),U),ITEM,1)
+26 DO ADDVAL^RORTSK11(RORTSK,"NP",+$GET(@NODE@("OPS",STOP,"P")),ITEM,3)
+27 SET TMP=+$GET(@NODE@("OPS",STOP,"V"))
+28 DO ADDVAL^RORTSK11(RORTSK,"NV",$JUSTIFY(TMP,0,2),ITEM,3)
+29 DO ADDVAL^RORTSK11(RORTSK,"NSC",+$GET(@NODE@("OPS",STOP,"S")),ITEM,3)
End DoDot:2
End DoDot:1
if RC<0
QUIT RC
+30 ;--- Summary
+31 DO ADDVAL^RORTSK11(RORTSK,"NP",+$GET(@NODE@("OP")),SECTION)
+32 DO ADDVAL^RORTSK11(RORTSK,"NV",+$GET(@NODE@("OPV")),SECTION)
+33 DO ADDVAL^RORTSK11(RORTSK,"NSC",+$GET(@NODE@("OPS")),SECTION)
+34 QUIT 0