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

PRCHITM5.m

Go to the documentation of this file.
PRCHITM5 ;OI&T/LKG - FILING DATA FROM NIF ;5/25/17  16:10
 ;;5.1;IFCAP;**198**;OCT 20, 2000;Build 6
 ;Per VA Directive 6402, this routine should not be modified.
 ;Integration agreements
 ; ICR #2051 FIND^DIC(), $$FIND1()^DIC
 ; ICR #2053 FILE^DIE(), UPDATE^DIE(), WP^DIE()
 ; ICR #2054 DT^DILF(), CLEAN^DILF
 ; ICR #2056 GETS^DIQ(), $$GET1^DIQ()
 ; ICR #10000 C^%DTC
 ; ICR #10103 $$DT^XLFDT
 ; ICR #10104 $$UP^XLFSTR()
 Q
FILE(PRCTRANNBR,PRCLINE,PRCITMC) ;
 N PRCCONTR,PRCIMF,PRCVEN,PRCNITM,PRCJ S PRCITMC=0
 D GETVEN(.PRCVEN) I PRCVEN=0 D ERR("Vendor not resolved for ST #"_PRCTRANNBR_" Line #"_PRCLINE_".") Q
 D GETITEM(.PRCIMF,.PRCNITM) I PRCIMF=0 D ERR("Item not resolved for ST #"_PRCTRANNBR_" Line #"_PRCLINE_".") Q
 S PRCJ=""
 F  S PRCJ=$O(PRCIMF(PRCJ)) Q:PRCJ=""  D
 . D ITEMFILE(PRCIMF(PRCJ),PRCVEN(1),PRCNITM) S PRCITMC=PRCITMC+1
 Q
 ;
