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

BARUFEX.m

Go to the documentation of this file.
BARUFEX ; IHS/SD/TPF - MAIN EXTRACT RTN FOR UFMS ; 09/19/2008
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**3,4,6,7**;OCT 26, 2005
 ;Heavily modified to prevent duplicate records ;MRS:BAR*1.8*7 IM30562
 ;GETDATA MOVED TO NEW ROUTINE BARUFEX1 created to meet SAC size requirements  ;MRS:BAR*1.8*7
 ;New functionality only enters through single PULLSESS EP ;MRS:BAR*1.8*7 IM30562
 Q
 ;
PULLSESS(UDUZ,SESSID) ;EP - PULL TRANSACTIONS LOGGED UNDER THIS SESSION
 N TRDATE,TRAILER,NOTSENT,BAROLD,BARNOW
 K ^BARUFEX($J)
 S RC=$$ASKFNAME^BARUFUT1(.BARFILE)
 I 'RC W !!,"SESSION NOT TRANSMITTED" D ASKFORRT^BARUFUT Q 0
 S (RECORD,TOTAMT)=0
 I $D(SESSID)'=1 D  Q $D(^BARUFEX($J))_U_BARFILE
 .S BAROLD=$$OLD(.SESSID)               ;CAPTURE OLDEST DATE BAR*1.8*4
 .S REC=""
 .F  S REC=$O(SESSID(REC)) Q:REC=""  D
 ..S UDUZ=$P(SESSID(REC),U)
 ..S SESSID=$P(SESSID(REC),U,2)
 ..I '$$LCK(UDUZ,SESSID) Q               ;MRS:BAR*1.8*7 IM30562
 ..I SESSID<BAROLD S BAROLD=SESSID       ;CAPTURE OLDEST DATE
 ..D DT(UDUZ,SESSID,BAROLD)
 .S:$D(^BARUFEX($J)) TRAILER=$$TRAILER()
 E  D  Q $D(^BARUFEX($J))_U_BARFILE
 .I '$$LCK(UDUZ,SESSID) Q                ;MRS:BAR*1.8*7 IM30562
 .D DT(UDUZ,SESSID,SESSID)
 .S:$D(^BARUFEX($J)) TRAILER=$$TRAILER()
 Q $D(^BARUFEX($J))_U_BARFILE
 ;
DT(UDUZ,SESSID,BAROLD) ;EP - HEAVILY MODIFIED FOR BAR*1.8*4 SCR80 1.4.1
 ;CHECK FOR TRANSACTIONS NOT SENT
 ;D NOTSENT(.RECORD,.TOTAMT)     ;ONLY CHECK ONCE
 S CURSTAT=$$CURSTAT^BARUFUT(UDUZ,SESSID)    ;MRS:BAR*1.8*6 IM29616
 Q:CURSTAT'="REVIEWED/APPROVED"              ;MRS:BAR*1.8*6 IM29616
 D NOW^%DTC
 S BARNOW=%
 S BARB=$P(SESSID,".")-.0001
 S BARDUZ=DUZ                    ;CASHIER
 I '$G(NOTSENT) D
 .D PRE^BARUFEX5(BAROLD,BARDUZ)     ;CREATE ^BARBOB GLOBAL ONCE
 .D NOTSENT(.RECORD,.TOTAMT) S NOTSENT=1  ;ONLY CHECK ONCE
 .W !,"FINISHED CHECKING 'NOT SENT' TRANSACTIONS"
 W !!,"PROCESSING SESSION TRANSACTIONS FOR "_$P(^VA(200,UDUZ,0),U)_": "_SESSID
 S TRDATE=0
 F  S TRDATE=$O(^BARSESS(DUZ(2),UDUZ,11,SESSID,2,TRDATE)) Q:'TRDATE  D
 .D GETDATA^BARUFEX1(TRDATE,.RECORD,.TOTAMT,UDUZ,SESSID)
 Q
 ;
