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

PSABRKU9.m

Go to the documentation of this file.
  1. PSABRKU9 ;VMP/PW-ORDER UNIT AUTO UPDATE FOR MCKESSON ;9/19/2004
  1. ;;3.0;DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**48**;10/24/97
  1. ;routine to be identical to PSAUP8
  1. ;References to ^PSDRUG( are covered by IA #2095
  1. Q
  1. OUAUTO ;EP for Order Unit Auto Update from PSABRKU6
  1. ; needs PSACTRL PSALINE from PSABRKU6
  1. ; PSAI - invoice PSAD - drug
  1. EN N DRDA,DROUDA,DROUNM,DRDUOU,INVOUNM,INVOUDA,INVDUOU,XX
  1. N PSADATA,VSNDUOU,VSNDRDA,VSDSYNDA,VSNDRD0,VSNSYND0,VCNT
  1. N INVOUNM,SYNDA,IVSN,IVSN0,SYN0,SYNDUOU,SYNIEN,VSNIEN,VSNSYNDA
  1. S PSADATA=^XTMP("PSAPV",PSACTRL,"IT",PSALINE)
  1. S PSADATA=$$PSADATA()
  1. S ^XTMP("PSAPV",PSACTRL,"IT",PSALINE)=PSADATA ;adj invoice OU, DUOU w postmaster
  1. Q
  1. PSADATA() ;extrensic return PSADATA modified
  1. S XX=PSADATA,(VSNDUOU,SYNDUOU,DRDUOU)=""
  1. S INVOUNM=$P(XX,U,2) S:INVOUNM["~" INVOUNM=$P(INVOUNM,"~")
  1. S DRDA=$P(XX,U,6),SYNDA=$P(XX,U,7),IVSN0=$P(XX,U,5)
  1. S DRDUOU=$$GET1^DIQ(50,DRDA,15)
  1. VSN ;set VSNDUOU= PSDRUG( unique VSN value or XTMP( value
  1. S IVSN=$S(IVSN0["~":$P(IVSN0,"~"),1:IVSN0)
  1. S (VSNDRDA,VCNT)=0 F S VSNDRDA=$O(^PSDRUG("AVSN",IVSN,VSNDRDA)) Q:VSNDRDA'>0 D
  1. .S VSNSYNDA=0 F S VSNSYNDA=$O(^PSDRUG("AVSN",IVSN,VSNDRDA,VSNSYNDA)) Q:VSNSYNDA'>0 S VCNT=VCNT+1 S VSNDRD0=VSNDRDA,VSNSYND0=VSNSYNDA
  1. I ((IVSN0["~")!(VCNT'=1)) I $D(^XTMP("PSAVSN",IVSN)) S VSNDUOU=^(IVSN) I 1
  1. E D
  1. .I VCNT'=1 Q
  1. .; FYI both SYN and VSN values should be comming from the same Synonym
  1. .S VSNIEN=VSNSYND0_","_VSNDRD0
  1. .S VSNDUOU=$$GET1^DIQ(50.1,VSNIEN,403)
  1. I VSNDUOU="",$D(^XTMP("PSAVSN",IVSN)) S VSNDUOU=^(IVSN)
  1. ;
  1. SYNDUOU ;set SYNDUOU= to PSDRUG( or XTMP value
  1. S SYNIEN=SYNDA_","_DRDA
  1. S SYNDUOU=$$GET1^DIQ(50.1,SYNIEN,403)
  1. I '$L(SYNDUOU),$D(^XTMP("PSAVSN",IVSN)) S SYNDUOU=^(IVSN) D
  1. . I SYNDUOU'=DRDUOU Q
  1. . L +^PSDRUG(DRDA,1,SYNDA,0):10 Q:'$T
  1. . S SYN0=^PSDRUG(DRDA,1,SYNDA,0)
  1. . S $P(SYN0,U,7)=SYNDUOU,^PSDRUG(DRDA,1,SYNDA,0)=SYN0
  1. . L -^PSDRUG(DRDA,1,SYNDA,0)
  1. ;
  1. TESTDUOU ; test if DUOUs are =
  1. I VSNDUOU=SYNDUOU,SYNDUOU=DRDUOU I 1
  1. E D G Q ; DUOUs '= but maybe VSN & SYN agree, set into IT
  1. . I '$L(VSNDUOU) Q
  1. . I VSNDUOU=SYNDUOU S $P(XX,U,20)=VSNDUOU,PSADATA=XX
  1. SETDUOU S $P(XX,U,20)=DRDUOU,PSADATA=XX ;set DUOU into PSAPV "IT"
  1. ;test for OU change
  1. CHKOU S DROUNM=$$GET1^DIQ(50,DRDA,12)
  1. S DROUDA=$$GET1^DIQ(50,DRDA,12,"I")
  1. I $E(INVOUNM,1,2)'="EA" G Q
  1. S $P(XX,U,12)=DROUDA,$P(XX,U,13)=.5,$P(XX,U,14)=DT
  1. S PSADATA=XX
  1. Q ;W ! ZW VSNDUOU,SYNDUOU,DRDUOU,PSADATA W !
  1. Q PSADATA