ITEMFILE(PRCITMIEN,PRCVEND,PRCADDED) ;
 N PRCARR,PRCERR,PRCNEW,PRCX,PRCVENSK S PRCVENSK=0
 S PRCNEW=$S('$D(^PRC(441,PRCITMIEN,2,PRCVEND)):1,1:0) ; New vendor multiple entry
 D:'PRCADDED BACKUP(PRCITMIEN)
 I $G(^TMP($J,"PRCHITM3","ITEM","FSC"))=6505!($P($G(^TMP($J,"PRCHITM3","ITEM","NSN")),"-")=6505) D
 . I $G(^TMP($J,"PRCHITM3","ITEM","DRUG TYPE"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_PRCITMIEN_" is missing Drug Type although FSC 6505.")
 S PRCITMIEN=PRCITMIEN_","
 K PRCARR,PRCERR S PRCARR(441,PRCITMIEN,53)=$$DT^XLFDT
 D FILE^DIE("","PRCARR","PRCERR") K PRCARR,PRCERR
 I $G(^TMP($J,"PRCHITM3","ITEM","BOC"))'="" S PRCX=^("BOC") D
 . I '$D(^PRCD(420.2,PRCX,0)) D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_" BOC "_PRCX_" does not exist in file #420.2.") Q
 . N PRCARR,PRCERR
 . S PRCARR(441,PRCITMIEN,12)=PRCX
 . D FILE^DIE("K","PRCARR","PRCERR")
 . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE,$P(PRCITMIEN,","))
 I 'PRCADDED D
 . S:$G(^TMP($J,"PRCHITM3","ITEM","NIF#"))'="" PRCARR(441,PRCITMIEN,51)=^("NIF#")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","FSC"))'="" PRCARR(441,PRCITMIEN,2)=^("FSC")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","SHORT DESC"))'="" PRCARR(441,PRCITMIEN,.05)=$$UP^XLFSTR(^("SHORT DESC"))
 S:$G(^TMP($J,"PRCHITM3","ITEM","NSN"))'="" PRCARR(441,PRCITMIEN,5)=^("NSN")
 S:$G(^TMP($J,"PRCHITM3","ITEM","MFG PART"))'="" PRCARR(441,PRCITMIEN,19)=^("MFG PART")
 S:$G(^TMP($J,"PRCHITM3","ITEM","STOCK KEEPING UNIT"))'="" PRCARR(441,PRCITMIEN,21)=^("STOCK KEEPING UNIT")
 S:$G(^TMP($J,"PRCHITM3","ITEM","DRUG TYPE"))'="" PRCARR(441,PRCITMIEN,22)=^("DRUG TYPE")
 S:$G(^TMP($J,"PRCHITM3","ITEM","MANUFACTURER"))'="" PRCARR(441,PRCITMIEN,25)=$$UP^XLFSTR(^("MANUFACTURER"))
 S:$G(^TMP($J,"PRCHITM3","ITEM","SOURCE MFG PART#"))'="" PRCARR(441,PRCITMIEN,19.1)=^("SOURCE MFG PART#")
 S:$G(^TMP($J,"PRCHITM3","ITEM","NIF UPDATE DATE"))'="" PRCARR(441,PRCITMIEN,54)=$$DT2FMD(^("NIF UPDATE DATE"))
 D FILE^DIE("EK","PRCARR","PRCERR")
 D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE,$P(PRCITMIEN,",")) K PRCARR,PRCERR
 I '$D(^TMP($J,"PRCHITM3","ITEM","LONG DESC")) D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_" is missing Long Desc.")
 I $D(^TMP($J,"PRCHITM3","ITEM","LONG DESC")) D
 . D WP^DIE(441,PRCITMIEN,.1,"K","^TMP($J,""PRCHITM3"",""ITEM"",""LONG DESC"")","PRCERR")
 . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE,$P(PRCITMIEN,","))
 . K PRCARR,PRCERR
 ; Update supply stations
 I $O(^PRCP(445,"AH",$P(PRCITMIEN,","),""))]"" D BLDSEG^PRCPHLFM(3,$P(PRCITMIEN,","),0)
 D SYNONYM(PRCITMIEN)
 I PRCNEW D
 . N PRCIEN S PRCIEN(2)=PRCVEND
 . S PRCARR(441.01,"+2,"_PRCITMIEN,.01)=PRCVEND
 . S:$G(^TMP($J,"PRCHITM3","ITEM","UOP"))'="" PRCARR(441.01,"+2,"_PRCITMIEN,1.5)=^("UOP")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","UNIT COST"))'="" PRCARR(441.01,"+2,"_PRCITMIEN,1)=^("UNIT COST")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","PKG MULT"))'="" PRCARR(441.01,"+2,"_PRCITMIEN,1.6)=^("PKG MULT")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","UNIT CONVERSION FACTOR"))'="" PRCARR(441.01,"+2,"_PRCITMIEN,10)=^("UNIT CONVERSION FACTOR")
 . D UPDATE^DIE("E","PRCARR","PRCIEN","PRCERR")
 . I $D(PRCERR) D
 . . D ERR("Problem adding vendor entry to item for ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_".") D PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE,$P(PRCITMIEN,",")) S PRCVENSK=1
 . . I $G(^TMP($J,"PRCHITM3","ITEM","UOP"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_" is missing UOP.")
 . . I $G(^TMP($J,"PRCHITM3","ITEM","UNIT COST"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_" is missing Unit Cost.")
 . . I $G(^TMP($J,"PRCHITM3","ITEM","PKG MULT"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_" is missing Pkg Mult.")
 . . I $G(^TMP($J,"PRCHITM3","ITEM","UNIT CONVERSION FACTOR"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",")_" is missing Unit Conversion Factor.")
 . K PRCARR,PRCERR
 Q:PRCVENSK
 S PRCITMIEN=PRCVEND_","_PRCITMIEN ;Changing PRCITMIEN for Vendor subfile
 S:$G(^TMP($J,"PRCHITM3","ITEM","VSTOCK#"))'="" PRCARR(441.01,PRCITMIEN,3)=^("VSTOCK#")
 S:$G(^TMP($J,"PRCHITM3","ITEM","NDC"))'="" PRCARR(441.01,PRCITMIEN,4)=^("NDC")
 S:$G(^TMP($J,"PRCHITM3","ITEM","MIN QTY"))'="" PRCARR(441.01,PRCITMIEN,8)=^("MIN QTY")
 S:$G(^TMP($J,"PRCHITM3","ITEM","MAX QTY"))'="" PRCARR(441.01,PRCITMIEN,8.5)=^("MAX QTY")
 S:$G(^TMP($J,"PRCHITM3","ITEM","ORDER QTY MULTIPLE"))'="" PRCARR(441.01,PRCITMIEN,9)=^("ORDER QTY MULTIPLE")
 S:$G(^TMP($J,"PRCHITM3","ITEM","SOURCE VENDOR STOCK#"))'="" PRCARR(441.01,PRCITMIEN,3.1)=^("SOURCE VENDOR STOCK#")
 I 'PRCNEW D
 . S:$G(^TMP($J,"PRCHITM3","ITEM","UOP"))'="" PRCARR(441.01,PRCITMIEN,1.5)=^("UOP")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","UNIT COST"))'="" PRCARR(441.01,PRCITMIEN,1)=^("UNIT COST")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","PKG MULT"))'="" PRCARR(441.01,PRCITMIEN,1.6)=^("PKG MULT")
 . S:$G(^TMP($J,"PRCHITM3","ITEM","UNIT CONVERSION FACTOR"))'="" PRCARR(441.01,PRCITMIEN,10)=^("UNIT CONVERSION FACTOR")
 D FILE^DIE("EK","PRCARR","PRCERR")
 D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE,$P(PRCITMIEN,",",2))
 K PRCARR,PRCERR
 I $G(^TMP($J,"PRCHITM3","ITEM","CONTRACT"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",",2)_" is missing Contract.")
 I $G(^TMP($J,"PRCHITM3","ITEM","CONTRACT"))'="" S PRCX=^("CONTRACT") D
 . N PRCSCRN,PRCY S PRCSCRN="I $P($G(^(0)),U,2)=""""!($P($G(^(0)),U,2)'<"_$$DT^XLFDT()_")"
 . K PRCERR
 . S PRCY=$$FIND1^DIC(440.03,","_PRCVEND_",","BX",PRCX,"",PRCSCRN,"PRCERR")
 . I PRCY'>0 D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_$P(PRCITMIEN,",",2)_": The value '"_PRCX_"' for field CONTRACT in VENDOR SUB-FIELD in file ITEM MASTER is not valid.") Q
 . K PRCARR,PRCERR S PRCARR(441.01,PRCITMIEN,2)=PRCY
 . D FILE^DIE("K","PRCARR","PRCERR")
 . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE,$P(PRCITMIEN,",",2))
 . K PRCARR,PRCERR
 D CLEAN^DILF
 Q
 ;
GETVEN(PRCVEN) ;
 N PRCE,PRCLX S PRCVEN=0
 I $G(^TMP($J,"PRCHITM3","VEN","IEN"))'>0 D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" Vendor IEN missing or invalid.") Q
 I $G(^TMP($J,"PRCHITM3","VEN","IEN"))>0 S PRCVEN=1,PRCVEN(1)=^("IEN") D
 . I '$D(^PRC(440,PRCVEN(1),0)) D ERR("ST #"_PRCTRANNBR_": Vendor with Number "_PRCVEN(1)_" does not exist.") K PRCVEN(1) S PRCVEN=0 Q
 . S PRCLX=$$GET1^DIQ(440,PRCVEN(1)_",",.01)
 . I $$UP^XLFSTR($G(^TMP($J,"PRCHITM3","VEN","ORDER NAME")))'=PRCLX D  Q
 . . D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" Incoming and stored vendor names for ien "_PRCVEN(1)_" are")
 . . D ERR("  different '"_$G(^TMP($J,"PRCHITM3","VEN","ORDER NAME"))_"' versus '"_PRCLX_"'.")
 . . K PRCVEN(1) S PRCVEN=0
 Q
 ;
GETITEM(PRCIMF,PRCADD) ;
 N PRCNIF S PRCIMF=0,PRCADD=0
 I $G(^TMP($J,"PRCHITM3","ITEM","IMFNBR"))'>0 D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF# is missing or invalid.") Q
 I $G(^TMP($J,"PRCHITM3","ITEM","IMFNBR"))>0 S PRCIMF=1,PRCIMF(1)=^("IMFNBR") D
 . I $G(^TMP($J,"PRCHITM3","ITEM","NIF#"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_PRCIMF(1)_" is missing NIF#.")
 . I $D(^PRC(441,PRCIMF(1))) D  Q
 . . N PRCX,PRCY,PRCERR S PRCX=$G(^TMP($J,"PRCHITM3","ITEM","NIF#")),PRCY=$$GET1^DIQ(441,PRCIMF(1)_",",51,,,"PRCERR")
 . . I PRCX'="",PRCY'="",PRCX'=PRCY D
 . . . D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_": IMF #"_PRCIMF(1)_" exists but has different NIF#, "_PRCY)
 . . . D ERR("   not incoming value "_PRCX_". It will be updated.")
 . I '$D(^PRC(441,PRCIMF(1))) D
 . . L +^PRC(441,0):15 N PRCNBROLD S PRCNBROLD=$P($G(^PRC(441,0)),U,3)
 . . N PRCARR,PRCERR,PRCIENS S PRCARR(441,"+1,",.01)=PRCIMF(1)
 . . S PRCARR(441,"+1,",.05)=$$UP^XLFSTR($G(^TMP($J,"PRCHITM3","ITEM","SHORT DESC")))
 . . S PRCARR(441,"+1,",2)=$G(^TMP($J,"PRCHITM3","ITEM","FSC"))
 . . I PRCARR(441,"+1,",2)="" S PRCARR(441,"+1,",2)=$P($G(^TMP($J,"PRCHITM3","ITEM","NSN")),"-")
 . . S PRCARR(441,"+1,",51)=$G(^TMP($J,"PRCHITM3","ITEM","NIF#"))
 . . D UPDATE^DIE("E","PRCARR","PRCIENS","PRCERR") S PRCADD=1
 . . I $D(PRCERR) D  Q
 . . . D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_": Problem adding IMF entry #"_PRCIMF(1)_".") D PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE)
 . . . I $G(^TMP($J,"PRCHITM3","ITEM","SHORT DESC"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_PRCIMF(1)_" is missing Short Desc.")
 . . . I $G(^TMP($J,"PRCHITM3","ITEM","FSC"))="" D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_" IMF #"_PRCIMF(1)_" is missing FSC.")
 . . . K PRCIMF S PRCIMF=0,PRCADD=0
 . . I $G(PRCIMF(1))'=$G(PRCIENS(1)) D
 . . . I $G(PRCIENS(1))>0 D ERR("ST #"_PRCTRANNBR_" Line #"_PRCLINE_": Item assigned IMF# "_PRCIENS(1)_" instead of requested "_(PRCIMF(1))_".")
 . . . S PRCIMF(1)=$G(PRCIENS(1))
 . . S $P(^PRC(441,0),U,3)=PRCNBROLD L -^PRC(441,0)
 Q
 ;
DT2FMD(PRCDATE) ;
 ; Input date in YYMMDD format
 ; Returns date in VA FileMan date format if successful
 ;    or null value if input invalid
 N PRCARR,PRCERR,PRCOUT S PRCOUT=""
 S PRCDATE=$E(PRCDATE,3,4)_"/"_$E(PRCDATE,5,6)_"/"_$E(PRCDATE,1,2)
 D DT^DILF("X",PRCDATE,.PRCARR,,"PRCERR")
 S:'$D(PRCERR) PRCOUT=PRCARR
 Q PRCOUT
 ;
FMD(PRCDATE) ;
 ; Input external date and output VA FileMan date
 N PRCARR,PRCERR,PRCOUT S PRCOUT=""
 D DT^DILF("X",PRCDATE,.PRCARR,,"PRCERR")
 S:'$D(PRCERR) PRCOUT=PRCARR
 Q PRCOUT
 ;
BACKUP(PRCIEN) ;Backup Short Description and long Description
 ; Also add short description as Synonym if value not already present
 Q:'$D(^PRC(441,PRCIEN))
 N PRCARR,PRCERR,PRCX S PRCIEN=PRCIEN_","
 D GETS^DIQ(441,PRCIEN,".05;51;52","","PRCARR","PRCERR")
 I PRCARR(441,PRCIEN,52)="",PRCARR(441,PRCIEN,51)="" D
 . S PRCARR(441,PRCIEN,52)=PRCARR(441,PRCIEN,.05),PRCX=$E(PRCARR(441,PRCIEN,.05),1,36)
 . K PRCARR(441,PRCIEN,.05),PRCARR(441,PRCIEN,51),PRCERR
 . D FILE^DIE("EK","PRCARR","PRCERR")
 . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE)
 . K PRCARR,PRCERR
 . I '$$FIND1^DIC(441.05,","_PRCIEN,"X",PRCX,"","","PRCERR"),'$D(PRCERR) D
 . . S PRCARR(441.05,"+1,"_PRCIEN,.01)=PRCX
 . . D UPDATE^DIE("E","PRCARR","","PRCERR")
 . . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE)
 K PRCARR,PRCERR N PRCI S PRCI=$P(PRCIEN,",")
 I '$P($G(^PRC(441,PRCI,0)),"^",15),$P($G(^PRC(441,PRCI,8,0)),"^",4)'>0 D
 . I $P($G(^PRC(441,PRCI,1,0)),"^",4)>0 D
 . . D WP^DIE(441,PRCIEN,50,"","^PRC(441,PRCI,1)","PRCERR")
 . . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE)
 Q
 ;
SYNONYM(PRCIEN) ;
 N PRCI S PRCI=""
 F  S PRCI=$O(^TMP($J,"PRCHITM3","ITEM","SYN",PRCI)) Q:PRCI=""  S PRCX=^(PRCI) D
 . N PRCARR,PRCERR
 . I '$$FIND1^DIC(441.05,","_PRCIEN,"X",PRCX,"","","PRCERR"),'$D(PRCERR) D
 . . S PRCARR(441.05,"+1,"_PRCIEN,.01)=PRCX
 . . D UPDATE^DIE("E","PRCARR","","PRCERR")
 . . D:$D(PRCERR) PROCERRS(.PRCERR,PRCTRANNBR,PRCLINE)
 Q
INITLOG(PRCTXNID) ; Initialize error log
 N PRCDT,X1,X2,X,%H
 S PRCERRC=0,PRCHNODE="PRCHITM3;"_PRCTXNID K ^XTMP(PRCHNODE)
 ; Setting up ^XTMP header node including automatic purge date
 S PRCDT=$$DT^XLFDT,X1=PRCDT,X2=30 D C^%DTC S ^XTMP(PRCHNODE,0)=X_"^"_PRCDT_"^"_"NIF Item Add/Update"
 Q
 ;
PROCERRS(PRCE,PRCT,PRCL,PRCIMF) ; Process errors in DIERR
 N PRCI,PRCK,PRCM S PRCK=$P($G(PRCE("DIERR")),"^") Q:+PRCK'>0
 F PRCI=1:1:PRCK S PRCM=$G(PRCE("DIERR",PRCI,"TEXT",1)) I PRCM'="" S PRCM="ST #"_PRCT_" Line #"_PRCL_$S($G(PRCIMF)>0:" IMF #"_PRCIMF,1:"")_": "_PRCM D ERR(PRCM)
 Q
ERR(PRCMSG) ; Error processing
 S PRCERRC=PRCERRC+1 S ^XTMP(PRCHNODE,"ERR",PRCERRC)=PRCMSG
 Q
 ;
 ;PRCHITM5