source: WorldVistAEHR/trunk/r/DRUG_ACCOUNTABILITY-PSA/PSAPTCH.m@ 1361

Last change on this file since 1361 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.2 KB
Line 
1PSAPTCH ;BHM/DAV - FIND INVOICES PROCESSED BY CONTROLLED SUBS;
2 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**21**; 10/24/97
3 ;CS() = array contains item numbers of processed CS invoice
4 ;PSACSERR =error flag set
5 ;
6 D Q
7 ;
81 ;Check for uploaded CS invoice
9 ;PSAIN=^XTMP("PSAPV",PSACTRL,"IN")
10 S PSAUPORD=$P(PSAIN,"^",4) ;Incoming Order Number
11 S PSAUPINV=$P(PSAIN,"^",2) ;Incoming Invoice Number
12 I $G(PSAUPORD)="" K ^XTMP("PSAPV",PSACTRL) S PSAINVDL=1 Q
13 I $G(PSAUPINV)="" K ^XTMP("PSAPV",PSACTRL) S PSAINVDL=1 Q
14 I $L(PSAIN)'>10 K ^XTMP("PSAPV",PSACTRL) S PSAINVDL=1 Q
15 S Y=$P(PSAIN,"^",1) X ^DD("DD") S PSAUPDT1=Y ;Invoice Date
16 S Y=$P(PSAIN,"^",3) X ^DD("DD") S PSAUPDT2=Y ;Order Date
17 S INVITM=0 F S INVITM=$O(^XTMP("PSAPV",PSACTRL,"IT",INVITM)) Q:INVITM'>0 S INV(INVITM)=^XTMP("PSAPV",PSACTRL,"IT",INVITM),INVCNT=$G(INVCNT)+1
18 I '$D(^PSD(58.811,"AORD",PSAUPORD,PSAUPINV)) G Q
19 W @IOF,!,"** WARNING **",!!,"P.O. Number : ",PSAUPORD,!,"Invoice Number : ",PSAUPINV,!
20 K PSAORD,ORDIEN,INVIEN,CSINV
21 S ORDIEN=$O(^PSD(58.811,"AORD",PSAUPORD,PSAUPINV,0)) ;Order # IEN
22 S INVIEN=$O(^PSD(58.811,"AORD",PSAUPORD,PSAUPINV,ORDIEN,0)) ;Invoice # IEN
23 S PSDCNT=0,X=0 F S X=$O(^PSD(58.811,ORDIEN,1,INVIEN,1,X)) Q:X'>0 S PSDCNT=$G(PSDCNT)+1
24 ;
25 S PSASTAS=$P($G(^PSD(58.811,ORDIEN,1,INVIEN,0)),"^",3),PSASTAS=$S(PSASTAS="P":"PROCESSED",PSASTAS="V":"VERIFIED",PSASTAS="C":"COMPLETED",1:"UNKNOWN")
26 W !,"Incoming",?40,"Already Marked as "_" * "_PSASTAS_" *",!,"Invoice file",?40,"in Drug Accountability Order file",! F X=1:1:(IOM-1) W "="
27 S Y=$P($G(^PSD(58.811,ORDIEN,1,INVIEN,0)),"^",4) X ^DD("DD") W !,PSAUPDT2,?16," <-- Order Date --> ",?40,Y
28 S Y=$P($G(^PSD(58.811,ORDIEN,1,INVIEN,0)),"^",2) X ^DD("DD") W !,PSAUPDT1,?15," <-- Invoice Date --> ",?40,Y
29CHECK W !,?3,$J($G(INVCNT),8),?16," <-- Line Items -->",?40,$G(PSDCNT),!!
30 ;
31CMPRE R !,"Do you want to compare item? NO// ",AN:DTIME I AN["^"!(AN="") G ASK
32 S AN=$E(AN) I "yYnN"'[AN W !,"Answer 'Y'es to display the items from the invoice file, as well as the items",!,"already uploaded.",! G CMPRE
33 I "nN"[AN G ASK
34 S X=0 F S X=$O(^XTMP("PSAPV",PSACTRL,"IT",X)) Q:X="" S DATA=$G(^XTMP("PSAPV",PSACTRL,"IT",X)),PSAITM(+DATA)=DATA
35 S X=0 F S X=$O(^PSD(58.811,ORDIEN,1,INVIEN,1,X)) Q:X="" S DATA=$G(^PSD(58.811,ORDIEN,1,INVIEN,1,X,0)),PSAUPITM(+DATA)=DATA
36 ;
37ASK R !!,"Do you want to delete the incoming invoice ? NO// ",AN:DTIME G Q:AN["^" I "Nn"[AN G Q
38 I "?"[AN W !!,"Answer 'Y'es, and the incoming invoice will be deleted.",! G ASK
39 I AN="" G Q
40 I "Yy"[AN K ^XTMP("PSAPV",PSACTRL) S PSAINVDL=1 Q
41 ;
42 ;Kill incoming invoice.
43Q K AN,CS,CSCNT,CSIEN,CSINV,DATA,FOUND,INV,INVCNT,INVDEL,INVIEN,INVITM,LINEITM,ORDIEN,PSAORD,PSAUPDT1,PSAUPDT2,PSAUPINV,PSAUPORD,PSDCNT,X,XX,Y Q
44PSAOLD ;Entry point for deleting old invoices
45 I '$D(^XTMP("PSAPV")) W !,"Sorry, there aren't any invoices on file." G Q
46ASKDT S %DT="A",%DT("A")="Delete invoices older than what date: " D ^%DT
47 I Y'<DT W !,"Sorry, the date has to be in the past." K Y G ASKDT
48 S PSAKLDT=Y
49 ;
50 S PSACTRL=0 F S PSACTRL=$O(^XTMP("PSAPV",PSACTRL)) Q:PSACTRL'>0 S DATA=$G(^XTMP("PSAPV",PSACTRL,"IN")) D
51 .I $G(DATA)="" Q
52 .S PSAINVDT=$P(^XTMP("PSAPV",PSACTRL,"IN"),"^",1)
53 .I PSAINVDT<PSAKLDT K ^XTMP("PSAPV",PSACTRL) W "."
54 W !,"Finished" K PSACTRL,PSAINVDT,PSAKLDT Q
Note: See TracBrowser for help on using the repository browser.