- RORTSK12 ;HCIOFO/SG - REPORT STATS UTILITIES ; 7/15/05 12:00pm
- ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
- ;
- Q
- ;
- ;***** CLEARS THE STATISTICS
- ;
- ; REGIEN Registry IEN
- ;
- ; [RPTCODE] Report Code. By default ($G(RPTCODE)'>0),
- ; all statistic data is deleted.
- ;
- CLEAR(REGIEN,RPTCODE) ;
- N DA,DIK,IENS,NODE,RPIEN
- S DA(1)=+REGIEN,IENS=","_DA(1)_","
- S DIK=$$ROOT^DILFD(798.12,IENS)
- S NODE=$$CREF^DILF(DIK)
- ;
- ;--- Clear the report stats
- I $G(RPTCODE)>0 D Q
- . S RPIEN=$$RPIEN^RORUTL08(RPTCODE) Q:RPIEN'>0
- . L +@NODE@(RPTCODE):5
- . S DA=$$FIND1^DIC(798.12,IENS,"QX",RPIEN,"B",,"RORMSG")
- . D:DA>0 ^DIK
- . L -@NODE@(RPTCODE)
- ;
- ;--- Clear all stats
- L +@NODE:5
- S DA=0 F S DA=$O(@NODE@(DA)) Q:DA'>0 D ^DIK
- L -@NODE
- Q
- ;
- ;***** INCREMENT THE NUMBER OF REPORT RUNS
- ;
- ; REGIEN Registry IEN
- ;
- ; RPTCODE Report Code
- ;
- ; [VAL] Increment value. By default ($G(VAL)'>0),
- ; the counter is incremented by 1.
- ;
- INC(REGIEN,RPTCODE,VAL) ;
- N IEN,IENS,NODE,RORBUF,RORFDA,RORMSG,RPIEN,TMP
- S:$G(VAL)'>0 VAL=1
- ;
- ;--- Get IEN of the report parameters
- S RPIEN=$$RPIEN^RORUTL08(RPTCODE) Q:RPIEN'>0
- ;
- ;--- Lock the report stats
- S IENS=","_(+REGIEN)_","
- S NODE=$$ROOT^DILFD(798.12,IENS,1)
- L +@NODE@(RPTCODE):5
- D
- . ;--- Find and load the report stats
- . S TMP="@;.02"
- . D FIND^DIC(798.12,IENS,TMP,"QX",RPIEN,2,"B",,,"RORBUF","RORMSG")
- . D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,798.12,IENS)
- . Q:$G(RORBUF("DILIST",0))>1
- . S IEN=+$G(RORBUF("DILIST",2,1))
- . ;--- Increment the counter
- . S IENS=$S(IEN>0:IEN,1:"?+1")_","_(+REGIEN)_","
- . S RORFDA(798.12,IENS,.01)=RPIEN
- . S RORFDA(798.12,IENS,.02)=$G(RORBUF("DILIST","ID",1,.02))+VAL
- . D UPDATE^DIE(,"RORFDA",,"RORMSG")
- . D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,798.12,IENS)
- ;
- ;--- Unlock the report stats
- L -@NODE@(RPTCODE)
- Q
- ;
- ;***** RETURNS THE REPORT RUN STATISTICS
- ;
- ; REGIEN Registry IEN
- ;
- ; .STATS Reference to a local array where the statistics
- ; (collected since the last successful data
- ; transmission) will be returned to.
- ;
- ; STATS( Report Statistics Summary
- ; ^01: Total number of report runs
- ; RptCode) Report run statistics
- ; ^01: Number of report runs
- ;
- ; Return Values:
- ; <0 Error code
- ; 0 Ok
- ;
- STATS(REGIEN,STATS) ;
- N IR,RORBUF,RORMSG,RPTCODE,TMP
- K STATS S STATS="0"
- ;--- Load the statistics
- S TMP=","_(+REGIEN)_","
- D LIST^DIC(798.12,TMP,".01I;.02","Q",,,,"B",,,"RORBUF","RORMSG")
- Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,798.12,TMP)
- ;--- Process the statistics
- S IR=0
- F S IR=$O(RORBUF("DILIST","ID",IR)) Q:IR'>0 D
- . ;--- Get the IEN of the report parameters
- . S TMP=+$G(RORBUF("DILIST","ID",IR,.01)) Q:TMP'>0
- . ;--- Get the report code
- . S RPTCODE=$$RPCODE^RORUTL08(TMP) Q:RPTCODE'>0
- . ;--- Get the report statistics
- . S TMP=+$G(RORBUF("DILIST","ID",IR,.02))
- . S $P(STATS(RPTCODE),U)=TMP
- . S $P(STATS,U)=$P(STATS,U)+TMP
- ;---
- Q 0
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORTSK12 3126 printed Feb 18, 2025@23:09:57 Page 2
- RORTSK12 ;HCIOFO/SG - REPORT STATS UTILITIES ; 7/15/05 12:00pm
- +1 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
- +2 ;
- +3 QUIT
- +4 ;
- +5 ;***** CLEARS THE STATISTICS
- +6 ;
- +7 ; REGIEN Registry IEN
- +8 ;
- +9 ; [RPTCODE] Report Code. By default ($G(RPTCODE)'>0),
- +10 ; all statistic data is deleted.
- +11 ;
- CLEAR(REGIEN,RPTCODE) ;
- +1 NEW DA,DIK,IENS,NODE,RPIEN
- +2 SET DA(1)=+REGIEN
- SET IENS=","_DA(1)_","
- +3 SET DIK=$$ROOT^DILFD(798.12,IENS)
- +4 SET NODE=$$CREF^DILF(DIK)
- +5 ;
- +6 ;--- Clear the report stats
- +7 IF $GET(RPTCODE)>0
- Begin DoDot:1
- +8 SET RPIEN=$$RPIEN^RORUTL08(RPTCODE)
- if RPIEN'>0
- QUIT
- +9 LOCK +@NODE@(RPTCODE):5
- +10 SET DA=$$FIND1^DIC(798.12,IENS,"QX",RPIEN,"B",,"RORMSG")
- +11 if DA>0
- DO ^DIK
- +12 LOCK -@NODE@(RPTCODE)
- End DoDot:1
- QUIT
- +13 ;
- +14 ;--- Clear all stats
- +15 LOCK +@NODE:5
- +16 SET DA=0
- FOR
- SET DA=$ORDER(@NODE@(DA))
- if DA'>0
- QUIT
- DO ^DIK
- +17 LOCK -@NODE
- +18 QUIT
- +19 ;
- +20 ;***** INCREMENT THE NUMBER OF REPORT RUNS
- +21 ;
- +22 ; REGIEN Registry IEN
- +23 ;
- +24 ; RPTCODE Report Code
- +25 ;
- +26 ; [VAL] Increment value. By default ($G(VAL)'>0),
- +27 ; the counter is incremented by 1.
- +28 ;
- INC(REGIEN,RPTCODE,VAL) ;
- +1 NEW IEN,IENS,NODE,RORBUF,RORFDA,RORMSG,RPIEN,TMP
- +2 if $GET(VAL)'>0
- SET VAL=1
- +3 ;
- +4 ;--- Get IEN of the report parameters
- +5 SET RPIEN=$$RPIEN^RORUTL08(RPTCODE)
- if RPIEN'>0
- QUIT
- +6 ;
- +7 ;--- Lock the report stats
- +8 SET IENS=","_(+REGIEN)_","
- +9 SET NODE=$$ROOT^DILFD(798.12,IENS,1)
- +10 LOCK +@NODE@(RPTCODE):5
- +11 Begin DoDot:1
- +12 ;--- Find and load the report stats
- +13 SET TMP="@;.02"
- +14 DO FIND^DIC(798.12,IENS,TMP,"QX",RPIEN,2,"B",,,"RORBUF","RORMSG")
- +15 if $GET(DIERR)
- DO DBS^RORERR("RORMSG",-9,,,798.12,IENS)
- +16 if $GET(RORBUF("DILIST",0))>1
- QUIT
- +17 SET IEN=+$GET(RORBUF("DILIST",2,1))
- +18 ;--- Increment the counter
- +19 SET IENS=$SELECT(IEN>0:IEN,1:"?+1")_","_(+REGIEN)_","
- +20 SET RORFDA(798.12,IENS,.01)=RPIEN
- +21 SET RORFDA(798.12,IENS,.02)=$GET(RORBUF("DILIST","ID",1,.02))+VAL
- +22 DO UPDATE^DIE(,"RORFDA",,"RORMSG")
- +23 if $GET(DIERR)
- DO DBS^RORERR("RORMSG",-9,,,798.12,IENS)
- End DoDot:1
- +24 ;
- +25 ;--- Unlock the report stats
- +26 LOCK -@NODE@(RPTCODE)
- +27 QUIT
- +28 ;
- +29 ;***** RETURNS THE REPORT RUN STATISTICS
- +30 ;
- +31 ; REGIEN Registry IEN
- +32 ;
- +33 ; .STATS Reference to a local array where the statistics
- +34 ; (collected since the last successful data
- +35 ; transmission) will be returned to.
- +36 ;
- +37 ; STATS( Report Statistics Summary
- +38 ; ^01: Total number of report runs
- +39 ; RptCode) Report run statistics
- +40 ; ^01: Number of report runs
- +41 ;
- +42 ; Return Values:
- +43 ; <0 Error code
- +44 ; 0 Ok
- +45 ;
- STATS(REGIEN,STATS) ;
- +1 NEW IR,RORBUF,RORMSG,RPTCODE,TMP
- +2 KILL STATS
- SET STATS="0"
- +3 ;--- Load the statistics
- +4 SET TMP=","_(+REGIEN)_","
- +5 DO LIST^DIC(798.12,TMP,".01I;.02","Q",,,,"B",,,"RORBUF","RORMSG")
- +6 if $GET(DIERR)
- QUIT $$DBS^RORERR("RORMSG",-9,,,798.12,TMP)
- +7 ;--- Process the statistics
- +8 SET IR=0
- +9 FOR
- SET IR=$ORDER(RORBUF("DILIST","ID",IR))
- if IR'>0
- QUIT
- Begin DoDot:1
- +10 ;--- Get the IEN of the report parameters
- +11 SET TMP=+$GET(RORBUF("DILIST","ID",IR,.01))
- if TMP'>0
- QUIT
- +12 ;--- Get the report code
- +13 SET RPTCODE=$$RPCODE^RORUTL08(TMP)
- if RPTCODE'>0
- QUIT
- +14 ;--- Get the report statistics
- +15 SET TMP=+$GET(RORBUF("DILIST","ID",IR,.02))
- +16 SET $PIECE(STATS(RPTCODE),U)=TMP
- +17 SET $PIECE(STATS,U)=$PIECE(STATS,U)+TMP
- End DoDot:1
- +18 ;---
- +19 QUIT 0