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

ABSPOSN2.m

Go to the documentation of this file.
ABSPOSN2 ; IHS/FCS/DRS - NCPDP Fms F ILC A/R ;  [ 09/12/2002  10:16 AM ]
 ;;1.0;PHARMACY POINT OF SALE;**3**;JUN 21, 2001;Build 38
 ;----------------------------------------------------------------------
 ;----------------------------------------------------------------------
PBITEM(BITEMIEN) ;EP
 ;Manage local variables
 N PATIEN,LITEMIEN,VSTIEN,IADTINS,IADTTYP,INSDATA,VMEDS,SVMEDS,DATEW
 N NMEDS,NFORMS,INDEX,START,END,PATINFO,INSINFO,PHARINFO,DRUGINFO
 N INSTYPE
 N PCNDFN S PCNDFN=BITEMIEN
 ;
 ;Make sure input variables are defined
 Q:$G(BITEMIEN)=""
 Q:'$D(^ABSBITMS(9002302,BITEMIEN,0))
 ;
 S PATIEN=$P($G(^ABSBITMS(9002302,BITEMIEN,0)),U,2)
 Q:PATIEN=""
 Q:'$D(^DPT(PATIEN,0))
 ;
 S LITEMIEN=$O(^ABSBITMS(9002302,BITEMIEN,1,0))
 Q:'+LITEMIEN
 ;
 S VSTIEN=$P($G(^ABSBITMS(9002302,BITEMIEN,1,LITEMIEN,0)),U,3)
 Q:VSTIEN=""
 Q:'$D(^AUPNVSIT(VSTIEN,0))
 ;
 S DIPA("VCN")=$P($G(^ABSBITMS(9002302,BITEMIEN,"VCN")),U,1)
 ;
 ; INSurance: S IADTINS,IADTTYP,INSDATA,INSTYPE
 ;      
 S IADTINS=$P($G(^ABSBITMS(9002302,BITEMIEN,0)),U,4)
 I 'IADTINS S IADTINS=1 ; DRS; 04/13/2000
 I $D(^ABSBITMS(9002302,BITEMIEN,"INSCOV1")) D
 . K IADTTYPE ; no longer applicable
 . M INSDATA=^ABSBITMS(9002302,BITEMIEN,"INSCOV1",IADTINS)
 . S INSTYPE="INSCOV1"
 E  D  ; Old INSCOV data structures
 . S IADTTYP=$O(^ABSBITMS(9002302,BITEMIEN,"INSCOV",IADTINS,""))
 . ;Q:IADTTYP'="PRVT"
 . ;added INSNXT stuff to get past private INS only
 . N INSNXT
 . S INSNXT=$O(^ABSBITMS(9002302,BITEMIEN,"INSCOV",IADTINS,""))
 . Q:INSNXT=""
 . S INSDATA=$G(^ABSBITMS(9002302,BITEMIEN,"INSCOV",IADTINS,INSNXT,0))
 . S INSTYPE=INSNXT ;="PRVT" or "CAID" or...
 . ; what INSDATA means depENDs on INSTYPE
 ;
 D GETVMED(BITEMIEN,.VMEDS)
 Q:+$G(VMEDS(0))=0
 ;I BITEMIEN=130417,+$H=58185 U $P ZW VMEDS R ">>>",%
 ;Get PATient, INSurer, and PHARmacy inFmation
 D PATINFO^ABSPOSN3(PATIEN,.PATINFO)
 D INSINFO^ABSPOSN3(.INSDATA,.INSINFO,INSTYPE)
 D PHARINFO^ABSPOSN3(.PHARINFO,$P(VMEDS(1),U,6))
 ;
 ;Sort V Medications by DATE RX Written
 D SORTVMED(.VMEDS,.SVMEDS)
 ;I BITEMIEN=130417,+$H=58185 U $P ZW SVMEDS R ">>>",%
 Q:'$D(SVMEDS)
 U IO
 S DATEW=0
 F  D  Q:'+DATEW
 .S DATEW=$O(SVMEDS(DATEW))
 .Q:'+DATEW
 .S NMEDS=+$G(SVMEDS(DATEW,0))
 .Q:NMEDS=0
 .S NFORMS=((NMEDS-1)\2)+1
 .F INDEX=1:1:NFORMS D
 ..S START=((INDEX-1)*2)+1
 ..S END=START+2-1
 ..S:END>NMEDS END=NMEDS
 ..K DRUGINFO
 ..S DRUGINFO(0)=$S(START=END:1,1:2)
 ..;D DRUGINFO^ABSPOSN3(VMEDS(START),1,.DRUGINFO)
 ..;D:'(START=END) DRUGINFO^ABSPOSN3(VMEDS(END),2,.DRUGINFO)
 ..D DRUGINFO^ABSPOSN3(VMEDS(SVMEDS(DATEW,START)),1,.DRUGINFO)
 ..D:START'=END DRUGINFO^ABSPOSN3(VMEDS(SVMEDS(DATEW,END)),2,.DRUGINFO)
 ..D PFM^ABSPOSN6
 Q
 ;----------------------------------------------------------------------
 ;Given a Billing ITEMs Record IEN number, this routine loops through
 ;the V CPT multiple and returns all V Medication ITEMs.
 ;
 ;Parameters:  BITEMIEN  - Billing ITEMs IEN (9002302)
 ;            .VMEDS     - Array of V Medication IEN #s (9000010.14)
 ;                         VMEDS(0) = <Total Number>
 ;                         VMEDS(N) = <V Medication IEN>
 ;----------------------------------------------------------------------
