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

PSAVER7.m

Go to the documentation of this file.
  1. PSAVER7 ;BIR/JMB-Verify Invoices - CONT'D ;7/23/97
  1. ;;3.0;DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**12,21,42,56,64,66,76**; 10/24/97;Build 1
  1. ;Background Job
  1. ;This routine increments pharmacy location and master vault balances
  1. ;in 58.8 after invoices have been verified. This routine is called
  1. ;by PSAVER6.
  1. ;
  1. ;References to ^PSDRUG( are covered by IA #2095
  1. TR ;File transaction data in 58.81
  1. I $D(PSADUREC),'PSADUREC Q ;*56 block '0' quantity edits
  1. I $D(PSAQTY),'PSAQTY Q ;*56 block '0' quantity edits
  1. F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. FIND S PSAT=$P(^PSD(58.81,0),"^",3)+1 I $D(^PSD(58.81,PSAT)) S $P(^PSD(58.81,0),"^",3)=$P(^PSD(58.81,0),"^",3)+1 G FIND
  1. S DIC="^PSD(58.81,",DIC(0)="L",DLAYGO=58.81,(DINUM,X)=PSAT D ^DIC K DIC,DINUM,DLAYGO L -^PSD(58.81,0)
  1. S DIE="^PSD(58.81,",DA=PSAT,DR="1////1;2////^S X=PSALOC;3////^S X=PSADT;4////^S X=PSADRG;5////^S X=PSADUREC;6////^S X=PSAVDUZ;9////^S X=PSABAL;71////^S X=PSAINV;106////^S X=PSAORD"
  1. I $G(PSACS) S DR=DR_";100////^S X=PSACS"
  1. F L +^PSD(58.81,DA,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. D ^DIE L -^PSD(58.81,DA,0) K DIE
  1. S:'$D(^PSD(58.8,PSALOC,1,PSADRG,4,0)) DIC("P")=$P(^DD(58.8001,19,0),"^",2)
  1. S DA(2)=PSALOC,DA(1)=PSADRG,(X,DINUM)=PSAT,DIC="^PSD(58.8,"_DA(2)_",1,"_DA(1)_",4,",DIC(0)="L",DLAYGO=58.8
  1. F L +^PSD(58.8,PSALOC,1,PSADRG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. D ^DIC L -^PSD(58.8,PSALOC,1,PSADRG,0) K DIC,DINUM,DLAYGO
  1. ;
  1. 50 S PSAODASH=$P($G(^PSDRUG(PSADRG,2)),"^",4)
  1. S PSAONDC=$P(PSAODASH,"-")_$P(PSAODASH,"-",2)_$P(PSAODASH,"-",3)
  1. ;(PSA*3*21) NDC & PRICING UPDATES (DAVE BLOCKER 10NOV99)
  1. S PSADUOU=$S($G(PSADUOU)'>0:1,1:PSADUOU)
  1. S PSADUREC=(PSAQTY*PSADUOU)
  1. S DIE="^PSDRUG(",DA=PSADRG,DR="50////^S X="_(PSADUREC+$G(^PSDRUG(PSADRG,660.1)))
  1. F L +^PSDRUG(DA,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. D ^DIE L -^PSDRUG(DA,0) K DIE,DA,DR
  1. ;This section replaces most of the routine
  1. ;PSAOU = order unit from invoice
  1. ;PSAPOU & PSANPOU = Price of Order Unit from invoice
  1. ;PSADUOU=Dispense Units per OU form invoice data
  1. ;PSANPDU= Price of Dispense Units per Order Unit
  1. ;
  1. ;Drug file Information
  1. K DRUG
  1. S PSANODE=$G(^PSDRUG(PSADRG,660))
  1. F X=2,3,5,6 S DRUG(X)=$P($G(PSANODE),"^",X)
  1. ;
  1. S PSANPDU=$J(($G(PSAPOU)/$G(PSADUOU)),0,4) ;Price of Order Unit divide by Disp. Units per Order Unit
  1. ;PSA*3*42 |> (let changes happen and file, put changes into mail message)
  1. S DIE="^PSDRUG(",(DA,OLDDA)=PSADRG,DR="12////^S X=PSAOU;15////^S X=PSADUOU;16///^S X=PSANPDU;13////^S X=PSAPOU" ;*42;*56;*76
  1. F L +^PSDRUG(DA,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. D ^DIE K DIE,DA,DR
  1. ; <| PSA*42
  1. PTCH21 ;PSA*3*21 (Vendor's VSN changing to 8 digits, check also)
  1. ;If NDC or VSN changes should it create to synonym entry ?
  1. I $G(^PSDRUG(PSADRG,1,PSASUB,0))="" G NDC
  1. I $G(^PSDRUG(PSADRG,1,PSASUB,0)) S PSAEDTT=0,DATA=^PSDRUG(PSADRG,1,PSASUB,0) D
  1. .I PSAVSN'=$P(DATA,"^",4) S PSAEDTT=1 ;VSN
  1. .I PSAPOU'=$P(DATA,"^",6) S PSAEDTT=1 ;Price per order unit
  1. .I PSADUOU'=$P(DATA,"^",7) S PSAEDTT=1 ;Dispense Units per Order Unit
  1. .I PSANPDU'=$P(DATA,"^",8) S PSAEDTT=1 ;New Price per dispense unit
  1. .I $G(PSAEDTT)>0 D
  1. ..S DA=PSASUB,DA(1)=PSADRG,DIE="^PSDRUG("_DA(1)_",1,"
  1. ..S DR="2////^S X=PSADASH"_$S(PSACS:";1////C",1:";1////D")_";400////^S X=PSAVSN;401////^S X=PSAOU"_$S(+PSAPOU:";402////^S X=PSAPOU",1:"")_";403////^S X=PSADUOU"_";404///^S X=PSANPDU"_";405///^S X=PSAVEND"
  1. ..D ^DIE K DIE,DR,DA
  1. NDC ;NDC UPDATE
  1. I PSANDC'="",PSANDC'=PSAONDC D ;*42
  1. .S DIE="^PSDRUG(",DA=PSADRG,DR="31////^S X=PSADASH"
  1. .F L +^PSDRUG(DA,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. .D ^DIE L -^PSDRUG(DA,0) K DIE,DA,DR
  1. SYNONYM ;Adds/edits the SYNONYM multiple in DRUG file >>*66 RJS
  1. G:PSANDC="" END
  1. S DA(1)=PSADRG ;; << *66 RJS
  1. ;
  1. S PSANPDU=$J(($G(PSAPOU)/$G(PSADUOU)),0,4) ;Price of Order Unit divide by Disp. Units per Order Unit ;*76
  1. S:'$D(^PSDRUG(PSADRG,1,0)) DIC("P")="50.1A"
  1. ; *56 Search for earliest best match of synonyms, start at bottom go up
  1. ; if VSN use it, if several VSNs use the first, IF VSN match NDCs must match also.
  1. ; if no VSN, make a new synonym
  1. ; no "B" synonym index exists
  1. T0 N PSYNDA,PSYN0,PSTNDC,PSTVSN,PSMNDC,PSMBTH S (PSMNDC,PSMBTH)=0
  1. S PSYNDA="" F S PSYNDA=$O(^PSDRUG(PSADRG,1,PSYNDA),-1) Q:PSYNDA'>0 D
  1. . S PSYN0=^PSDRUG(PSADRG,1,PSYNDA,0),PSTNDC=$P(PSYN0,U),PSTVSN=$P(PSYN0,U,4) ;zero node, test values of NDC VSN
  1. . I PSTNDC'=PSANDC Q
  1. . I PSTVSN=PSAVSN S PSMBTH=PSYNDA Q ;both VSN & NDC matches
  1. T1 S PSASUB=$S(PSMBTH:PSMBTH,1:0) ;PSAMBTH Match both vsn,ndc
  1. ;end *56
  1. I 'PSASUB!(PSASUB&('$D(^PSDRUG(PSADRG,1,PSASUB,0)))) D
  1. .S DIC="^PSDRUG("_DA(1)_",1,",DIC(0)="Z",X=PSANDC,DLAYGO=50
  1. .F L +^PSDRUG(PSADRG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. .D FILE^DICN L -^PSDRUG(PSADRG,0) K DIC,DLAYGO S PSASUB=+Y
  1. .K DIC,DA,DR,DIE
  1. I PSASUB,$D(^PSDRUG(PSADRG,1,PSASUB,0)) S DA=PSASUB
  1. S DA(1)=PSADRG,DIE="^PSDRUG("_DA(1)_",1,"
  1. S DR="2////^S X=PSADASH"_$S($G(PSACS)>0:";1////C",1:";1////D")_";400////^S X=PSAVSN;401////^S X=PSAOU"_$S(+PSAPOU:";402////^S X=PSAPOU",1:"")_";403////^S X=PSADUOU"_";404///^S X=PSANPDU;405///^S X=PSAVEND"
  1. F L +^PSDRUG(PSADRG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
  1. D ^DIE L -^PSDRUG(PSADRG,0)
  1. K DIE,DR,X1,X2,DATA
  1. END ; FINAL CLEANUP << *66 RJS
  1. L -^PSDRUG(OLDDA,0) K OLDDA ;; >> *66 RJS
  1. Q