RORX008 ;HOIFO/BH,SG - VERA REIMBURSEMENT REPORT ;11/8/05 8:38am
 ;;1.5;CLINICAL CASE REGISTRIES;**21,31**;Feb 17, 2006;Build 62
 ;
 ;--------------------------------------------------------------------
 ; Registry: [VA ICR]
 ;--------------------------------------------------------------------
 ;******************************************************************************
 ;                       --- 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.
 ;******************************************************************************
 Q
 ;
 ;***** COMPILES THE "VERA REIMBURSEMENT" REPORT
 ; REPORT CODE: 008
 ;
 ; .RORTSK       Task number and task parameters
 ;
 ; The ^TMP("RORX008",$J) global node is used by this function.
 ;
 ; ^TMP("RORX008",$J,
 ;
 ;   "DRG",
 ;     GenDrugIEN,       Generic drug name
 ;       0)              Number of HIV+ patients
 ;       1)              Number of Clinical AIDS patients
 ;
 ;   "PAT",              Totals
 ;                         ^01: Number of basic care patients
 ;                         ^02: Number of complex care patients
 ;                         ^03: Number of patients received ARVs
 ;     DFN)              Patient Descriptor
 ;                         ^01: Last 4 digits of SSN
 ;                         ^02: Name
 ;                         ^03: Date of Death (FileMan)
 ;                         ^04: Received ARV drugs(0/1)
 ;                         ^05: Complex care (0/1)
 ;                         ^06: National ICN
 ;                         ^07: PACT Patient care team
 ;                         ^08: PCP Primary care physician
 ;                         ^09: Age/DOB
 ;
 ; Return Values:
 ;       <0  Error code
 ;        0  Ok
 ;
