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

ABSPOSI1.m

Go to the documentation of this file.
  1. ABSPOSI1 ; IHS/FCS/DRS - support for the prescrip. field on the form ; [ 09/12/2002 10:10 AM ]
  1. ;;1.0;PHARMACY POINT OF SALE;**3,10,44**;JUN 21, 2001;Build 38
  1. ;----------------------------------------------------------------------
  1. ;IHS/SD/lwj 03/10/04 patch 10
  1. ; Routine adjusted to call ABSPFUNC to retrieve
  1. ; the Prescription Refill NDC value. At some
  1. ; point the call needs to be modified to call APSPFUNC.
  1. ; See ABSPFUNC for details on why call was done.
  1. ;----------------------------------------------------------------------
  1. Q
  1. ENABASK D THEASKS(0) Q ; enable the "Ask preauth?" etc. questions
  1. DISABASK D THEASKS(1) Q ; disable those questions
  1. THEASKS(N) ; don't use this directly, the 0/1 meanings are backwards
  1. ; from what you would think they mean (0 enables, 1 disables)
  1. N PAGE,BLOCK S PAGE=1,BLOCK=1
  1. N F F F=12,14,16,18,20 D
  1. . ;I N=0,F=18 Q ; NOT IMPLEM'D - DON'T ENABLE
  1. . D UNED^DDSUTL(F,BLOCK,PAGE,N)
  1. Q
  1. VALID ; VALID is the Data Validation action for the field.
  1. ; It may invoke prescription or visit lookup.
  1. ; It might reset X and DDSEXT.
  1. ;D MSGWAIT("We are in VALID^"_$T(+0)_" with X="_$G(X)_", DDSEXT="_$G(DDSEXT))
  1. N Z S Z=$$VALIDATE(X)
  1. ;D MSGWAIT("VALIDATE^() returns and we have Z="_Z)
  1. S (X,DDSEXT)=Z
  1. ;D MSGWAIT("On the way out, we have set X="_$G(X)_" and DDSEXT="_$G(DDSEXT))
  1. Q
  1. VALIDATE(X) ; validate input and return transformed value
  1. ; Returns -1 if error and sets DDSERROR
  1. ;D MSGWAIT("We are in VALIDATE^"_$T(+0)_" with X="_$G(X))
  1. K DDSERROR
  1. N TYPE ; = "RX" or "VISIT"
  1. ;
  1. VAL1 I 0 ; ELSE each possibility:
  1. E I X?1N.N1"-"1N.N D ; ANMC bar code labels
  1. . S TYPE="RX"
  1. . S X="`"_$P(X,"-",2)
  1. . S X=$$RXLOOKUP(X,"NOX")
  1. . I X<0 S DDSERROR=1
  1. E I X?1N.N,$P($G(^ABSP(9002313.99,1,"INPUT")),U)=0 D ; Sitka
  1. . S TYPE="RX"
  1. . S X="`"_+X
  1. . S X=$$RXLOOKUP(X,"NOX")
  1. . I X<0 S DDSERROR=2
  1. E I X?1"`"1N.N D ; internal RX number input ; 10/26/2000
  1. . S TYPE="RX",X=$$RXLOOKUP(X,"NOX") I X<0 S DDSERROR=6
  1. VAL2 ;
  1. E I X?1N.N0.1A!($$UPPER(X)?1"RX".P1N.N0.1A) D ;external RX # input
  1. . S TYPE="RX"
  1. . I $$UPPER(X)?1"RX".E D
  1. . . S X=$P(X,"RX",2) F Q:$E(X)?1N S X=$E(X,2,$L(X))
  1. . S X=$$RXLOOKUP(X,"OX")
  1. . I X<0 S DDSERROR=5
  1. E I X="" D ; null (includes "@")
  1. . S X="DELETE"
  1. E I $$UPPER(X)=$E("FIND",1,$L(X)) D
  1. . S TYPE="RX" ; might change to VISIT, below
  1. . ; RESET^DDS is the wrong thing to do here
  1. . ; try it without this, too D FULLSCRE
  1. . W @IOF
  1. . S X=$$RXFIND^ABSPOSIF ; = RXI^RXR if presc, = VISITIEN if visit
  1. . D REFRESH^DDSUTL
  1. . I X<0 S DDSERROR=3 Q
  1. . I $L(X,U)=1 S TYPE="VISIT"
  1. E I X?0.1U1N.N1"."1N.N1U D ; VCN number
  1. . S TYPE="VISIT" ; it might change to RX, below
  1. . S X=$O(^AUPNVSIT("VCN",X,0))
  1. . W @IOF
  1. . S X=$$RXFIND^ABSPOSIF(,,X) ;
  1. . D REFRESH^DDSUTL
  1. . I 'X S DDSERROR=4,X=-1
  1. . I $L(X,U)=2 S TYPE="RX"
  1. E I $L(X)'<3,$$UPPER(X)=$E("DELETE",1,$L(X)) D
  1. . S X="DELETE" ; and let EFFECTS do the dirty work later
  1. E D ; if it didn't hit any of the recognized cases:
  1. . S X=-1,DDSERROR=999
  1. ; And now deal with the results
  1. I X>0 D
  1. . I TYPE="RX" D ; X=RXI or RXI^RXR
  1. . . S X="`"_X ; RXR part will be dealt with in EFFECTS
  1. . E I TYPE="VISIT" D ; X points to ^AUPNVSIT
  1. . . S X="V`"_X ; may be changed to VCN in EFFECTS
  1. E I X?1"`"1N.N ; nothing needs to be done ; it's `RXI
  1. E I X="DELETE" ; okay, nothing to do here ; EFFECTS takes care of it
  1. E I X="@" ; okay, EFFECTS takes care of it
  1. E I X=-1 D ; DDSERROR should already be set.
  1. . D HELP^ABSPOSI1
  1. E D IMPOSS^ABSPOSUE("P","TI","Unexpected case: X="_X,,"VAL2",$T(+0))
  1. Q X
  1. FULLSCRE ; adapted from FULL^VALM1
  1. S IOTM=1,IOBM=IOSL W IOSC W @IOSTBM W IORC Q
  1. RXLOOKUP(X,DIC0) ; lookup by `IEN or prescrip # or patient name or whatever
  1. N DIC,Y,DUOUT,DTOUT S DIC="^PSRX(",DIC(0)=DIC0
  1. ;S ^TMP($T(+0),$J," 0 RXLOOKUP^DIC")=$H
  1. ;S ^TMP($T(+0),$J," 1 RXLOOKUP^DIC X^DIC0=")=$G(X)_U_$G(DIC0)
  1. D ^DIC
  1. N RET S RET=$S(Y>0:"`"_+Y,1:-1)
  1. I DIC0["A" D REFRESH^DDSUTL ; put screen back together
  1. ;S ^TMP($T(+0),$J," 2 RXLOOKUP^DIC RET=")=RET
  1. Q RET
  1. HELP ;EP -
  1. N AR,N S N=0
  1. D HELP1("Scan the prescription label.")
  1. D HELP1("Or, you can enter ` followed by the internal number.")
  1. D HELP1("Or, type F or FIND to lookup by patient name.")
  1. D HELP1("Or, type the VCN number (non-prescription charges only).")
  1. I $$GET^DDSVAL(DIE,.DA,.02)]"" D HELP1("Answer with @ to delete this line.")
  1. D HLP^DDSUTL(.AR)
  1. Q
  1. HELP1(X) S N=N+1,AR(N)=X Q
  1. MSGWAIT(X) ;EP - from ABSPOSI2,ABSPOSI8
  1. N AR S AR(1)=X
  1. ; ,AR(2)="$$EOP"
  1. D HLP^DDSUTL(.AR)
  1. D HLP^DDSUTL("$$EOP")
  1. Q
  1. EFFECTS N ERR ; side effects of putting a value in the prescription field
  1. N RX,NDC,PATNAME,DRUGNAME,FILLDATE
  1. N RXI,RXR,DRUG,PAT,AWPMED,VISIT,IEN59
  1. ; NDCDEF - not a field on the form, so this cheap fetch is okay
  1. N NDCDEF S NDCDEF=$P($G(^ABSP(9002313.51,DA(1),100)),U)
  1. I X?1"`"1N.N!(X?1"`"1N.N1"^"1N.N) D ; It's a prescription:
  1. . ; Refill may or may not have been specified (FIND leads to 2nd piece)
  1. . I $L(X,U)>1 S RXR=$P(X,U,2),X=$P(X,U)
  1. . E S RXR=$O(^PSRX($P(X,"`",2),1," "),-1)
  1. . S RX=X,RXI=$P(X,"`",2) ; display the `internal form
  1. . N R0 S R0=$G(^PSRX(RXI,0)) I R0="" D IMPOSS^ABSPOSUE("DB,P","TI","VALIDATE should have caught this",,"EFFECTS",$T(+0))
  1. . S PAT=$P(R0,U,2)
  1. . S PATNAME=$P(^DPT(PAT,0),U)
  1. . S DRUG=$P(R0,U,6) ; get pointer to drug file ; ABSP*1.0T7*11 ; removed "N DRUG", the NEW happened at the calling level and DRUG is needed below
  1. . ;OIT/CAS/RCS 10022012 - Patch 44, only allow 40 characters for the drug name, HEAT # 86226
  1. . I DRUG S DRUGNAME=$E($P($G(^PSDRUG(DRUG,0)),U),1,40) ; get drug name
  1. . E S DRUGNAME="?missing from ^PSRX?"
  1. . I RXR D ; refill
  1. . . S FILLDATE=$P(^PSRX(RXI,1,RXR,0),U) ;$O(^PSRX(X,1,"B",""),-1)
  1. . . ;IHS/SD/lwj 03/10/04 patch 10 nxt line rmkd out, new line added
  1. . . ;I NDCDEF S NDC=$P(^PSRX(RXI,1,RXR,0),U,13)
  1. . . I NDCDEF S NDC=$$NDCVAL^ABSPFUNC(RXI,RXR) ;patch 10
  1. . . ;IHS/SD/lwj 03/10/04 patch 10 end change
  1. . . E S NDC=""
  1. . . S VISIT=$P($G(^PSRX(RXI,1,RXR,999999911)),U)
  1. . E D ; first fill
  1. . . S FILLDATE=$P(^PSRX(RXI,2),U,2),RXR=0
  1. . . I NDCDEF S NDC=$P(^PSRX(RXI,2),U,7)
  1. . . E S NDC=""
  1. . . S VISIT=$P($G(^PSRX(RXI,999999911)),U)
  1. . S FILLDATE=$$MMMDD(FILLDATE)
  1. . I VISIT D ; got to follow the PCC link - we aren't at VISIT yet!
  1. . . S VISIT=$P($G(^AUPNVMED(VISIT,0)),U,3)
  1. E I X?1"V`"1N.N D ; a visit
  1. . S VISIT=$P(X,"`",2) N V0 S V0=^AUPNVSIT(VISIT,0)
  1. . S RX=$P($G(^AUPNVSIT(VISIT,"VCN")),U)
  1. . I RX="" S RX=X ; display the V`VSTDFN form if no VCN defined yet
  1. . S NDC="" ; no default for charge code
  1. . S PAT=$P(V0,U,5)
  1. . S PATNAME=$P(^DPT(PAT,0),U)
  1. . S DRUGNAME="" ; no charge item yet
  1. . S (RXI,RXR,AWPMED)="" ; no prescription
  1. . S FILLDATE=$$MMMDD($P($P(V0,U),"@"))
  1. E I X="DELETE" D
  1. . S (RX,NDC,PATNAME,DRUGNAME,FILLDATE)=""
  1. ;S:RX="" RX=" " S:NDC="" NDC=" " S:PATNAME="" PATNAME=" "
  1. ;S:DRUGNAME="" DRUGNAME=" " S:FILLDATE="" FILLDATE=" "
  1. D PUT^DDSVAL(DIE,.DA,.02,RX)
  1. ; if you have a default NDC number, don't store unless field is empty.
  1. I $$GET^DDSVAL(DIE,.DA,.03)=""!1 D PUT^DDSVAL(DIE,.DA,.03,NDC)
  1. D PUT^DDSVAL(DIE,.DA,.04,PATNAME)
  1. D PUT^DDSVAL(DIE,.DA,.05,DRUGNAME)
  1. D PUT^DDSVAL(DIE,.DA,.06,FILLDATE)
  1. I X="DELETE" D Q
  1. . ; delete all the other fields, too:
  1. . N F
  1. . F F=1.01:.01:1.07,2.01,5.01:.01:5.06,6.01:.01:6.03,7.01:.01:7.03 D
  1. . . D PUT^DDSVAL(DIE,.DA,F,"",,"I")
  1. . D ERASEALL^ABSPOSI8 ; the "I" multiple and page 8 details
  1. . S DDSBR="RX DISP" ; and go back to the RX field
  1. ; For others (not the DELETE case):
  1. D PUT^DDSVAL(DIE,.DA,1.01,$G(RXI),,"I")
  1. D PUT^DDSVAL(DIE,.DA,1.02,$G(RXR),,"I")
  1. D PUT^DDSVAL(DIE,.DA,1.03,$G(DRUG),,"I")
  1. D PUT^DDSVAL(DIE,.DA,1.04,$G(PAT),,"I")
  1. D PUT^DDSVAL(DIE,.DA,1.05,$G(AWPMED),,"I")
  1. D PUT^DDSVAL(DIE,.DA,1.06,$G(VISIT),,"I")
  1. D PUT^DDSVAL(DIE,.DA,1.07,$G(IEN59),,"I")
  1. ;D FILLDATE^ABSPOSIB ; called from Branching Logic
  1. Q
  1. MMMDD(Y) ;EP
  1. X ^DD("DD") Q $P(Y,",")
  1. UPPER(X) Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")