TRAILER() ;EP - 
 ;DO THE TRAILER
 S RECTYPE="T"
 S RECORDS=$$FILLSTR^BARUFUT1(RECORD,10,"R","0")
 S TOTAMT=$$FILLSTR^BARUFUT1(TOTAMT,20,"R","0")
 S ^BARUFEX($J,RECORD)=RECTYPE_RECORDS_TOTAMT
 D SENDFILE^BARUFUT2("BARUFEX(",BARFILE)
 ;
 ;SET TRANSMISSION DATE/TIME MULTIPLE
 ;S RC=$$SETTRANS^BARUFUT(UDUZ,SESSID,BARFILE,CURSTAT)
 Q 1_U_BARFILE
 ;
NOTSENT(RECORD,TOTAMT) ;EP - CHECK THE NOT SENT CROSS REFERENCE
 N TRDATE,SESSID,UDUZ
 W !!,"CHECKING PREVIOUSLY 'NOT SENT' TRANSACTIONS"
 S TRDATE=""
 F  S TRDATE=$O(^BARSESS(DUZ(2),"NS",TRDATE)) Q:TRDATE=""  D
 .S SESSID=$O(^BARSESS(DUZ(2),"NS",TRDATE,""))
 .S UDUZ=$O(^BARSESS(DUZ(2),"NS",TRDATE,SESSID,""))
 .;D GETDATA(TRDATE,.RECORD,.TOTAMT)
 .D GETDATA^BARUFEX1(TRDATE,.RECORD,.TOTAMT,UDUZ,SESSID)
 Q
 ;
OLD(SESSID) ;FIND OLDEST SESSION DATE BAR*1.8*4 DD 4.1.1
 N DATE,OLD,REC
 S OLD=$G(SESSID)
 S REC=""
 F  S REC=$O(SESSID(REC)) Q:REC=""  D
 .S DATE=$P(SESSID(REC),U,2)
 .I OLD="" S OLD=DATE
 .I OLD>DATE S OLD=DATE       ;CAPTURE OLDEST DATE
 Q OLD-2                      ;MAKE A LITTLE OLDER
 ;
LCK(UDUZ,SESSID) ;EP; LOCK A/R SESSION FILE ;MRS:BAR*1.8*7 IM30562
 ;
 N X
 F I=1:1:5 LOCK +^BARSESS(DUZ(2),UDUZ,11,SESSID):2 S X=$T Q:X
 I 'X D  Q X
 .W *7,!!,"A/R UFMS CASHIER SESSION FILE IS LOCKED for SESSION "_SESSID
 .W !," SOMEONE ELSE MAY BE EXPORTING, TRY THIS SESSION AGAIN LATER "
 .H 3
 Q X
 ;
 ;OLD SUBROUTINES DISABLED AND MOVED TO BOTTOM OF ROUTINE;MRS:BAR*1.8*7 IM30562
