Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: RORX014

RORX014.m

Go to the documentation of this file.
RORX014 ;HOIFO/SG - REGISTRY MEDICATIONS REPORT ;11/25/05 5:57pm
 ;;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.
 ;******************************************************************************
 ;
 ;***** OUTPUTS THE REPORT HEADER
 ;
 ; PARTAG        Reference (IEN) to the parent tag
 ;
 ; Return Values:
 ;       <0  Error code
 ;       >0  IEN of the HEADER element
 ;
 ;;RXCOMBLST(NP,PATIENTS(NAME,LAST4,DOD,ICN,PACT,PCP))^I $$PARAM^RORTSK01("OPTIONS","COMPLETE"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
 ;;RXCOMBLST(NP,PATIENTS(NAME,LAST4,AGE,DOD,ICN,PACT,PCP))^I $$PARAM^RORTSK01("OPTIONS","COMPLETE"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
 ;;RXCOMBLST(NP,PATIENTS(NAME,LAST4,DOB,DOD,ICN,PACT,PCP))^I $$PARAM^RORTSK01("OPTIONS","COMPLETE"),$$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
 ;;RXCOMBLST(NP,RXCOMB)^I $$PARAM^RORTSK01("OPTIONS","SUMMARY")
 ;
 N HEADER,RC
 S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
 Q:HEADER<0 HEADER
 S RC=$$TBLDEF^RORXU002("HEADER^RORX014",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,RC
 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 RORTSK("PARAMS","DRUGS","A","AGGR_GENERIC")=1
 S RC=$$DRUGLST^RORXU007(.RORTSK,PARAMS,.RORXL)
 Q:RC<0 RC
 ;--- Success
 Q PARAMS
 ;
 ;***** COMPILES THE "REGISTRY MEDICATIONS" REPORT
 ; REPORT CODE: 014
 ;
 ; .RORTSK       Task number and task parameters
 ;
 ; The ^TMP("RORX014",$J) global node is used by this function.
 ;
 ; ^TMP("RORX014",$J,
 ;   "DRG",
 ;     DrugIEN)          Medication name (generic or formulation)
 ;   "RXC",
 ;     RxcIEN,
 ;       1)              List of Drug IEN's separated by ","
 ;       "P"             Number of patients
 ;         DFN)          Patient Descriptor
 ;                         ^01: Las 4 digits of SSN
 ;                         ^02: Name
 ;                         ^03: Date of Death
 ;                         ^04: ICN
 ;                         ^05: Age/DOB
 ;     "B",
 ;       RxcNdx,
 ;         RxcIEN)       ""
 ;     "P",
 ;       NumOfPat,
 ;         RxcIEN)       ""
 ;
 ; RxcNdx is the first 100 characters of the list of Drug IEN's.
 ;
 ; Return Values:
 ;       <0  Error code
 ;        0  Ok
 ;
RXCOMB(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,NRXC,RC,REPORT,SFLAGS,TMP
 S RORXL="",(ECNT,RC)=0
 K ^TMP("RORX014",$J)
 ;--- 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(80)
 . S RC=$$QUERY^RORX014A(SFLAGS)
 . I RC  Q:RC<0  S ECNT=ECNT+RC
 . ;--- Sort the data
 . D TPPSETUP^RORTSK01(5)
 . S RC=$$SORT^RORX014A(.NRXC)
 . I RC  Q:RC<0  S ECNT=ECNT+RC
 . ;--- Store the results
 . D TPPSETUP^RORTSK01(15)
 . S RC=$$STORE^RORX014A(REPORT,NRXC)
 . I RC  Q:RC<0  S ECNT=ECNT+RC
 ;
 ;--- Cleanup
 K ^TMP("RORX014",$J)
 D FREE^RORTMP(RORXL)
 Q $S(RC<0:RC,ECNT>0:-43,1:0)