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

RORUTL14.m

Go to the documentation of this file.
  1. RORUTL14 ;HCIOFO/BH,SG - PHARMACY DATA SEARCH ; 12/13/05 2:16pm
  1. ;;1.5;CLINICAL CASE REGISTRIES;**28**;Feb 17, 2006;Build 66
  1. ;
  1. ;
  1. ;******************************************************************************
  1. ;PKG/PATCH DATE DEVELOPER MODIFICATION
  1. ;----------- ---------- ----------- ----------------------------------------
  1. ;ROR*1.5*28 APR 2016 T KOPP Document DAA/in house parameter.
  1. ;******************************************************************************
  1. Q
  1. ;
  1. ;***** SEARCHES THE PHARMACY DATA
  1. ;
  1. ; PATIEN IEN of the patient (DFN)
  1. ;
  1. ; ROR8RXS Closed root of a variable, which contains a list
  1. ; of drugs of interest (in the same format as
  1. ; the list returned by the $$DRUGLIST^RORUTL16).
  1. ;
  1. ; If the "*" is passed via this parameter then all
  1. ; pharmacy orders tests are considered.
  1. ;
  1. ; If this parameter has a pure numeric value then
  1. ; it is considered as registry IEN and the default
  1. ; list of registry specific drugs is automatically
  1. ; compiled by the $$DRUGLIST^RORUTL16 function.
  1. ;
  1. ; [[.]ROR8DST] Closed root of an array where the data will be
  1. ; returned (the ^TMP("RORUTL14",$J), by default).
  1. ; The data will be stored into the destination
  1. ; array in following format:
  1. ;
  1. ; @ROR8DST@(i, Additional drug information
  1. ; ^01: Order number
  1. ; ^02: Flags describing the order:
  1. ; I Inpatient dose
  1. ; O Outpatient fill
  1. ; P Pending
  1. ; V IV
  1. ; ^03: Generic drug IEN (file #50.6)
  1. ; ^04: Generic drug name
  1. ; ^05: Drug class IEN (file #50.605)
  1. ; ^06: Drug class code
  1. ; 0) Detailed information on pharmacy
  1. ; "RXN",0) order loaded by the OEL^PSOORRL
  1. ; ...
  1. ;
  1. ; Example:
  1. ; S RORDST=$NA(^TMP("RORTMP",$J))
  1. ; S RC=$$RXSEARCH^RORUTL14(DFN,REGIEN,RORDST)
  1. ;
  1. ; If this parameter is passed by reference, you can
  1. ; provide a full name ($$TAG^ROUTINE) of the callback
  1. ; function, which will process and store the results,
  1. ; as the value of the "RORCB" node.
  1. ;
  1. ; Any additional nodes created in this variable will
  1. ; be accessible in the callback function. The following
  1. ; nodes are created automatically:
  1. ;
  1. ; "RORDFN" IEN of the registry patient (DFN)
  1. ;
  1. ; "ROREDT" End date
  1. ;
  1. ; "RORFLAGS" Value of parameter of the same name
  1. ;
  1. ; "RORSDT" Start date
  1. ;
  1. ; "RORXGEN" Generic drug
  1. ; ^01: Drug IEN in file #50.6
  1. ; ^02: Generic drug name
  1. ;
  1. ; "RORXVCL" VA Drug class
  1. ; ^01: Class IEN in file #50.605
  1. ; ^02: Class code
  1. ;
  1. ; The callback function must accept 5 parameters:
  1. ;
  1. ; .ROR8DST Reference to the ROR8DST parameter
  1. ; passed into the $$RXSEARCH function.
  1. ;
  1. ; ORDER Order number (from condensed list)
  1. ;
  1. ; FLAGS Flags describing the order to be
  1. ; processed.
  1. ;
  1. ; DRUG Dispensed drug
  1. ; ^01: Drug IEN in file #50
  1. ; ^02: Drug name
  1. ;
  1. ; DATE Order date (issue date for outpatient
  1. ; drugs or start date for inpatient)
  1. ;
  1. ; The ^TMP("PS",$J) global node contains the data
  1. ; returned by the OEL^PSOORRL procedure (see the
  1. ; DBIA #2400 for details).
  1. ;
  1. ; The callback function is called for each additive
  1. ; included in the IV order; the ^TMP("PS",$J) is
  1. ; loaded once and stays the same for all of them.
  1. ;
  1. ; The function should return the following values:
  1. ;
  1. ; <0 Error code (the search will be aborted)
  1. ; 0 Ok
  1. ; 1 Skip this pharmacy order
  1. ; 2 Skip this and all remaining orders
  1. ;
  1. ; Example:
  1. ; S RORDST=$NA(^TMP("RORBUF",$J))
  1. ; S RORDST("RORPTR")=+$O(@RORDST@(""),-1)
  1. ; S RORDST("RORCB")="$$RXCB^RORUT999"
  1. ; S RC=$$RXSEARCH^RORUTL14(DFN,REGIEN,.RORDST)
  1. ;
  1. ; [RORFLAGS] Flags to control processing:
  1. ; E Load external values for additional fields
  1. ; stored into the output array or passed to
  1. ; the callback function. Affected fields
  1. ; have the (E) marker.
  1. ; I Include inpatient doses
  1. ; O Include outpatient fills
  1. ; P Include pending orders
  1. ; V Include IV
  1. ; C Include only DAA Drug (remarks contains CHOICE)
  1. ; H Include only In-house drug (remarks doesn't contain CHOICE)
  1. ;
  1. ; If this parameter has no value ($G(RORFLAGS)="")
  1. ; then the default set of flags is used: "IO".
  1. ;
  1. ; RORSDT Start date (FileMan)
  1. ; [ROREDT] End date (FileMan)
  1. ;
  1. ; The search is performed exactly between provided
  1. ; boundaries (the time parts are considered).
  1. ;
  1. ; The following global nodes are used by the function:
  1. ;
  1. ; ^TMP("PS",$J) The OCL^PSOORRL and OEL^PSOORRL procedures
  1. ; return the results into this node.
  1. ;
  1. ; ^TMP("RORUTL14",$J) If the name of the destination array is
  1. ; not provided via the ROR8DST parameter
  1. ; then the $$RXSEARCH returns the results
  1. ; under this node.
  1. ;
  1. ; ^TMP("RORUTL14L",$J) If the ROR8RXS parameter is undefined
  1. ; then a temporary list of registry specific
  1. ; drugs is compiled under this node.
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 No ordes have been found
  1. ; >0 Number of pharmacy orders
  1. ;
  1. RXSEARCH(PATIEN,ROR8RXS,ROR8DST,RORFLAGS,RORSDT,ROREDT) ;
  1. N RC,ROR8SET,RORXLST,TMP
  1. S:$G(ROR8DST)="" ROR8DST=$NA(^TMP("RORUTL14",$J))
  1. S RORFLAGS=$S($G(RORFLAGS)'="":RORFLAGS,1:"IO")
  1. Q:$TR(RORFLAGS,"IO")=RORFLAGS 0 ; Neither Inpatient nor Outpatient
  1. Q:$G(ROR8RXS)="" 0 ; No drugs to search for
  1. ;---
  1. S:$G(ROREDT)'>0 ROREDT=DT
  1. S RORXLST=$$ALLOC^RORTMP(),RC=0
  1. ;
  1. D
  1. . ;--- Prepare the list of drugs of interest
  1. . I (+ROR8RXS)=ROR8RXS D Q:RC'>0
  1. . . S TMP=ROR8RXS,ROR8RXS=$$ALLOC^RORTMP()
  1. . . S RC=$$DRUGLIST^RORUTL16(ROR8RXS,TMP)
  1. . I ROR8RXS'="*",$D(@ROR8RXS)<10 S RC=0 Q
  1. . ;--- Preselect pharmacy orders
  1. . S RC=$$QUERY^RORUTL15(PATIEN,RORFLAGS,RORSDT,ROREDT,RORXLST)
  1. . Q:RC'>0
  1. . ;--- Process selected orders
  1. . S RC=$$PROCESS^RORUTL15(PATIEN,RORFLAGS,RORXLST)
  1. . Q:RC'>0
  1. ;
  1. ;--- Cleanup
  1. D POP^RORTMP(RORXLST)
  1. Q RC