GETVMED(BITEMIEN,VMEDS) ;
 ;Manage local variables
 N NEXT,COUNT,VCPTIEN,RXIEN,RXRFIEN,VMEDIEN,RXWDATE,F57IEN
 ;
 ;Make sure input varaibles are defined
 Q:$G(BITEMIEN)=""
 Q:'$D(^ABSBITMS(9002302,BITEMIEN,0))
 ;
 S (NEXT,COUNT)=0
 F  D  Q:'+NEXT
 .S NEXT=$O(^ABSBITMS(9002302,BITEMIEN,"VCPT",NEXT))
 .Q:'+NEXT
 .;
 .S VCPTIEN=$P($G(^ABSBITMS(9002302,BITEMIEN,"VCPT",NEXT,0)),U,1)
 .Q:VCPTIEN=""
 .Q:'$D(^ABSVCPT(9002301,VCPTIEN,0))
 .;
 .;
 .S VMEDIEN=$P($G(^ABSVCPT(9002301,VCPTIEN,"SPEC")),U,2)
 .S RXIEN=$P($G(^ABSVCPT(9002301,VCPTIEN,"SPEC")),U,1) ;12.29.99
 .S F57IEN=$P($G(^ABSVCPT(9002301,VCPTIEN,"SPEC")),U,4) ;04/20/2000
 .I F57IEN S RXRFIEN=$P($G(^ABSPTL(F57IEN,1)),U)
 .I RXIEN,'VMEDIEN S VMEDIEN=$P($G(^PSRX(RXIEN,999999911)),U,1)
 .;
 .I VMEDIEN=""&('RXIEN) D  Q
 . . S VDATE=$P($G(^ABSVCPT(9002301,VCPTIEN,"BATCH")),U,7)
 . . S COUNT=COUNT+1
 . . S $P(VMEDS(COUNT),U,5)=VCPTIEN
 . . S $P(VMEDS(COUNT),U,4)=VDATE
 . . S VMEDS(0)=COUNT
 .;
 .;Q:'$D(^AUPNVMED(VMEDIEN,0))
 .;
 .I VMEDIEN&('RXIEN) D
 . . S RXIEN=$O(^PSRX("APCC",VMEDIEN,""))
 . . Q:RXIEN=""
 .I VMEDIEN,RXIEN,'$G(RXRFIEN) S RXRFIEN=$O(^PSRX("APCC",VMEDIEN,RXIEN,""))
 .;
 .Q:'RXIEN
 .Q:'$D(^PSRX(RXIEN,0))
 .;
 .;Determine RX Written DATE
 .S RXWDATE=$P($G(^PSRX(RXIEN,0)),U,13)
 .;Q:RXWDATE=""
 .S RXWDATE=$S(RXWDATE'="":RXWDATE,1:VDATE)
 .S COUNT=COUNT+1
 .S VMEDS(COUNT)=$G(VMEDIEN)_U_$G(RXIEN)_U_$G(RXRFIEN)_U_RXWDATE_U_VCPTIEN_U_F57IEN
 ;
 S VMEDS(0)=COUNT
 Q
 ;---------------------------------------------------------------------
SORTVMED(VMEDS,SVMEDS) ;
 ;Manage local varables
 N INDEX,DATE
 ;
 Q:$G(VMEDS(0))=""
 ;
 F INDEX=1:1:VMEDS(0) D
 .S DATE=$P($G(VMEDS(INDEX)),U,4)
 .Q:DATE=""
 .S SVMEDS(DATE,0)=$G(SVMEDS(DATE,0))+1
 .S SVMEDS(DATE,SVMEDS(DATE,0))=INDEX
 Q