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

MHVXRXM.m

Go to the documentation of this file.
  1. MHVXRXM ;BAA - Medication extract ; [12/14/06 11:38am]
  1. ;;1.0;My HealtheVet;**40**;Aug 23, 2005;Build 26
  1. ;;Per VA Directive 6402, this routine should not be modified
  1. ; Copied from MHVXRX
  1. Q
  1. ;
  1. ;
  1. EXTRACT(QRY,ERR,DATAROOT) ; Entry point to extract prescription data
  1. ; Retrieves requested prescription data and returns it in DATAROOT
  1. ; Retrieves all prescriptions of all statuses in given date range
  1. ; Statuses of deleted are filtered by the pharmacy API.
  1. ;
  1. ; Integration Agreements:
  1. ; 4821 : NONVA^PSO5241
  1. ; 4821 : PEN^PSO5241
  1. ; 4820 : RX^PSO52API
  1. ; 4827 : PSS^PSO59
  1. ; 4533 : ARWS^PSS50
  1. ; 10040 : Hospital Location file
  1. ; 10090 : Institution file
  1. ;
  1. ;
  1. ; Input:
  1. ; QRY - Query array
  1. ; QRY(DFN) - (required) Pointer to PATIENT (#2) file
  1. ; QRY(FROM) - Date to start from
  1. ; QRY(TO) - Date to go to
  1. ; DATAROOT - Root of array to hold extract data
  1. ;
  1. ; Output:
  1. ; DATAROOT - Populated data array, includes # of hits
  1. ; ERR - Errors during extraction
  1. ;
  1. N U,DT,HIT,FROM,TO,STA,DRUG,DIV,MHVSTAT,RXN,MHVDATE,INDEX,DFN,SIG,STAT
  1. N IEN,DRUGNM,DSPDT,ISSDT,LSTFDT,NXTFLDT,FLDT,RELDTTM,EXPDT,STATUS,NUM
  1. N QTY,DSUP,NUMRF,PROV,PORDNUM,MAIL,DIV,REMARKS,SOURCE,LIST,OTRKNM,NDC,LIST
  1. N CLINIC,REFDT,SCHD,NDC,TRDNM,CANDT,ORDR,ADMCLN,CMOP,DGNDC,TOTRF,UNDX,DISC,REM
  1. N PACTY,PADD1,PANAM,PAPHN,PASTA,PAZIP,RXCNT,TRAN,PASITE,PHPHN,REASON,RCOM
  1. ;
  1. D LOG^MHVUL2("MHVXRM EXTRACT","BEGIN","S","TRACE")
  1. S U="^",DT=$$DT^XLFDT
  1. S ERR=0,HIT=0
  1. K @DATAROOT
  1. K ^TMP($J,"MHV"),^TMP($J,"MHVNV"),^TMP($J,"MHVPD"),^TMP($J,"MHVPS"),^TMP($J,"MHVPA")
  1. S DFN=$G(QRY("DFN"))
  1. S FROM=$G(QRY("FROM"))
  1. S TO=$G(QRY("TO"))
  1. ;
  1. ;don't show any non active rx greater than 90 days
  1. S:FROM="" FROM=2000101 ;1/1/1900
  1. S:TO="" TO=9999999 ;If no date set to way into the future
  1. ;
  1. D RX^PSO52API(DFN,"MHV",,,"0,3,R,P,O,M,C,A,CPRS,ST",FROM,TO)
  1. D PEN^PSO5241(DFN,"MHVPD")
  1. D NONVA^PSO5241(DFN,"MHVNV")
  1. ;
  1. D PROCESS
  1. ;
  1. K ^TMP($J,"MHV"),^TMP($J,"MHVNV"),^TMP($J,"MHVPD"),^TMP($J,"MHVPS"),^TMP($J,"MHVPA"),^TMP($J,"MHVDG"),^TMP($J,"PTR")
  1. D LOG^MHVUL2("MHVXRM EXTRACT","END","S","TRACE")
  1. Q
  1. ;
  1. PROCESS ;
  1. S LIST="MHV"
  1. S INDEX=0
  1. F S INDEX=$O(^TMP($J,LIST,DFN,INDEX)) Q:INDEX="" D
  1. .D INIT
  1. .D MHV
  1. ;
  1. I ^TMP($J,"MHVNV",DFN,0)>0 D PRONV
  1. I ^TMP($J,"MHVPD",DFN,0)>0 D PROPD
  1. Q
  1. ;
  1. MHV ;
  1. I +^TMP($J,LIST,DFN,0)=-1 Q
  1. S RXN=^TMP($J,LIST,DFN,INDEX,.01)
  1. I RXN="" Q
  1. S STA=$P($G(^TMP($J,LIST,DFN,INDEX,100)),"^",1) ;status
  1. Q:STA=13
  1. D SETDATA
  1. D DATAROOT
  1. ;
  1. I +^TMP($J,LIST,DFN,INDEX,"RF",0)>0 D REFILL
  1. I +^TMP($J,LIST,DFN,INDEX,"P",0)>0 D PARTIAL
  1. Q
  1. ;
  1. SETDATA ; setup data for original prescription
  1. S UNDX=""
  1. S MHVSTAT=$$AP2^PSOPRA(DFN,RXN)
  1. S MHVDATE=$P(MHVSTAT,"^",2)
  1. S MHVSTAT=$P(MHVSTAT,"^",1)
  1. I MHVSTAT>0 I $$AP5^PSOPRA(DFN,RXN)
  1. S IEN=INDEX
  1. S DRUG=$P($G(^TMP($J,LIST,DFN,INDEX,6)),"^",1) ;drug ien
  1. S DRUGNM=$P($G(^TMP($J,LIST,DFN,INDEX,6)),"^",2) ;drug name
  1. D GETDRG(DRUG,DRUGNM)
  1. S NDC=$G(^TMP($J,LIST,DFN,INDEX,27)) ;RX NDC
  1. I NDC="" S NDC=DGNDC
  1. S DSPDT=$P($G(^TMP($J,LIST,DFN,INDEX,25)),"^",1) ;dispense date
  1. S ISSDT=$P($G(^TMP($J,LIST,DFN,INDEX,1)),"^",1) ;issue date
  1. S LSTFDT=$P($G(^TMP($J,LIST,DFN,INDEX,22)),"^",1) ;last fill date
  1. S NXTFLDT=$P($G(^TMP($J,LIST,DFN,INDEX,102)),"^",1) ;next fill date
  1. S FLDT=$P($G(^TMP($J,LIST,DFN,INDEX,22)),"^",1) ;fill date
  1. S RELDTTM=$P($G(^TMP($J,LIST,DFN,INDEX,31)),"^",1) ;release date & time
  1. S STAT=$P($G(^TMP($J,LIST,DFN,INDEX,100)),"^",2) ;status
  1. S EXPDT=$P($G(^TMP($J,LIST,DFN,INDEX,26)),"^",1) ;expiration date
  1. S STATUS=$S(STA<12&(EXPDT<DT):"EXPIRED",1:STAT)
  1. I STATUS["DISCONTINUED" S STATUS="DISCONTINUED"
  1. S QTY=$G(^TMP($J,LIST,DFN,INDEX,7)) ;quantitY
  1. S DSUP=$G(^TMP($J,LIST,DFN,INDEX,8)) ;days supply
  1. S (NUMRF,TOTRF)=$G(^TMP($J,LIST,DFN,INDEX,9))
  1. S PROV=$G(^TMP($J,LIST,DFN,INDEX,4)) ;provider
  1. S PORDNUM=$P($G(^TMP($J,LIST,DFN,INDEX,39.3)),"^",1) ;placer order number
  1. S MAIL=$P($G(^TMP($J,LIST,DFN,INDEX,11)),"^",1) ;mail (W/M)
  1. S DIV=$G(^TMP($J,LIST,DFN,INDEX,20))_U_$G(^TMP($J,LIST,DFN,INDEX,20,0)) ;division
  1. S REMARKS=$G(^TMP($J,LIST,DFN,INDEX,12)) ;remarks
  1. S SOURCE="RX"
  1. S TRDNM=$G(^TMP($J,LIST,DFN,INDEX,6.5)) ;trade name
  1. S CANDT=$P($G(^TMP($J,LIST,DFN,INDEX,26.1)),"^",1) ;cancel date
  1. S CLINIC=$P($G(^TMP($J,LIST,DFN,INDEX,5)),"^",2) ;clinic
  1. S CMOP=$$CMOP(INDEX,0) ;cmop data
  1. S OTRKNM=$$TRACK(INDEX,"ORIGINAL")
  1. S REASON=$$ACTLG(INDEX,"ORIGINAL")
  1. S RCOM=$P(REASON,"^",2),REASON=$P(REASON,"^",1)
  1. S ORDR=$P($G(^TMP($J,LIST,DFN,IEN,"OI")),"^",2) ;ORDERABLE ITEM
  1. I ORDR="NO DATA FOUND" S ORDR=""
  1. S ADMCLN=+$G(^TMP($J,LIST,DFN,INDEX,14)) ;ADMINISTERED IN CLINIC
  1. S ADMCLN=$S(ADMCLN=1:"YES",1:"NO")
  1. S PAIEN=$P($G(^TMP($J,LIST,DFN,INDEX,20)),U,1)
  1. I PAIEN'="" D GETPHRM(PAIEN)
  1. Q
  1. ;
  1. REFILL ; process refills
  1. N RF,TRFL
  1. S TRFL=$G(^TMP($J,LIST,DFN,INDEX,9))
  1. S RF=0
  1. S SOURCE="RF"
  1. F S RF=$O(^TMP($J,LIST,DFN,INDEX,"RF",RF)) Q:RF="" D SETRF(RF)
  1. Q
  1. ;
  1. SETRF(RF) ;
  1. D INIT2
  1. S RXN=^TMP($J,LIST,DFN,INDEX,.01)
  1. I RXN="" Q
  1. D STRFDT(RF)
  1. D DATAROOT
  1. I ^TMP($J,LIST,DFN,INDEX,"M",0)=-1 S @DATAROOT@(HIT,"SIG",0)=0
  1. E M @DATAROOT@(HIT,"SIG")=^TMP($J,LIST,DFN,INDEX,"M")
  1. Q
  1. ;
  1. STRFDT(RF) ;
  1. S UNDX="RF"_RF
  1. S (FLDT,ISSDT)=$P($G(^TMP($J,LIST,DFN,INDEX,"RF",RF,.01)),"^",1)
  1. S DSPDT=$P($G(^TMP($J,LIST,DFN,INDEX,"RF",RF,10.1)),"^",1)
  1. S RELDTTM=$P($G(^TMP($J,LIST,DFN,INDEX,"RF",RF,17)),"^",1)
  1. S QTY=$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,1))
  1. S DSUP=$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,1.1))
  1. S PROV=$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,15))
  1. S MAIL=$P($G(^TMP($J,LIST,DFN,INDEX,"RF",RF,2)),"^",1)
  1. S DIV=$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,8))_U_$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,8,0))
  1. S REMARKS=$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,3))
  1. S NDC=$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,11))
  1. I NDC="" S NDC=DGNDC
  1. S NUMRF=TOTRF-RF
  1. S CMOP=$$CMOP(INDEX,RF)
  1. S OTRKNM=$$TRACK(INDEX,"REFILL #"_RF)
  1. S REASON=$$ACTLG(INDEX,"REFILL #"_RF)
  1. S RCOM=$P(REASON,"^",2),REASON=$P(REASON,"^",1)
  1. S ADMCLN=+$G(^TMP($J,LIST,DFN,INDEX,"RF",RF,23))
  1. S ADMCLN=$S(ADMCLN=1:"YES",1:"NO")
  1. S PAIEN=$P($G(^TMP($J,LIST,DFN,INDEX,"RF",RF,8)),U,1)
  1. I PAIEN'="" D GETPHRM(PAIEN)
  1. Q
  1. ;
  1. PARTIAL ; process partial prescriptions
  1. N PF
  1. S PF=0
  1. S SOURCE="PF"
  1. F S PF=$O(^TMP($J,LIST,DFN,INDEX,"P",PF)) Q:PF="" D SETPF(PF)
  1. Q
  1. ;
  1. SETPF(PF) ;
  1. D INIT2
  1. S RXN=$G(^TMP($J,LIST,DFN,INDEX,.01))
  1. I RXN="" Q
  1. D STPFDT(PF)
  1. D DATAROOT
  1. I ^TMP($J,LIST,DFN,INDEX,"M",0)=-1 S @DATAROOT@(HIT,"SIG",0)=0
  1. E M @DATAROOT@(HIT,"SIG")=^TMP($J,LIST,DFN,INDEX,"M")
  1. Q
  1. ;
  1. STPFDT(PF) ;
  1. S UNDX="PF"_PF
  1. S (FLDT,ISSDT)=$P($G(^TMP($J,LIST,DFN,INDEX,"P",PF,.01)),"^",1)
  1. S DSPDT=$P($G(^TMP($J,LIST,DFN,INDEX,"P",PF,7.5)),"^",1)
  1. S RELDTTM=$P($G(^TMP($J,LIST,DFN,INDEX,"P",PF,8)),"^",1)
  1. S QTY=$G(^TMP($J,LIST,DFN,INDEX,"P",PF,.04))
  1. S DSUP=$G(^TMP($J,LIST,DFN,INDEX,"P",PF,.041))
  1. S PROV=$G(^TMP($J,LIST,DFN,INDEX,"P",PF,6))
  1. S MAIL=$P($G(^TMP($J,LIST,DFN,INDEX,"P",PF,.02)),"^",1)
  1. S DIV=$G(^TMP($J,LIST,DFN,INDEX,"P",PF,.09))_U_$G(^TMP($J,LIST,DFN,INDEX,"P",PF,.09,0))
  1. S REMARKS=$G(^TMP($J,LIST,DFN,INDEX,"P",PF,.03))
  1. S NDC=$G(^TMP($J,LIST,DFN,INDEX,"P",PF,1))
  1. I NDC="" S NDC=DGNDC
  1. S PAIEN=$P($G(^TMP($J,LIST,DFN,INDEX,"P",PF,.09)),U,1)
  1. I PAIEN'="" D GETPHRM(PAIEN)
  1. Q
  1. ;
  1. CMOP(IEN,RF) ; SET UP CMOP VARIABLES
  1. N CM,CMP,CMOP
  1. I +$G(^TMP($J,LIST,DFN,IEN,"C",0))'>0 Q ""
  1. S CMP=+$G(^TMP($J,LIST,DFN,IEN,"C",0))
  1. S CMOP=""
  1. I CMP>0 D
  1. .S CM=0 F S CM=$O(^TMP($J,LIST,DFN,IEN,"C",CM)) Q:CM="" D
  1. ..I ^TMP($J,LIST,DFN,IEN,"C",CM,2)=RF D
  1. ...S $P(CMOP,U,9)=$P(^TMP($J,LIST,DFN,IEN,"C",CM,9),"^",1)
  1. ...F I=2,3,4,10,11,12 D
  1. ....I $P(^TMP($J,LIST,DFN,IEN,"C",CM,I),"^",2)]"" S $P(CMOP,U,I)=$P(^TMP($J,LIST,DFN,IEN,"C",CM,I),"^",2)
  1. ....E S $P(CMOP,U,I)=$P(^TMP($J,LIST,DFN,IEN,"C",CM,I),"^",1)
  1. Q CMOP
  1. ;
  1. ACTLG(IEN,RF) ; Get info from activity log for Auto DC'ed info.
  1. N RSN,COM,RC,RCOM
  1. S (RSN,RC,COM,RCOM)=""
  1. S AN=0 F S AN=$O(^TMP($J,LIST,DFN,IEN,"A",AN)) Q:AN="" D
  1. .S RC=^TMP($J,LIST,DFN,IEN,"A",AN,.04)
  1. .I RF=RC D
  1. ..S COM=^TMP($J,LIST,DFN,IEN,"A",AN,.05)
  1. ..I COM["Rx Discontinued by EHRM Data Migration." S RSN=$P(^TMP($J,LIST,DFN,IEN,"A",AN,.02),"^",2),RCOM=COM,COM=""
  1. Q RSN_"^"_RCOM
  1. ;
  1. TRACK(IEN,RF) ;
  1. N TRKN,COM,AN,RC
  1. S (TRKN,COM)=""
  1. S AN=0 F S AN=$O(^TMP($J,LIST,DFN,IEN,"A",AN)) Q:AN="" D
  1. .S RC=^TMP($J,LIST,DFN,IEN,"A",AN,.04)
  1. .I RF=RC,$D(^TMP($J,LIST,DFN,IEN,"A",AN,"OC")) D TRK
  1. TRACKQ Q TRKN
  1. ;
  1. TRK ;
  1. N TR,LINE
  1. S TR=0
  1. F S TR=$O(^TMP($J,LIST,DFN,IEN,"A",AN,"OC",TR)) Q:TR="" D
  1. .S LINE=^TMP($J,LIST,DFN,IEN,"A",AN,"OC",TR,.01)
  1. .I LINE["Mail Tracking Info.: " S TRKN=$P(LINE," ",4) S TRKN=$P(TRKN," ",1)
  1. Q
  1. ;
  1. GETPHRM(PAIEN) ;
  1. I '$D(^TMP($J,"MHVPA",PAIEN)) D PSS^PSO59(PAIEN,,"MHVPA")
  1. S PANAM=$P($G(^TMP($J,"MHVPA",PAIEN,.01)),2)
  1. S PADD1=$G(^TMP($J,"MHVPA",PAIEN,.02))
  1. S PAPHN=$G(^TMP($J,"MHVPA",PAIEN,.03))_"-"_$G(^TMP($J,"MHVPA",PAIEN,.04))
  1. I PAPHN="-" S PHPHN=""
  1. S PASITE=$G(^TMP($J,"MHVPA",PAIEN,.06))
  1. S PACTY=$G(^TMP($J,"MHVPA",PAIEN,.07))
  1. S PAZIP=$P($G(^TMP($J,"MHVPA",PAIEN,.05)),U,2)
  1. S PASTA=$P($G(^TMP($J,"MHVPA",PAIEN,.08)),U,2)
  1. Q
  1. ;
  1. DATAROOT ;
  1. S HIT=HIT+1
  1. S @DATAROOT=HIT
  1. S @DATAROOT@(HIT)=$G(RXN)_U_$G(DRUG)_U_$G(MHVSTAT)_U_$G(MHVDATE)
  1. S @DATAROOT@(HIT,"P")=$G(PROV)
  1. S @DATAROOT@(HIT,"RXN")=$G(INDEX)_U_$G(DRUGNM)_U_$G(ISSDT)_U_$G(LSTFDT)_U_$G(RELDTTM)_U_$G(EXPDT)_U_$G(CANDT)_U_$G(TRDNM)
  1. S @DATAROOT@(HIT,"RXN1")=$G(STATUS)_U_$G(QTY)_U_$G(DSUP)_U_$G(NUMRF)_U_$G(PORDNUM)_U_$G(MAIL)_U_$G(UNDX)
  1. S @DATAROOT@(HIT,"RXN2")=$G(SOURCE)_U_$G(NDC)_U_$G(DSPDT)_U_$G(REASON)_U_$G(RCOM)_U_$G(CANDT)
  1. S @DATAROOT@(HIT,"RXN3")=$G(CLINIC)_U_$G(NXTFLDT)_U_$G(SCHD)_U_$G(OTRKNM)_U_$G(ORDR)_U_$G(ADMCLN)
  1. S @DATAROOT@(HIT,"PHRM")=$G(PAIEN)_U_$G(PANAM)_U_$G(PADD1)_U_$G(PAPHN)_U_$G(PACTY)_U_$G(PAZIP)_U_$G(PASTA)_U_$G(PASITE)
  1. S @DATAROOT@(HIT,"DIV")=$G(DIV)
  1. S @DATAROOT@(HIT,"CMOP")=$G(CMOP)
  1. I LIST="MHV" D
  1. .I $P(^TMP($J,LIST,DFN,INDEX,"M",0),U,1)=-1 S @DATAROOT@(HIT,"SIG",0)=0
  1. .E M @DATAROOT@(HIT,"SIG")=^TMP($J,LIST,DFN,INDEX,"M")
  1. I LIST="MHV"!("MHVRF")!(LIST="MHVPF") D
  1. .I REMARKS'="" S @DATAROOT@(HIT,"RMK",1,0)=REMARKS
  1. .S @DATAROOT@(HIT,"RMK",0)=$S(REMARKS="":"",1:1)
  1. Q
  1. ;
  1. PRONV ;
  1. S SOURCE="NV"
  1. S LIST="MHVNV"
  1. S INDEX=0
  1. F S INDEX=$O(^TMP($J,LIST,DFN,INDEX)) Q:INDEX="" Q:INDEX="B" D MHVNV
  1. Q
  1. ;
  1. MHVNV ;Non VA medications
  1. D INIT
  1. N DOSAGE,MEDRT,SCHED,IEN4,PAIEN,CLNUM
  1. S UNDX=""
  1. S RXN=INDEX ;No prescription number exists
  1. S STATUS=$P($G(^TMP($J,LIST,DFN,INDEX,5)),"^",2)
  1. I STATUS="" S STATUS="ACTIVE"
  1. S DRUG=$P($G(^TMP($J,LIST,DFN,INDEX,1)),"^",1)
  1. S DRUGNM=$P($G(^TMP($J,LIST,DFN,INDEX,1)),"^",2) ;drug name
  1. D GETDRG(DRUG,DRUGNM)
  1. S NDC=DGNDC
  1. S DOSAGE=$G(^TMP($J,LIST,DFN,INDEX,2))
  1. S MEDRT=$G(^TMP($J,LIST,DFN,INDEX,3))
  1. S SCHED=$G(^TMP($J,LIST,DFN,INDEX,4))
  1. S SIG=DOSAGE_" "_MEDRT_" "_SCHED
  1. S PROV=$G(^TMP($J,LIST,DFN,INDEX,12))
  1. S LSTFDT=$P($G(^TMP($J,LIST,DFN,INDEX,8)),"^",1)
  1. S ISSDT=$P($G(^TMP($J,LIST,DFN,INDEX,11)),"^",1)
  1. S ISSDT=$P(ISSDT,".",1)
  1. S EXPDT=$P($G(^TMP($J,LIST,DFN,INDEX,6)),"^",1)
  1. S EXPDT=$P(EXPDT,".",1)
  1. S CLNUM=$P($G(^TMP($J,LIST,DFN,INDEX,13)),"^",1)
  1. S CLINIC=$P($G(^TMP($J,LIST,DFN,INDEX,13)),"^",2)
  1. S REMARKS=$G(^TMP($J,LIST,DFN,INDEX,14))
  1. S ORDR=$P($G(^TMP($J,LIST,DFN,INDEX,.01)),"^",2)
  1. S IEN4=$$GET1^DIQ(44,CLNUM,3,"I") ; INSTITUTION file (#4) IEN
  1. S PAIEN=$$GETPTR(IEN4)
  1. I PAIEN'="" D GETPHRM(PAIEN)
  1. D DATAROOT
  1. S N=0 F I=0:1 S N=$O(^TMP($J,LIST,DFN,INDEX,14,N)) Q:N="" S @DATAROOT@(HIT,"RMK",N,0)=^TMP($J,LIST,DFN,INDEX,14,N)
  1. S @DATAROOT@(HIT,"RMK",0)=$S(I=0:"",1:I)
  1. ;
  1. S N=0 F I=0:1 S N=$O(^TMP($J,LIST,DFN,INDEX,10,N)) Q:N="" S @DATAROOT@(HIT,"DSC",N,0)=^TMP($J,LIST,DFN,INDEX,10,N)
  1. S @DATAROOT@(HIT,"DSC",0)=$S(I=0:"",1:I)
  1. ;
  1. S @DATAROOT@(HIT,"SIG",0)=1
  1. S @DATAROOT@(HIT,"SIG",1,0)=SIG
  1. Q
  1. ;
  1. PROPD ;
  1. S SOURCE="PD"
  1. S LIST="MHVPD"
  1. S INDEX=0
  1. F S INDEX=$O(^TMP($J,LIST,DFN,INDEX)) Q:INDEX="" Q:INDEX="B" D MHVPD
  1. Q
  1. ;
  1. MHVPD ;Pending Medications
  1. D INIT
  1. N N,I,CIEN
  1. S (RXN,IEN)=INDEX
  1. S UNDX=""
  1. S PORDNUM=$G(^TMP($J,LIST,DFN,INDEX,.01)) ; PLACER NUMBER
  1. S DRUG=$P($G(^TMP($J,LIST,DFN,INDEX,11)),"^",1) ; DRUG
  1. S DRUGNM=$P($G(^TMP($J,LIST,DFN,INDEX,11)),"^",2) ; drug name
  1. S ORDR=$P($G(^TMP($J,LIST,DFN,INDEX,8)),"^",2) ; ORDERABLE ITEM
  1. D GETDRG(DRUG,DRUGNM)
  1. S NDC=DGNDC
  1. S ISSDT=$P($G(^TMP($J,LIST,DFN,INDEX,15)),"^",1) ; LOGIN DATE
  1. S ISSDT=$P(ISSDT,".",1)
  1. S QTY=$P($G(^TMP($J,LIST,DFN,INDEX,12)),"^",1) ; QTANTITY
  1. S DSUP=$P($G(^TMP($J,LIST,DFN,INDEX,101)),"^",1) ; DAY SUPPLY
  1. S NUMRF=$P($G(^TMP($J,LIST,DFN,INDEX,13)),"^",1) ; NUMBER OF REFILLS
  1. S PROV=$G(^TMP($J,LIST,DFN,INDEX,5)) ; PROVIDER
  1. S MAIL=$P($G(^TMP($J,LIST,DFN,INDEX,19)),"^",1) ; MAIL
  1. S STATUS=$P($G(^TMP($J,LIST,DFN,INDEX,2)),"^",2) ; ORDER TYPE (NW, HD, RNW, DE, DC, RP)
  1. S CIEN=$P($G(^TMP($J,LIST,DFN,INDEX,100)),"^",1) ; Related institution FILE #4 POINTER
  1. S CLINIC=$P($G(^TMP($J,LIST,DFN,INDEX,100)),"^",2) ; Related institution FILE #4 NAME
  1. S PAIEN=$$GETPTR(CIEN)
  1. I PAIEN'="" D GETPHRM(PAIEN)
  1. D DATAROOT
  1. S N=0 F I=0:1 S N=$O(^TMP($J,LIST,DFN,INDEX,24,N)) Q:N="" S @DATAROOT@(HIT,"SIG",N,0)=^TMP($J,LIST,DFN,INDEX,24,N)
  1. S @DATAROOT@(HIT,"SIG",0)=I
  1. Q
  1. ;
  1. GETPTR(IEN4) ; FIND PHARMACY FIELDS
  1. N OUT,PTR,STNM
  1. S STNM=$$GET1^DIQ(4,IEN4,99,"I")
  1. S OUT=""
  1. D PSS^PSO59(,"??","PTR")
  1. S PTR=0 F S PTR=$O(^TMP($J,"PTR",PTR)) Q:PTR="" Q:PTR="B" I ^TMP($J,"PTR",PTR,.06)=STNM S OUT=PTR Q
  1. Q OUT
  1. ;
  1. GETDRG(PSSI,PSSE) ;Drug Information
  1. N PSNIEN,PSNFT
  1. Q:PSSI=""
  1. D ARWS^PSS50(PSSI,PSSE,"MHVDG")
  1. S PSNFT=^TMP($J,"MHVDG",PSSI,21)
  1. S DGNDC=^TMP($J,"MHVDG",PSSI,31)
  1. S PSNIEN=$P(^TMP($J,"MHVDG",PSSI,22),"^",1)
  1. I PSNIEN="" S SCHD="Unscheduled" Q
  1. D DATA^PSN50P68(PSNIEN,PSNFT,"MHVPS")
  1. S SCHD=$P(^TMP($J,"MHVPS",PSNIEN,19),"^",2)
  1. Q
  1. ;
  1. INIT ; set variables to null
  1. S (MHVDATE,MHVSTAT,IEN,DRUG,DRUGNM,DSPDT,ISSDT,LSTFDT,NXTFLDT,FLDT,RELDTTM,EXPDT,STATUS)=""
  1. S (QTY,DSUP,NUMRF,PROV,PORDNUM,MAIL,DIV,REMARKS,TRDNM,CANDT,OTRKNM,UNDX,DISC,REM)=""
  1. S (CLINIC,REFDT,SCHD,NDC,ORDR,ADMCLN,CMOP,DGNDC,REMARKS,TOTRF,REASON,RCOM)=""
  1. S (PANAM,PADD1,PAPHN,PACTY,PAZIP,PASTA)=""
  1. Q
  1. INIT2 ;init vars for partials and refills
  1. S (IEN,DSPDT,ISSDT,FLDT,RELDTTM,UNDX)=""
  1. S (QTY,DSUP,PROV,MAIL,DIV,REMARKS,OTRKNM)=""
  1. S (ADMCLN,CMOP,REMARKS,REASON,RCOM,DISC,REM)=""
  1. S (PANAM,PADD1,PAPHN,PACTY,PAZIP,PASTA)=""