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

ABSPOSFD.m

Go to the documentation of this file.
  1. ABSPOSFD ; IHS/FCS/DRS - ABSP("RX",*) ; [ 09/12/2002 10:09 AM ]
  1. ;;1.0;PHARMACY POINT OF SALE;**3,10,40**;JUN 21, 2001;Build 38
  1. ;----------------------------------------------------------------------
  1. ; This is a copy of routine ABSPOSCD, made on 03/20/2001.
  1. ; It constructs the ABSP(*) array for printing NCPDP forms.
  1. ; Try to keep the two versions in synch.
  1. ;
  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. ;----------------------------------------------------------------------
  1. ;Set ABSP() "RX" nodes for current medication:
  1. ;
  1. ;Parameters: VMEDINFO - Contains RXIEN,RXRFIEN,IEN57
  1. ; MEDN - Index number indicating what medication is
  1. ; being processed
  1. ;----------------------------------------------------------------------
  1. ; Called from ABSPOSCA from ABSPOSQG from ABSPOSQ2,
  1. ; once for each item in its VMEDS() array.
  1. MEDINFO(VMEDINFO,MEDN,INSPINS) ;EP
  1. ;Manage local variables
  1. N RXIEN,RXRFIEN,DRUGIEN,PROVIEN,RXI,IEN57,PINSTYPE
  1. ;
  1. ;Parse variables from VMEDINFO variable
  1. S RXIEN=$P(VMEDINFO,U,2)
  1. S RXRFIEN=$P(VMEDINFO,U,3)
  1. S IEN57=$P(VMEDINFO,U,5)
  1. D OVERRIDE(IEN57,MEDN) ; overrides stored in 9002313.511
  1. ;
  1. S PINSTYPE=$P(INSPINS,",") ; "CAID" will make a difference
  1. ;
  1. S DRUGIEN=$P($G(^PSRX(RXIEN,0)),U,6)
  1. S PROVIEN=$P($G(^PSRX(RXIEN,0)),U,4)
  1. ;
  1. S ABSP("RX",MEDN,"IEN57")=IEN57
  1. S (RXI,ABSP("RX",MEDN,"RX IEN"))=RXIEN
  1. S ABSP("RX",MEDN,"Date Written")=$P($G(^PSRX(RXIEN,0)),U,13)
  1. S ABSP("RX",MEDN,"RX Number")=RXIEN ;$P($G(^PSRX(RXIEN,0)),U,1)
  1. S ABSP("RX",MEDN,"New/Refill")=$S(RXRFIEN="":"N",1:"R")
  1. S ABSP("RX",MEDN,"Preauth #")=$P(^ABSPTL(IEN57,1),U,9)
  1. I 'RXRFIEN D ; first fill
  1. .S ABSP("RX",MEDN,"Quantity")=$P($G(^PSRX(RXIEN,0)),U,7)
  1. .S ABSP("RX",MEDN,"Days Supply")=$P($G(^PSRX(RXIEN,0)),U,8)
  1. .S ABSP("RX",MEDN,"Date Filled")=$P($G(^PSRX(RXIEN,2)),U,2)
  1. .S ABSP("RX",MEDN,"NDC")=$P($G(^PSRX(RXIEN,2)),U,7)
  1. E D ; refill
  1. .S ABSP("RX",MEDN,"Quantity")=$P($G(^PSRX(RXIEN,1,RXRFIEN,0)),U,4)
  1. .S ABSP("RX",MEDN,"Days Supply")=$P($G(^PSRX(RXIEN,1,RXRFIEN,0)),U,10)
  1. .S ABSP("RX",MEDN,"Date Filled")=$P($G(^PSRX(RXIEN,1,RXRFIEN,0)),U)
  1. .;IHS/SD/lwj 03/10/04 patch 10 nxt line rmkd out, new line added
  1. .;S ABSP("RX",MEDN,"NDC")=$P($G(^PSRX(RXIEN,1,RXRFIEN,0)),U,13)
  1. .S ABSP("RX",MEDN,"NDC")=$$NDCVAL^ABSPFUNC(RXIEN,RXRFIEN) ; patch 10
  1. .;IHS/SD/lwj 03/10/04 patch 10 end change
  1. ;IHS/OIT/CNI/RAN PATCH 40 This is the proper fill date
  1. S ABSP("RX","Date Filled")=ABSP("RX",MEDN,"Date Filled")
  1. ;
  1. S ABSP("RX",MEDN,"# Refills")=$P($G(^PSRX(RXIEN,0)),U,9)
  1. S ABSP("RX",MEDN,"Refill #")=$$RXRFN(RXIEN,RXRFIEN)
  1. S ABSP("RX",MEDN,"Prescriber IEN")=+PROVIEN
  1. S ABSP("RX",MEDN,"Prescriber DEA #")=$P($G(^VA(200,+PROVIEN,"PS")),U,2)
  1. S ABSP("RX",MEDN,"Prescriber CAID #")=$P($G(^VA(200,+PROVIEN,9999999)),U,7)
  1. S ABSP("RX",MEDN,"Prescriber UPIN #")=$P($G(^VA(200,+PROVIEN,9999999)),U,8) ;*1.26*2*
  1. S ABSP("RX",MEDN,"Prescriber Billing Location")=$S(PROVIEN]"":$P($G(^VA(200,PROVIEN,9999999)),"^",11),1:"") ; ANMC only? not in Sitka's data dic.
  1. ;IHS/OIT/CASSEVERN/RAN 11/16/2010 PATCH 40 Adding Triplicate Serial # for New York Medicaid
  1. S ABSP("RX",MEDN,"Triplicate Serial #")=$P($G(^PSRX(RXIEN,9999999)),U,14)
  1. D
  1. . N %
  1. . I PINSTYPE="CAID" D
  1. . . S %=ABSP("RX",MEDN,"Prescriber CAID #")
  1. . . I %="" D ; special for ANMC
  1. . . . N %1 S %1=ABSP("RX",MEDN,"Prescriber Billing Location")
  1. . . . S %=$S(%1=1665:"MDG275",%1=1946:"MDG867",1:"")
  1. . . I %="" S %=ABSP("Site","Default CAID #")
  1. . E D
  1. . . S %=ABSP("RX",MEDN,"Prescriber DEA #")
  1. . . I %="" S %=ABSP("Site","Default DEA #")
  1. . S ABSP("RX",MEDN,"Prescriber ID")=%
  1. ;
  1. D:DRUGIEN'=""
  1. .S ABSP("RX",MEDN,"Drug IEN")=DRUGIEN
  1. .S ABSP("RX",MEDN,"Drug Name")=$P($G(^PSDRUG(DRUGIEN,0)),U,1)
  1. .I ABSP("RX",MEDN,"NDC")="" D
  1. ..S ABSP("RX",MEDN,"NDC")=$P($G(^PSDRUG(DRUGIEN,2)),U,4)
  1. N PRICING S PRICING=^ABSPTL(IEN57,5)
  1. S ABSP("RX",MEDN,"Quantity")=$P(PRICING,U) ; 01/31/2001
  1. S ABSP("RX",MEDN,"Unit Price")=$P(PRICING,U,2)
  1. S ABSP("RX",MEDN,"Ingredient Cost")=$J($P(PRICING,U,3),0,2)
  1. S ABSP("RX",MEDN,"Dispensing Fee")=$J($P(PRICING,U,4),0,2)
  1. S ABSP("Site","Dispensing Fee")=ABSP("RX",MEDN,"Dispensing Fee")
  1. S ABSP("RX",MEDN,"Gross Amount Due")=$J($P(PRICING,U,5),0,2)
  1. S ABSP("RX",MEDN,"Usual & Customary")=$J($P(PRICING,U,5),0,2)
  1. ;IHS/OIT/SCR 11/20/08 - Add incentive amount info
  1. S ABSP("RX",MEDN,"Incentive Amount")=$J($P(PRICING,U,7),0,2)
  1. I ABSP("NCPDP","Add Disp. Fee to Ingr. Cost") D
  1. . N X S X=ABSP("RX",MEDN,"Ingredient Cost")
  1. . S X=X+ABSP("RX",MEDN,"Dispensing Fee")
  1. . S ABSP("RX",MEDN,"Ingredient Cost")=X
  1. ;
  1. ; Visit-related data
  1. ;
  1. I IEN57 D
  1. . N VSITIEN S VSITIEN=$P(^ABSPTL(IEN57,0),U,7)
  1. . Q:'VSITIEN
  1. . ;S ABSP("RX",MEDN,"Diagnosis Code")=$TR($$PRIMPOV^APCLV(VSITIEN,"C"),".","")
  1. . ; For paper forms, do not strip the "."
  1. . ; Strictly speaking, electronic claims should have stripped the "."
  1. . ; in the format code, not here in the fetch
  1. . S ABSP("RX",MEDN,"Diagnosis Code")=$$PRIMPOV^APCLV(VSITIEN,"C")
  1. Q
  1. ;
  1. ; $$RXRFN()
  1. ;Determine RX Refill Number based on prescription record
  1. ; It's overly cautious about making sure that the refills are
  1. ; counted in date filled order.
  1. ;
  1. ;Input Variables: RXIEN - Prescription record IEN (52)
  1. ; RXRFIEN - Refill multiple IEN
  1. ;
  1. ;Function Returns: Null - Could not process request
  1. ; 0 - Not a refill
  1. ; N - Refill number
  1. ; Copied into here from ABSPECD4 so we can remove ABSPECD4 from kit.
  1. ; Also called from ABSPOSN3
  1. ;----------------------------------------------------------------------
  1. RXRFN(RXIEN,RXRFIEN) ;EP
  1. ;Manage local variables
  1. N COUNT,DATE,XIEN,STOP
  1. ;
  1. ;Make sure input variables are defined
  1. Q:$G(RXIEN)="" ""
  1. Q:$G(RXRFIEN)="" ""
  1. ;
  1. ;Initialize local variables
  1. S (COUNT,STOP)=0
  1. ;
  1. ;Loop through refill multiple by date
  1. S DATE=""
  1. F D Q:'+DATE!(STOP)
  1. .S DATE=$O(^PSRX(RXIEN,1,"B",DATE))
  1. .Q:'+DATE
  1. .;
  1. .;For each sub-record increment refill count
  1. .S XIEN=""
  1. .F D Q:'+XIEN!(STOP)
  1. ..S XIEN=$O(^PSRX(RXIEN,1,"B",DATE,XIEN))
  1. ..Q:'+XIEN
  1. ..S COUNT=COUNT+1
  1. ..;
  1. ..;STOP when you reach the refill record
  1. ..S:XIEN=RXRFIEN STOP=1
  1. Q $S(STOP=1:COUNT,1:0)
  1. ;
  1. ; Retrieve OVERRIDE nodes and put into ABSP array
  1. ; They will be fetched from ABSP("OVERRIDE"
  1. ; during low-level construction of the actual encoded claim packet.
  1. ;
  1. OVERRIDE(IEN57,MEDN) ; set any ABSP("OVERRIDE" nodes from 9002313.511 data
  1. ; ABSP("OVERRIDE",field)=value for fields 101-401
  1. ; ABSP("OVERRIDE","RX",MEDN,field) for med #N, fields 402+
  1. ; Note that if you have multiple prescriptions bundled, the
  1. ; union of overrides from 101-401 apply to all; and if there's a
  1. ; conflict, the last one overwrites the previous ones.
  1. N IEN511 S IEN511=$P(^ABSPTL(IEN57,1),U,13) Q:'IEN511
  1. D GET511^ABSPOSO2(IEN511,"ABSP(""OVERRIDE"")","ABSP(""OVERRIDE"",""RX"","_MEDN_")")
  1. CC Q