RORX016B ;HCIOFO/BH,SG - OUTPATIENT UTILIZATION (SORT) ;9/14/05 10:08am
;;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 and PCP as additional identifiers.
;******************************************************************************
;
;***** SORTS THE RESULTS AND COMPILES THE TOTALS
;
; Return Values:
; <0 Error code
; 0 Ok
;
SORT() ;
N I,NDSC,NAME,NODE,NSC,NV,RC,RORBUF,RORMSG,STOP,TMP
S NODE=$NA(^TMP("RORX016",$J)) Q:$D(@NODE)<10 0
;--- Outpatient stop codes
S RC=$$LOOP^RORTSK01(0) Q:RC<0 RC
S STOP="",(NDSC,NSC)=0
F S STOP=$O(@NODE@("OPS",STOP)) Q:STOP="" D
. S NSC=NSC+$G(@NODE@("OPS",STOP,"S")),NDSC=NDSC+1
. D FIND^DIC(40.7,,"@;.01","UX",STOP,1,"C",,,"RORBUF","RORMSG")
. D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,40.7)
. S NAME=$G(RORBUF("DILIST","ID",1,.01)) K RORBUF
. S @NODE@("OPS",STOP)=$S(NAME'="":NAME,1:"Unknown")
S @NODE@("OPS")=NSC_U_NDSC
;---
Q 0
;
;***** CALCULATES THE INTERMEDIATE TOTALS
;
; PATIEN Patient IEN (DFN)
; CATSUB Category subscript in the temporary global
;
; Return Values:
; <0 Error code
; 0 Ok
;
TOTALS(PATIEN,AGE) ;
N NODE,TMP
S NODE=$NA(^TMP("RORX016",$J))
;
;=== Outpatient data
D:$D(@NODE@("OP",PATIEN))>1
. N DATE,NDSC,NPSC,NSC,NV,NVSC,SCLST,STOP
. S @NODE@("OP")=$G(@NODE@("OP"))+1
. ;---
. S (DATE,NPSC,NV)=0
. F S DATE=$O(@NODE@("OP",PATIEN,DATE)) Q:DATE'>0 D
. . S NV=NV+1 ; Number of visits
. . S NVSC=@NODE@("OP",PATIEN,DATE) ; Number of visist's stops
. . ;--- Count the patient's stops
. . S STOP=""
. . F S STOP=$O(@NODE@("OP",PATIEN,DATE,STOP)) Q:STOP="" D
. . . S NSC=@NODE@("OP",PATIEN,DATE,STOP) ; Number of stops
. . . S @NODE@("OPS",STOP,"S")=$G(@NODE@("OPS",STOP,"S"))+NSC
. . . S @NODE@("OPS",STOP,"V")=$G(@NODE@("OPS",STOP,"V"))+(NSC/NVSC)
. . . S SCLST(STOP)=""
. . S NPSC=NPSC+NVSC ; Total number of stops
. K @NODE@("OP",PATIEN)
. ;--- Count the different stops and patients
. S STOP="",NDSC=0
. F S STOP=$O(SCLST(STOP)) Q:STOP="" D
. . S @NODE@("OPS",STOP,"P")=$G(@NODE@("OPS",STOP,"P"))+1
. . S NDSC=NDSC+1 ; Number of diff. stops
. ;--- Count the visits
. S:NV>0 @NODE@("OPV")=$G(@NODE@("OPV"))+NV
. ;--- Count the stop codes
. D:NPSC>0
. . S @NODE@("OP",PATIEN)=NPSC_U_NDSC_U_$G(VA("BID"))_U_NV_U_$S($$PARAM^RORTSK01("PATIENTS","ICN"):$$ICN^RORUTL02(PATIEN),1:"")
. . S @NODE@("OP",PATIEN)=@NODE@("OP",PATIEN)_U_$S($$PARAM^RORTSK01("PATIENTS","PACT"):$$PACT^RORUTL02(PATIEN),1:"")_U_$S($$PARAM^RORTSK01("PATIENTS","PCP"):$$PCP^RORUTL02(PATIEN),1:"")_U_AGE
. . S @NODE@("OPS1",NPSC)=$G(@NODE@("OPS1",NPSC))+1
. . S @NODE@("OPS1",NPSC,RORPNAME,PATIEN)=""
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX016B 3328 printed Oct 16, 2024@17:45:38 Page 2
RORX016B ;HCIOFO/BH,SG - OUTPATIENT UTILIZATION (SORT) ;9/14/05 10:08am
+1 ;;1.5;CLINICAL CASE REGISTRIES;**21,31**;Feb 17, 2006;Build 62
+2 ;
+3 QUIT
+4 ;******************************************************************************
+5 ; --- ROUTINE MODIFICATION LOG ---
+6 ;
+7 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+8 ;----------- ---------- ----------- ----------------------------------------
+9 ;ROR*1.5*21 SEP 2013 T KOPP Added ICN as last report column if
+10 ; additional identifier option selected
+11 ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT and PCP as additional identifiers.
+12 ;******************************************************************************
+13 ;
+14 ;***** SORTS THE RESULTS AND COMPILES THE TOTALS
+15 ;
+16 ; Return Values:
+17 ; <0 Error code
+18 ; 0 Ok
+19 ;
SORT() ;
+1 NEW I,NDSC,NAME,NODE,NSC,NV,RC,RORBUF,RORMSG,STOP,TMP
+2 SET NODE=$NAME(^TMP("RORX016",$JOB))
if $DATA(@NODE)<10
QUIT 0
+3 ;--- Outpatient stop codes
+4 SET RC=$$LOOP^RORTSK01(0)
if RC<0
QUIT RC
+5 SET STOP=""
SET (NDSC,NSC)=0
+6 FOR
SET STOP=$ORDER(@NODE@("OPS",STOP))
if STOP=""
QUIT
Begin DoDot:1
+7 SET NSC=NSC+$GET(@NODE@("OPS",STOP,"S"))
SET NDSC=NDSC+1
+8 DO FIND^DIC(40.7,,"@;.01","UX",STOP,1,"C",,,"RORBUF","RORMSG")
+9 if $GET(DIERR)
DO DBS^RORERR("RORMSG",-9,,,40.7)
+10 SET NAME=$GET(RORBUF("DILIST","ID",1,.01))
KILL RORBUF
+11 SET @NODE@("OPS",STOP)=$SELECT(NAME'="":NAME,1:"Unknown")
End DoDot:1
+12 SET @NODE@("OPS")=NSC_U_NDSC
+13 ;---
+14 QUIT 0
+15 ;
+16 ;***** CALCULATES THE INTERMEDIATE TOTALS
+17 ;
+18 ; PATIEN Patient IEN (DFN)
+19 ; CATSUB Category subscript in the temporary global
+20 ;
+21 ; Return Values:
+22 ; <0 Error code
+23 ; 0 Ok
+24 ;
TOTALS(PATIEN,AGE) ;
+1 NEW NODE,TMP
+2 SET NODE=$NAME(^TMP("RORX016",$JOB))
+3 ;
+4 ;=== Outpatient data
+5 if $DATA(@NODE@("OP",PATIEN))>1
Begin DoDot:1
+6 NEW DATE,NDSC,NPSC,NSC,NV,NVSC,SCLST,STOP
+7 SET @NODE@("OP")=$GET(@NODE@("OP"))+1
+8 ;---
+9 SET (DATE,NPSC,NV)=0
+10 FOR
SET DATE=$ORDER(@NODE@("OP",PATIEN,DATE))
if DATE'>0
QUIT
Begin DoDot:2
+11 ; Number of visits
SET NV=NV+1
+12 ; Number of visist's stops
SET NVSC=@NODE@("OP",PATIEN,DATE)
+13 ;--- Count the patient's stops
+14 SET STOP=""
+15 FOR
SET STOP=$ORDER(@NODE@("OP",PATIEN,DATE,STOP))
if STOP=""
QUIT
Begin DoDot:3
+16 ; Number of stops
SET NSC=@NODE@("OP",PATIEN,DATE,STOP)
+17 SET @NODE@("OPS",STOP,"S")=$GET(@NODE@("OPS",STOP,"S"))+NSC
+18 SET @NODE@("OPS",STOP,"V")=$GET(@NODE@("OPS",STOP,"V"))+(NSC/NVSC)
+19 SET SCLST(STOP)=""
End DoDot:3
+20 ; Total number of stops
SET NPSC=NPSC+NVSC
End DoDot:2
+21 KILL @NODE@("OP",PATIEN)
+22 ;--- Count the different stops and patients
+23 SET STOP=""
SET NDSC=0
+24 FOR
SET STOP=$ORDER(SCLST(STOP))
if STOP=""
QUIT
Begin DoDot:2
+25 SET @NODE@("OPS",STOP,"P")=$GET(@NODE@("OPS",STOP,"P"))+1
+26 ; Number of diff. stops
SET NDSC=NDSC+1
End DoDot:2
+27 ;--- Count the visits
+28 if NV>0
SET @NODE@("OPV")=$GET(@NODE@("OPV"))+NV
+29 ;--- Count the stop codes
+30 if NPSC>0
Begin DoDot:2
+31 SET @NODE@("OP",PATIEN)=NPSC_U_NDSC_U_$GET(VA("BID"))_U_NV_U_$SELECT($$PARAM^RORTSK01("PATIENTS","ICN"):$$ICN^RORUTL02(PATIEN),1:"")
+32 SET @NODE@("OP",PATIEN)=@NODE@("OP",PATIEN)_U_$SELECT($$PARAM^RORTSK01("PATIENTS","PACT"):$$PACT^RORUTL02(PATIEN),1:"")_U_$SELECT($$PARAM^RORTSK01("PATIENTS","PCP"):$$PCP^RORUTL02(PATIEN),1:"")_U_AGE
+33 SET @NODE@("OPS1",NPSC)=$GET(@NODE@("OPS1",NPSC))+1
+34 SET @NODE@("OPS1",NPSC,RORPNAME,PATIEN)=""
End DoDot:2
End DoDot:1
+35 QUIT 0