ARVREIMB(RORTSK) ;
 N ROREDT        ; End date
 N ROREDT1       ; End date + 1
 N RORREG        ; Registry IEN
 N RORSDT        ; Start date
 N RORXL         ; Drug list for the pharmacy search API
 ;
 N ECNT,RC,REPORT,SFLAGS,TMP
 K ^TMP("RORX008",$J)
 S RORXL="",(ECNT,RC)=0
 ;--- Root node of the report
 S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
 Q:REPORT<0 REPORT
 ;
 D
 . ;--- Get and prepare the report parameters
 . S RORREG=$$PARAM^RORTSK01("REGIEN")
 . S RC=$$PARAMS(REPORT,.RORSDT,.ROREDT,.SFLAGS)  Q:RC<0
 . S ROREDT1=$$FMADD^XLFDT(ROREDT\1,1)
 . ;--- Report header
 . S RC=$$HEADER(REPORT)  Q:RC<0
 . ;--- Query the registry
 . D TPPSETUP^RORTSK01(75)
 . S RC=$$QUERY^RORX008A(SFLAGS)
 . I RC  Q:RC<0  S ECNT=ECNT+RC
 . ;--- Store the results
 . D TPPSETUP^RORTSK01(25)
 . S RC=$$STORE^RORX008A(REPORT)
 . I RC  Q:RC<0  S ECNT=ECNT+RC
 ;
 ;--- Cleanup
 K ^TMP("RORX008",$J)
 D FREE^RORTMP(RORXL)
 Q $S(RC<0:RC,ECNT>0:-43,1:0)
 ;
 ;***** OUTPUTS THE REPORT HEADER
 ;
 ; PARTAG        Reference (IEN) to the parent tag
 ;
 ; Return Values:
 ;       <0  Error code
 ;       >0  IEN of the HEADER element
 ;
 ;;DRUGS(#,NAME,NP,NPHIV,NPAIDS)^I $$PARAM^RORTSK01("OPTIONS","REGMEDSMRY")
 ;;PATIENTS(#,NAME,LAST4,DOD,AIDSTAT,ARV,COMPLEX,ICN,PACT,PCP)^I $$PARAM^RORTSK01("OPTIONS","PTLIST"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
 ;;PATIENTS(#,NAME,LAST4,AGE,DOD,AIDSTAT,ARV,COMPLEX,ICN,PACT,PCP)^I $$PARAM^RORTSK01("OPTIONS","PTLIST"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
 ;;PATIENTS(#,NAME,LAST4,DOB,DOD,AIDSTAT,ARV,COMPLEX,ICN,PACT,PCP)^I $$PARAM^RORTSK01("OPTIONS","PTLIST"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
 ;
 N HEADER,RC
 S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
 Q:HEADER<0 HEADER
 S RC=$$TBLDEF^RORXU002("HEADER^RORX008",HEADER)
 Q $S(RC<0:RC,1:HEADER)
 ;
 ;***** OUTPUTS THE PARAMETERS TO THE REPORT
 ;
 ; PARTAG        Reference (IEN) to the parent tag
 ;
 ; [.STDT]       Start and end dates of the report
 ; [.ENDT]       are returned via these parameters
 ;
 ; [.FLAGS]      Flags for the $$SKIP^RORXU005 are
 ;               returned via this parameter
 ;
 ; Return Values:
 ;       <0  Error code
 ;       >0  IEN of the PARAMETERS element
 ;
PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
 N PARAMS,TMP
 S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
 Q:PARAMS<0 PARAMS
 ;--- Process the drug list and options
 S RORTSK("PARAMS","DRUGS","A","REGMEDS")=1
 S TMP=$$DRUGLST^RORXU007(.RORTSK,PARAMS,.RORXL)
 Q:TMP<0 TMP
 ;---
 Q PARAMS
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX008   4745     printed  Sep 23, 2025@19:20:28                                                                                                                                                                                                     Page 2
RORX008   ;HOIFO/BH,SG - VERA REIMBURSEMENT REPORT ;11/8/05 8:38am
 +1       ;;1.5;CLINICAL CASE REGISTRIES;**21,31**;Feb 17, 2006;Build 62
 +2       ;
 +3       ;--------------------------------------------------------------------
 +4       ; Registry: [VA ICR]
 +5       ;--------------------------------------------------------------------
 +6       ;******************************************************************************
 +7       ;                       --- ROUTINE MODIFICATION LOG ---
 +8       ;        
 +9       ;PKG/PATCH    DATE        DEVELOPER    MODIFICATION
 +10      ;-----------  ----------  -----------  ----------------------------------------
 +11      ;ROR*1.5*21   SEP 2013    T KOPP       Added ICN as last report column if
 +12      ;                                      additional identifier option selected
 +13      ;ROR*1.5*31   MAY 2017    M FERRARESE  Adding PACT, PCP, and AGE/DOB as additional
 +14      ;                                      identifiers.
 +15      ;******************************************************************************
 +16       QUIT 
 +17      ;
 +18      ;***** COMPILES THE "VERA REIMBURSEMENT" REPORT
 +19      ; REPORT CODE: 008
 +20      ;
 +21      ; .RORTSK       Task number and task parameters
 +22      ;
 +23      ; The ^TMP("RORX008",$J) global node is used by this function.
 +24      ;
 +25      ; ^TMP("RORX008",$J,
 +26      ;
 +27      ;   "DRG",
 +28      ;     GenDrugIEN,       Generic drug name
 +29      ;       0)              Number of HIV+ patients
 +30      ;       1)              Number of Clinical AIDS patients
 +31      ;
 +32      ;   "PAT",              Totals
 +33      ;                         ^01: Number of basic care patients
 +34      ;                         ^02: Number of complex care patients
 +35      ;                         ^03: Number of patients received ARVs
 +36      ;     DFN)              Patient Descriptor
 +37      ;                         ^01: Last 4 digits of SSN
 +38      ;                         ^02: Name
 +39      ;                         ^03: Date of Death (FileMan)
 +40      ;                         ^04: Received ARV drugs(0/1)
 +41      ;                         ^05: Complex care (0/1)
 +42      ;                         ^06: National ICN
 +43      ;                         ^07: PACT Patient care team
 +44      ;                         ^08: PCP Primary care physician
 +45      ;                         ^09: Age/DOB
 +46      ;
 +47      ; Return Values:
 +48      ;       <0  Error code
 +49      ;        0  Ok
 +50      ;
ARVREIMB(RORTSK) ;
 +1       ; End date
           NEW ROREDT
 +2       ; End date + 1
           NEW ROREDT1
 +3       ; Registry IEN
           NEW RORREG
 +4       ; Start date
           NEW RORSDT
 +5       ; Drug list for the pharmacy search API
           NEW RORXL
 +6       ;
 +7        NEW ECNT,RC,REPORT,SFLAGS,TMP
 +8        KILL ^TMP("RORX008",$JOB)
 +9        SET RORXL=""
           SET (ECNT,RC)=0
 +10      ;--- Root node of the report
 +11       SET REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
 +12       if REPORT<0
               QUIT REPORT
 +13      ;
 +14       Begin DoDot:1
 +15      ;--- Get and prepare the report parameters
 +16           SET RORREG=$$PARAM^RORTSK01("REGIEN")
 +17           SET RC=$$PARAMS(REPORT,.RORSDT,.ROREDT,.SFLAGS)
               if RC<0
                   QUIT 
 +18           SET ROREDT1=$$FMADD^XLFDT(ROREDT\1,1)
 +19      ;--- Report header
 +20           SET RC=$$HEADER(REPORT)
               if RC<0
                   QUIT 
 +21      ;--- Query the registry
 +22           DO TPPSETUP^RORTSK01(75)
 +23           SET RC=$$QUERY^RORX008A(SFLAGS)
 +24           IF RC
                   if RC<0
                       QUIT 
                   SET ECNT=ECNT+RC
 +25      ;--- Store the results
 +26           DO TPPSETUP^RORTSK01(25)
 +27           SET RC=$$STORE^RORX008A(REPORT)
 +28           IF RC
                   if RC<0
                       QUIT 
                   SET ECNT=ECNT+RC
           End DoDot:1
 +29      ;
 +30      ;--- Cleanup
 +31       KILL ^TMP("RORX008",$JOB)
 +32       DO FREE^RORTMP(RORXL)
 +33       QUIT $SELECT(RC<0:RC,ECNT>0:-43,1:0)
 +34      ;
 +35      ;***** OUTPUTS THE REPORT HEADER
 +36      ;
 +37      ; PARTAG        Reference (IEN) to the parent tag
 +38      ;
 +39      ; Return Values:
 +40      ;       <0  Error code
 +41      ;       >0  IEN of the HEADER element
 +42      ;
 +1       ;;DRUGS(#,NAME,NP,NPHIV,NPAIDS)^I $$PARAM^RORTSK01("OPTIONS","REGMEDSMRY")
 +2       ;;PATIENTS(#,NAME,LAST4,DOD,AIDSTAT,ARV,COMPLEX,ICN,PACT,PCP)^I $$PARAM^RORTSK01("OPTIONS","PTLIST"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
 +3       ;;PATIENTS(#,NAME,LAST4,AGE,DOD,AIDSTAT,ARV,COMPLEX,ICN,PACT,PCP)^I $$PARAM^RORTSK01("OPTIONS","PTLIST"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
 +4       ;;PATIENTS(#,NAME,LAST4,DOB,DOD,AIDSTAT,ARV,COMPLEX,ICN,PACT,PCP)^I $$PARAM^RORTSK01("OPTIONS","PTLIST"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
 +5       ;
 +6        NEW HEADER,RC
 +7        SET HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
 +8        if HEADER<0
               QUIT HEADER
 +9        SET RC=$$TBLDEF^RORXU002("HEADER^RORX008",HEADER)
 +10       QUIT $SELECT(RC<0:RC,1:HEADER)
 +11      ;
 +12      ;***** OUTPUTS THE PARAMETERS TO THE REPORT
 +13      ;
 +14      ; PARTAG        Reference (IEN) to the parent tag
 +15      ;
 +16      ; [.STDT]       Start and end dates of the report
 +17      ; [.ENDT]       are returned via these parameters
 +18      ;
 +19      ; [.FLAGS]      Flags for the $$SKIP^RORXU005 are
 +20      ;               returned via this parameter
 +21      ;
 +22      ; Return Values:
 +23      ;       <0  Error code
 +24      ;       >0  IEN of the PARAMETERS element
 +25      ;
PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
 +1        NEW PARAMS,TMP
 +2        SET PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
 +3        if PARAMS<0
               QUIT PARAMS
 +4       ;--- Process the drug list and options
 +5        SET RORTSK("PARAMS","DRUGS","A","REGMEDS")=1
 +6        SET TMP=$$DRUGLST^RORXU007(.RORTSK,PARAMS,.RORXL)
 +7        if TMP<0
               QUIT TMP
 +8       ;---
 +9        QUIT PARAMS