ASKDATE ;EP - ASK DATE RANGE
ASKFROM ;EP - ASK FROM DATE
 Q                              ;DISABLED MRS:BAR*1.8*7 IM30562
 K %DT
 S %DT="AET"
 S %DT("A")="Enter beginning transaction date: "
 D ^%DT
 Q:X=""!(X[U)
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKFROM
 S BARFROM=Y
ASKTO ;EP - ASK TO DATE
 Q                              ;DISABLED MRS:BAR*1.8*7 IM30562
 K %DT
 S %DT="AET"
 S %DT("A")="Enter ending transaction date: "
 D ^%DT
 G:X=""!(X[U) ASKFROM
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKTO
 S BARTO=Y
 I BARTO<BARFROM W !!,"END DATE MUST BE GREATER THAN BEGINING DATE" H 2 G ASKFROM
ASKFILE ;EP - ASK FILENAME
 Q                              ;DISABLED MRS:BAR*1.8*7 IM30562
 S RC=$$ASKFNAME^BARUFUT1(.BARFILE)
 I 'RC W !!,"FILE NOT TRANSMITTED" D ASKFORRT^BARUFUT Q
 D EN(BARFROM,BARTO)
 I '$D(^BARUFEX($J)) D
 .W !,"THERE WERE NO TRANSACTIONS FOUND ELIGIBLE FOR TRANSMISSION!"
 .D ASKFORRT^BARUFUT
 D SENDFILE^BARUFUT2("BARUFEX(",BARFILE)
 Q
ONETRAN(TRDATE,SESSID) ;EP - CREATE FILE FOR ONE/MANY A/R TRANSACTION
 Q                              ;DISABLED;MRS:BAR*1.8*7 IM30562
 N REC
 K ^BARUFEX($J)
 S ARFROM=TRDATE-.01
 S ARFROM=ARFROM-.00001
 D PRE^BARUFEX5(ARFROM,DUZ)        ;CREATE ^BARBOB GLOBAL
 S RC=$$ASKFNAME^BARUFUT1(.BARFILE)
 I 'RC W !!,"TRANSACTIONS NOT TRANSMITTED" D ASKFORRT^BARUFUT Q
 S (RECORD,TOTAMT)=0
 ;
 S REC=""
 F  S REC=$O(TRDATE(REC)) Q:REC=""  D
 .S TRDATE=TRDATE(REC)
 .;D GETDATA(TRDATE,.RECORD,.TOTAMT)
 .D GETDATA^BARUFEX1(TRDATE,.RECORD,.TOTAMT,UDUZ,SESSID)
 I '$D(^BARUFEX($J)) D  Q
 .W !,"THERE WERE NO TRANSACTIONS FOUND ELIGIBLE FOR TRANSMISSION!"
 .D ASKFORRT^BARUFUT
 ;DO THE TRAILER
 S RECTYPE="T"
 S RECORDS=$$FILLSTR^BARUFUT1(RECORD,10,"R","0")
 S TOTAMT=$$FILLSTR^BARUFUT1(TOTAMT,20,"R","0")
 S ^BARUFEX($J,RECORD)=RECTYPE_RECORDS_TOTAMT
 D SENDFILE^BARUFUT2("BARUFEX(",BARFILE)
 Q
EN(ARFROM,ARTO) ;EP - ENTRY TO MAIN UFMS EXTRACT. PULL ALL TRANSACTIONS W/IN DATE RANGE
 Q                              ;DISABLED MRS:BAR*1.8*7 IM30562
 N TRDATE,ENDDATE,TODATE
 N IENS,UFMSTRDT,ARCREDIT,ARDEBIT,ARBILL,UFMSBILL,TPBIEN,TPBLOC,BARACCT,TPBSTAT
 N ARCOL,ARCOLIN,ARASUFAC,ARCOLDT,TRANTYPE,UFMSTYPE,UFMSAMT,APPLYTO,BARAREA,PARNTLOC
 K ^BARUFEX($J)
 S:$G(ARFROM)="" ARFROM=DT-.01
 S:$G(ARTO)="" ARTO=DT
 S ENDDATE=ARTO_.999999
 D PRE^BARUFEX5(ARFROM,DUZ)    ;CREATE ^BARBOB GLOBAL ;BAR*1.8*4 UFMS  ;bar*1.8*4 SDR
 S TRDATE=ARFROM-.00001
 S RECORD=1,TOTAMT=0
 F  S TRDATE=$O(^BARTR(DUZ(2),TRDATE)) Q:'TRDATE!(TRDATE>ENDDATE)  D
 .;D GETDATA(TRDATE,.RECORD,.TOTAMT)               ;MRS:BAR*1.8*7 IM30562
 .D GETDATA^BARUFEX1(TRDATE,.RECORD,.TOTAMT)
 ;
 ;DO THE TRAILER
 S RECTYPE="T"
 S RECORDS=$$FILLSTR^BARUFUT1(RECORD,10,"R","0")
 S TOTAMT=$$FILLSTR^BARUFUT1(TOTAMT,20,"R","0")
 S ^BARUFEX($J,RECORD)=RECTYPE_RECORDS_TOTAMT
 Q