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

RORX012.m

Go to the documentation of this file.
  1. RORX012 ;HOIFO/SG,VAC - COMBINED MEDS AND LABS REPORT ;4/9/09 9:40am
  1. ;;1.5;CLINICAL CASE REGISTRIES;**8,21,31,33,34**;Feb 17, 2006;Build 45
  1. ;
  1. ;Modified Feb 2009, to permit only the most recent test to be
  1. ; displayed on the report - a call to ^RORXU009
  1. ;
  1. ;Modified March 2009 to filter patients on Include or Exclude ICD9
  1. ; codes. Call to ^RORXU010
  1. ;
  1. ;ROR*1.5*21 SEP 2013 T KOPP Add ICN column if Additional Identifier
  1. ; requested.
  1. ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
  1. ; identifiers.
  1. ;ROR*1.5*33 MAY 2017 M FERRARESE Adding Future Appointment
  1. ;
  1. ;ROR*1.5*34 SEP 2018 M FERRARESE Adding Future Appointment clinic name
  1. ;******************************************************************************
  1. ;
  1. Q
  1. ;
  1. ;***** OUTPUTS THE REPORT HEADER
  1. ;
  1. ; PARTAG Reference (IEN) to the parent tag
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; >0 IEN of the HEADER element
  1. ;
  1. ;;DRUGS(#,NAME,LAST4,DOD,RXNAME)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
  1. ;;DRUGS(#,NAME,LAST4,AGE,DOD,RXNAME)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
  1. ;;DRUGS(#,NAME,LAST4,DOB,DOD,RXNAME)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
  1. ;;LABTESTS(#,NAME,LAST4,DOD,DATE,LTNAME,RESULT)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
  1. ;;LABTESTS(#,NAME,LAST4,AGE,DOD,DATE,LTNAME,RESULT)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
  1. ;;LABTESTS(#,NAME,LAST4,DOB,DOD,DATE,LTNAME,RESULT)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
  1. ;;PATIENTS(#,NAME,LAST4,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
  1. ;;PATIENTS(#,NAME,LAST4,AGE,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
  1. ;;PATIENTS(#,NAME,LAST4,DOB,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
  1. ;
  1. N HEADER,RC
  1. S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
  1. Q:HEADER<0 HEADER
  1. S RC=$$TBLDEF^RORXU002("HEADER^RORX012",HEADER)
  1. Q $S(RC<0:RC,1:HEADER)
  1. ;
  1. ;***** OUTPUTS THE PARAMETERS TO THE REPORT
  1. ;
  1. ; PARTAG Reference (IEN) to the parent tag
  1. ;
  1. ; [.STDT] Start and end dates of the report
  1. ; [.ENDT] are returned via these parameters
  1. ;
  1. ; [.FLAGS] Flags for the $$SKIP^RORXU005 are
  1. ; returned via this parameter
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; >0 IEN of the PARAMETERS element
  1. ;
  1. PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
  1. N PARAMS,TMP
  1. S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
  1. Q:PARAMS<0 PARAMS
  1. ;--- Process the list of drugs and groups
  1. I RORPHARM D Q:TMP<0 TMP
  1. . S TMP=$$DRUGLST^RORXU007(.RORTSK,PARAMS,.RORXL,.RORXGRP)
  1. ;--- Process the list of Lab tests
  1. I RORLAB D Q:TMP<0 TMP
  1. . S TMP=$$LTLST^RORXU006(.RORTSK,PARAMS,.RORLTST,"RORLTRV")
  1. ;---
  1. Q PARAMS
  1. ;
  1. ;***** DETERMINES THE REPORT MODE FOR LAB OR PHARMACY
  1. ;
  1. ; NAME Base name of the attribute ("LAB" or "PHARM")
  1. ;
  1. ; Return Values:
  1. ; <0 "Did Not"
  1. ; 0 Not selected
  1. ; >0 "Did"
  1. RPTMODE(NAME) ;
  1. Q:$$PARAM^RORTSK01("PATIENTS",NAME) 1 ; "Did"
  1. Q:$$PARAM^RORTSK01("PATIENTS","NO"_NAME) -1 ; "Did Not"
  1. Q 0
  1. ;
  1. ;***** COMPILES THE "COMBINED PHARMACY AND LAB" REPORT
  1. ; REPORT CODE: 012
  1. ;
  1. ; .RORTSK Task number and task parameters
  1. ;
  1. ; The ^TMP("RORX012",$J) global node is used by this function.
  1. ;
  1. ; ^TMP("RORX012",$J,
  1. ; "PAT",
  1. ; DFN, Patient descriptor
  1. ; ^01: Last 4 digits of SSN
  1. ; ^02: Patient name
  1. ; ^03: Date of Death
  1. ; ^04: ICN
  1. ; ^05: PACT
  1. ; ^06: PCP
  1. ; ^07: AGE/DOB
  1. ; ^08: FUT APPOINTMENT DATE
  1. ; ^09: FUT APPOINTMENT CLINIC
  1. ;
  1. ;
  1. ; "LR",
  1. ; Date,
  1. ; TestName,
  1. ; TestIEN) Result
  1. ; "RX",
  1. ; DrugName,
  1. ; DrugIEN) ""
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. RXANDLAB(RORTSK) ;
  1. N RORLAB ; Labs mode (-1|0|1)
  1. N RORLTST ; Closed root of the list of lab tests for the
  1. ; ; Lab search API
  1. N RORLTRV ; Closed root of the list of lab tests with ranges
  1. N RORPHARM ; Meds mode (-1|0|1)
  1. N RORREG ; Registry IEN
  1. N RORXEDT ; Pharmacy end date
  1. N RORXGRP ; List of drug groups
  1. N RORXL ; Closed root of the drug list for the pharmacy
  1. ; ; search API or "*" if all drugs were selected
  1. N RORXSDT ; Pharmacy start date
  1. ;
  1. N ECNT,NSPT,RC,REPORT,SFLAGS,TMP
  1. N RORDEL ; Flag to determine if Most Recent is set
  1. N RORDELTSK ; Task number passed to delete tests
  1. S RORDEL=$G(RORTSK("PARAMS","LABTESTS","A","MOST_RECENT"))
  1. S RORDELTSK=RORTSK
  1. S (RORXL,RORLTST)="",(ECNT,RC)=0
  1. K ^TMP("RORX012",$J)
  1. ;--- Root node of the report
  1. S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
  1. Q:REPORT<0 REPORT
  1. ;
  1. D
  1. . ;--- Get and prepare the report parameters
  1. . S RORREG=$$PARAM^RORTSK01("REGIEN") ; Registry IEN
  1. . S RORLAB=$$RPTMODE("LAB") ; Labs logic
  1. . S RORPHARM=$$RPTMODE("PHARM") ; Meds logic
  1. . S RC=$$PARAMS(REPORT,.RORXSDT,.RORXEDT,.SFLAGS) Q:RC<0
  1. . ;--- Report header
  1. . S RC=$$HEADER(REPORT) Q:RC<0
  1. . ;--- Query the registry
  1. . D TPPSETUP^RORTSK01(80)
  1. . S RC=$$QUERY^RORX012A(SFLAGS,.NSPT)
  1. . I RC Q:RC<0 S ECNT=ECNT+RC
  1. . ;--- Store the results
  1. . D TPPSETUP^RORTSK01(20)
  1. . S RC=$$STORE^RORX012A(REPORT,NSPT)
  1. . I RC Q:RC<0 S ECNT=ECNT+RC
  1. ;
  1. ;--- Cleanup
  1. ;--- Modify the report if only the latest test is required
  1. ; Inputs are Task number for File 798.8 and the flag
  1. I RORDEL=1 D DEL^RORXU009(RORDELTSK)
  1. K ^TMP("RORX012",$J)
  1. D FREE^RORTMP(RORXL),FREE^RORTMP(RORLTST)
  1. ;
  1. Q $S(RC<0:RC,ECNT>0:-43,1:0)