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

RORUTL16.m

Go to the documentation of this file.
  1. RORUTL16 ;HCIOFO/SG - PHARMACY DATA SEARCH (UTILITIES) ; 10/6/05 9:34am
  1. ;;1.5;CLINICAL CASE REGISTRIES;**32**;Feb 17, 2006;Build 20
  1. ;
  1. ; This routine uses the following IAs:
  1. ;
  1. ; #4533 AND^PSS50, VAC^PSS50 (supported)
  1. ; #4543 IEN^PSN50P65 (supported)
  1. ;
  1. Q
  1. ;
  1. ;***** LOADS THE LIST OF REGISTRY SPECIFIC DRUGS
  1. ;
  1. ; ROR8DST Closed root of the destination buffer
  1. ;
  1. ; REGIEN Registry IEN
  1. ;
  1. ; [FLAGS] Flags to control processing:
  1. ; A Do not kill the destination array before
  1. ; loading the drugs (Add the drugs)
  1. ; C Include VA drug classes from the file #798.6
  1. ; D Include local (dispensed) drugs from the LOCAL
  1. ; DRUG NAME multiple of the file #798.1
  1. ; G Include generic drugs from the file #799.51
  1. ; R Reduce everything to local (dispensed) drugs
  1. ;
  1. ; If this parameter has no value ($G(FLAGS)="") then
  1. ; the default set of flags is used: "DGR".
  1. ;
  1. ; [GROUPID] Optional identifier of the drug group. By default
  1. ; ($G(GROUPID)=""), 0 is used.
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. ; The list of drugs is returned as follow:
  1. ;
  1. ; @ROR8DST@(
  1. ; DrugIEN,
  1. ; GroupID) ""
  1. ; "C",
  1. ; VAClassIEN,
  1. ; GroupID) ""
  1. ; "G",
  1. ; GenericDrugIEN,
  1. ; GroupID) ""
  1. ;
  1. ; DrugIEN is an internal entry number of the local drug record
  1. ; in the DRUG file (#50).
  1. ;
  1. ; Nodes "C" and/or "G" are created only if the R flag is not used.
  1. ; Otherwise, VA drug classes and generic drugs are reduced to the
  1. ; local (dispensed) drugs.
  1. ;
  1. DRUGLIST(ROR8DST,REGIEN,FLAGS,GROUPID) ;
  1. N DRUGIEN,IEN,NDFP,RC,REDUCE,ROOT,RORMSG,VACLIEN
  1. S FLAGS=$S($G(FLAGS)'="":FLAGS,1:"DGR")
  1. S GROUPID=$S($G(GROUPID)'="":GROUPID,1:0)
  1. S REDUCE=(FLAGS["R") K:FLAGS'["A" @ROR8DST
  1. ;
  1. ;--- Drug classes
  1. D:FLAGS["C"
  1. . S IEN=0
  1. . F S IEN=$O(^ROR(798.6,"AC",REGIEN,IEN)) Q:IEN'>0 D
  1. . . D RXADDVCL(ROR8DST,+$G(^ROR(798.6,IEN,0)),REDUCE,GROUPID)
  1. ;
  1. ;--- Local drug names
  1. D:FLAGS["D"
  1. . S ROOT=$$ROOT^DILFD(798.129,","_REGIEN_",",1)
  1. . S IEN=0
  1. . F S IEN=$O(@ROOT@(IEN)) Q:IEN'>0 D
  1. . . S DRUGIEN=+$P($G(@ROOT@(IEN,0)),U)
  1. . . S:DRUGIEN>0 @ROR8DST@(DRUGIEN,GROUPID)=""
  1. ;
  1. ;--- Generic drugs
  1. D:FLAGS["G"
  1. . N RGS S RGS=REGIEN_"#",DRUGIEN=0
  1. . F S DRUGIEN=$O(^ROR(799.51,"ARDG",RGS,DRUGIEN)) Q:DRUGIEN'>0 D
  1. . . D RXADDGEN(ROR8DST,DRUGIEN,REDUCE,GROUPID)
  1. Q 0
  1. ;
  1. ;***** LOADS PHARMACY ORDER DATA
  1. ;
  1. ; .ROR8DST Reference to the ROR8DST parameter
  1. ; passed into the callback function.
  1. ;
  1. ; ORDFLGS Flags describing the original order
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ; 1 Skip this refill
  1. ;
  1. ORDER(ROR8DST,ORDFLGS) ;
  1. N DATE,FILLTYPE
  1. D:ORDFLGS["I"
  1. . S DATE=$P(RORRXE(0),U,5),FILLTYPE="I"
  1. D:ORDFLGS["O"
  1. . S DATE=$P(RORRXE("RXN",0),U,6)
  1. . S FILLTYPE=$P(RORRXE("RXN",0),U,3)
  1. Q
  1. ;
  1. ;***** ADDS THE GENERIC DRUG TO THE LIST OF DRUGS
  1. ;
  1. ; ROR8DST Closed root of the destination buffer
  1. ;
  1. ; GENIEN IEN of a generic drug
  1. ;
  1. ; [REDUCE] Reduce the class to a list of local drugs
  1. ;
  1. ; [GROUPID] Drug group ID
  1. ;
  1. RXADDGEN(ROR8DST,GENIEN,REDUCE,GROUPID) ;
  1. Q:GENIEN'>0
  1. S GROUPID=$S($G(GROUPID)'="":GROUPID,1:0)
  1. I '$G(REDUCE) S @ROR8DST@("G",GENIEN,GROUPID)="" Q
  1. N DRUGIEN,RORTMP,RORTS
  1. S RORTMP=$$ALLOC^RORTMP(.RORTS)
  1. D AND^PSS50(GENIEN,,,RORTS)
  1. S DRUGIEN=0
  1. F S DRUGIEN=$O(@RORTMP@(DRUGIEN)) Q:DRUGIEN'>0 D
  1. . S @ROR8DST@(DRUGIEN,GROUPID)=""
  1. D XDRG^RORUTL22(GENIEN,GROUPID)
  1. D FREE^RORTMP(RORTMP)
  1. Q
  1. ;
  1. ;***** ADDS THE VA DRUG CLASS TO THE LIST OF DRUGS
  1. ;
  1. ; ROR8DST Closed root of the destination buffer
  1. ;
  1. ; VACL Either IEN or code of a VA drug class
  1. ;
  1. ; [REDUCE] Reduce the class to a list of local drugs
  1. ;
  1. ; [GROUPID] Drug group ID
  1. ;
  1. ; [FLAGS] Flags to control processing:
  1. ; E Always treat content of the VACL parameter as
  1. ; a code of the VA Drug Class (instead of IEN)
  1. ;
  1. RXADDVCL(ROR8DST,VACL,REDUCE,GROUPID,FLAGS) ;
  1. N DRUGIEN,RORMSG,RORTMP,RORTS,TMP,VACLIEN
  1. S RORTMP=$$ALLOC^RORTMP(.RORTS)
  1. D
  1. . S VACLIEN=+VACL
  1. . I (VACLIEN'=VACL)!($G(FLAGS)["E") D
  1. . . D IEN^PSN50P65(,VACL,RORTS)
  1. . . S TMP=+$G(@RORTMP@(0))
  1. . . S VACLIEN=$S(TMP=1:+$O(@RORTMP@(0)),1:0)
  1. . Q:VACLIEN'>0
  1. . ;---
  1. . S GROUPID=$S($G(GROUPID)'="":GROUPID,1:0)
  1. . I '$G(REDUCE) S @ROR8DST@("C",VACLIEN,GROUPID)="" Q
  1. . D VAC^PSS50(VACLIEN,,,RORTS)
  1. . S DRUGIEN=0
  1. . F S DRUGIEN=$O(@RORTMP@(DRUGIEN)) Q:DRUGIEN'>0 D
  1. . . S @ROR8DST@(DRUGIEN,GROUPID)=""
  1. ;
  1. D FREE^RORTMP(RORTMP)
  1. Q