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

ACHSWFRS.m

Go to the documentation of this file.
ACHSWFRS ;IHS/OIT/LMH - WEBFRS EXTRACT DATA ; 17 Jul 2008  3:03 PM
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**14,15**;JUN 11,2001
 ;WEBFRS DATA EXTRACT ORIGINAL ROUTINE FROM KEVIN ROGERS
 ;ACHS*3.1*14 IHS/OIT/LMH Modified to bring into ACHS namespace
 ;ACHS*3.1*14 IHS/OIT/FCJ Added DCIS section; removed Dev section; removed all IO writes and
 ;            un used lines of code; changed DUZ(2) to ACHSFAC; modified Sendto section
 ;ACHS*3.1*15 IHS/OIT/FCJ Added test for Error checks for DCIS records, call for dev to print report,
 ;            multiple changes throughout routine to test for printing error report
 ;NOTE: Routine is scheduled through taskman, do not write to screen, unless the ZTQUEUED variable is tested
 ;
 S ACHSFLG1=""
ST ;EP FOR REPORT ONLY
 ;--- Set the current patch version variable ---
 K ACHSVER S ACHSVER="P"_15  ;PATCH VERIFICATION FOR CONSOLIDATION PROCESS
 ;ACHS*3.1*15 2.13.2009 IHS/OIT/FCJ ADDED ^TMP($J,"ACHSWERR") TO NXT LINE
 K ^TMP($J,"ACHSWREC"),^TMP($J,"ACHSWFRS"),^TMP($J,"ACHSWERR")
 S ^TMP($J,"ACHSWERR",0)=0  ;ACHS*3.1*15 2.13.2009 IHS/OIT/FCJ ADDED LINE
 D ^ACHSVAR
 ;ACHS*3.1*15 2.17.2009 IHS/OIT/FCJ added REP section
REP ;
 I ACHSFLG1=1 D  G:POP KILL2
 .W @IOF,!!,$$C^ACHS("DCIS ERROR REPORT")
 .W !!,"NOTE: Documents will not be sent to DCIS until errors are fixed",!
 .D ^%ZIS                       ;EXIT BY "^" POP=1
 .Q:POP                ;EXIT OUT OF %ZIS
 .I $D(IO("S")) D SLV^ACHSFU    ;IF SLAVE DEV, DO OPEN & GET CLOSE PARAMS
 ;
 ;---- Loop CHS facilities -----------------------------------------
 ;---- Do not process facilities with incomplete configurations
 ;---- Do not process inactive facilities
 ;---- Process IHS & CHS affiliated locations ONLY;IHS/OCA/KJR;19DEC03
 ;---- Get export path from RPMS SITE file
 ;
 S ACHSFAC=0
 F  S ACHSFAC=$O(^ACHSF(ACHSFAC)) Q:'ACHSFAC  D
 .I ACHSFLG1=1,DUZ(2)'=ACHSFAC Q
 .Q:'$D(^ACHSF(ACHSFAC,2))  ;FACILITY PARAMETERS NOT SET
 .Q:$L($P(^AUTTLOC(ACHSFAC,0),"^",17))'=3  ;FINANCE CODE NOT SET
 .Q:'$G(^ACHS(9,ACHSFAC,"FY",ACHSCFY,0))  ;NO CURRENT YEAR ACTIVITY
 .;
 .;---- Begin: Check Affiliation ----
 .;
 .K DA,ACHSTMP S ACHSAFF=0,ACHSTMP(9999999)=0,DA=0
 .F  S DA=$O(^AUTTLOC(ACHSFAC,11,DA)) Q:'DA  D
 ..Q:$D(^AUTTLOC(ACHSFAC,11,DA,0))'=1  S ACHS0=^(0)
 ..F J=1:1:3 S ACHSP="ACHSP"_J,@ACHSP=$P(ACHS0,"^",J)
 ..Q:ACHSP2&(ACHSP2<DT)  Q:ACHSP1&(ACHSP1>DT)
 ..S ACHSTMP(9999999-ACHSP1)=ACHSP3
 .S DA=$O(ACHSTMP("")) S:DA<9999999 ACHSAFF=ACHSTMP(DA)
 .K DA,ACHSTMP,ACHS0,J,ACHSP,ACHSP1,ACHSP2,ACHSP3
 .Q:ACHSAFF'=1&(ACHSAFF'=3)  ;USE IHS & CHS AFFILIATED SITES ONLY
 .;
 .;---- End: Check Affiliation ---
 .;
 .S DFN=$O(^AUTTSITE(0)) Q:'DFN  ;NO RPMS SITE SET
 .Q:$D(^AUTTSITE(DFN,1))'=1  S ACHSPUB=$P(^(1),"^",2)
 .Q:ACHSPUB']""  ;NO FILE EXPORT PATH DEFINED
 .D START
 .D:ACHSFLG1="" SENDFILE
 .I ACHSFLG1=1 X:$D(IO("S")) ACHSPPO D RPT^ACHSWDR  ;ACHS*3.1*15 2.13.2009 IHS/OIT/FCJ RUN ERROR REPORT
 .K ^TMP($J,"ACHSWREC"),^TMP($J,"ACHSWFRS"),^TMP($J,"ACHSWERR")  ;;ACHS*3.1*15 2.13.2009 IHS/OIT/FCJ ADD ACHSWERR NODE
 D KILL2
 X:$D(IO("S")) ACHSPPC
 D:IO'=IO(0) ^%ZISC
 K ACHSQ,ACHSPPC,ACHSPPO
 Q
 ;
START ;
 S ASUFAC=$P(^AUTTLOC(ACHSFAC,0),"^",10)
 F ACHSFYS=2:-1:0 S ACHSFY=ACHSCFY-ACHSFYS D  ;Loop thru last 2 years of documents
 .D ^ACHSVAR
 .D FYSEL
 .D PRINT
 Q
 ;
FYSEL ; Identify fiscal years for data export
 S ACHSWFY=ACHSFY
 S %=$$FY^ACHSVAR($E(ACHSFY,3,4)),ACHSBDT=$P(%,U),ACHSEDT=$P(%,U,2)
 I ACHSEDT>DT S ACHSEDT=DT
 ;
 ;
REM ; --- Remove the intended Host File ---
 Q:ACHSFLG1=1
 I ACHSWFY=(ACHSCFY-2) D
 .S ACHSCMD=ACHSPUB_"chs"_ASUFAC_".txt"
 .I $$VERSION^%ZOSV(1)["UNIX" S ACHSCMD="rm "_ACHSCMD
 .E  S ACHSCMD="del "_ACHSCMD
 .S ACHSX=$$JOBWAIT^%HOSTCMD(ACHSCMD)
 Q
 ;
 ;
PRINT ;
 S ACHSFC=$P($G(^AUTTAREA($P($G(^AUTTLOC(ACHSFAC,0)),U,4),0)),U,3)_$E($P($G(^AUTTLOC(ACHSFAC,0)),U,17),2,3)
 I $D(ACHSERR),ACHSERR=1 K ZTSK D KILL Q
 S (ACHSTOTP,ACHSCNX,ACHSOPEN,ACHSTOTP("$"),ACHSCNX("$"),ACHSOPEN("$"))=0
 S X3=0,ACHSDNU=1_($E(ACHSWFY,4))_"00000"
A ; Main loop. Check end date.
 S ACHSDNU=$O(^ACHSF(ACHSFAC,"D","B",ACHSDNU))
 I (ACHSDNU="")!($E(ACHSDNU,2)'=$E(ACHSWFY,4)) D KILL Q
 S ACHSDIEN="" F I=1:1:9 S ACHSERR(I)=""
B ; Get IEN.
 S ACHSDIEN=$O(^ACHSF(ACHSFAC,"D","B",ACHSDNU,ACHSDIEN))
 G A:ACHSDIEN=""
C ; 
 G A:'$D(^ACHSF(ACHSFAC,"D",ACHSDIEN,0)) S ACHSSTS=$S($P(^(0),U,12)=3:"P",$P(^(0),U,12)=4:"C",1:"OPEN")
 S ACHSDOC1=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,0),U),ACHSVDFN=$P(^(0),U,8),ACHSDOC2=$P(^(0),U,14),ACHSDFY=$P(^(0),U,27),ACHSOBJ=$P(^(0),U,7)
 S ACHS("$")=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,0),U,9),ACHSTOS=$P(^(0),U,4),ACHSBLNK=+$P(^(0),U,3),ACHSORDT=$P(^(0),U,2),ACHS("$PCAN")=0
 G B:ACHSVDFN']"",B:'$D(^AUTTVNDR(ACHSVDFN,0)) S ACHSVNDR=$P(^(0),U) S ACHSEIN="" S:$D(^(11)) ACHSEIN=$P(^(11),U)_" "_$P(^(11),U,2)
 S ACHSDOC=ACHSDOC2_"-"_ACHSFC_"-"_ACHSDOC1
 K ACHSNAME
 S DFN=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,0),U,22)
 I +DFN>0,$D(^DPT(DFN,0)) S ACHSNAME=$P(^(0),U)
 I '$D(ACHSNAME),ACHSBLNK S ACHSNAME=$S(ACHSBLNK=1:"* BLANKET",1:"* SPECIAL TRANS")
 G B:'$D(ACHSNAME)
 S:$D(^ACHSF(ACHSFAC,"D",ACHSDIEN,"PA")) ACHS("$")=+^("PA")
 S:$D(^ACHSF(ACHSFAC,"D",ACHSDIEN,"ZA")) ACHS("$")=+^("ZA")
 F ACHS=0:0 S ACHS=$O(^ACHSF(ACHSFAC,"D",ACHSDIEN,"T",ACHS)) Q:+ACHS=0  D
 . S ACHSDOS=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,"T",ACHS,0),U,10)
 . I $P(^ACHSF(ACHSFAC,"D",ACHSDIEN,"T",ACHS,0),U,2)="C",$P(^(0),U,5)="F" S ACHS("$")=$P(^(0),U,4)
 . I $P(^ACHSF(ACHSFAC,"D",ACHSDIEN,"T",ACHS,0),U,2)="C",$P(^(0),U,5)="P" S ACHS("$PCAN")=ACHS("$PCAN")+$P(^(0),U,4)
 .Q
 ;
 ; --- Create delimited text record here ---
 ;
 ;     --- Add doc num and dollar totals ---
 S ACHSDOC=0_$P(ACHSDOC,"-")_$P(ACHSDOC,"-",2)_$P(ACHSDOC,"-",3)
 G:$D(^TMP($J,"ACHSWFRS",ACHSDOC))=1 B  ; STOP IF DUPLICATE DOCUMENT
 S ^TMP($J,"ACHSWFRS",ACHSDOC)=""
 I ACHSSTS="P" S ACHSTOT=ACHS("$")_U_ACHS("$")
 I ACHSSTS="C" S ACHSTOT="0^0"
 I ACHSSTS'="P" I ACHSSTS'="C" S ACHSTOT=ACHS("$")_"^0"
 ;
 ;     --- Add the Pseudo Prefix ---
 S ACHSPSD="" I $D(^AUTTLOC(ACHSFAC,1))=1 S ACHSPSD=$P(^(1),"^",2)
 ;
 ;     --- Add the vendor data ---
 S ACHSVDFN=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,0),U,8)
 K ACHSDATA S ACHSDATA="^^^^^^^^^^^^^^^^^^^^^"
 I +ACHSVDFN D ^ACHSWVEN
 ;
 ;    --- Add the CAN letter indicator ---
 S ACHSCAN=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,0),"^",6),ACHSFYI=""
 I ACHSCAN,$D(^ACHS(2,+ACHSCAN,0)) S ACHSFYI=$E($P(^(0),"^"),5)
 ;
 ;    --- Add the document destination indicator ---
 S ACHSDEST=$P(^ACHSF(ACHSFAC,"D",ACHSDIEN,0),U,17)
 ;
 ;ACHS*3.1*14 IHS/OIT/FCJ Added DCIS section
DCIS ;    ----DCIS SECTION ---
 S ACHSREC="^^^^^^^^^^^^^^^^^^^"
 ;FOR TESTING UNCOMMENT NXT LINE AND COMMENT OUT SECOND LINE
 ;I ACHSSTS="P" D DCIS^ACHSWDCS
 I ACHSORDT>3081000,ACHSDFY>2007,ACHSSTS="P" D DCIS^ACHSWDCS
 ;
 ;    --- Write line feed/return to top of loop ---
 S ^TMP($J,"ACHSWREC",ACHSDOC)=ACHSDOC_U_ACHSTOT_U_ACHSPSD_U_ACHSDATA_U_ACHSFYI_U_ACHSDEST_U_ACHSVER_ACHSREC
 G B
 ;
 ; --- End of new code here ---
 ;
 ;BEGIN NEW CODE IHS/OIT/LMH
SENDFILE ; Send file
 N X1,XBCON,XBE,XBF,XBQ,XBQSHO,XBFN,XBGL,XBFLT,XBMED,XBS1
 S XBFN="chs"_ASUFAC_".txt"
 S XBGL="TMP("_$J_",""ACHSWREC"","
 S XBQSHO=""
 S XBF=$J
 S XBE=$J
 S XBFLT=1
 S XBMED="F"
 S XBCON=1
 S XBS1="ACHS WEBFRS B"
 S XBQ="N"
 D ^XBGSAVE
 Q
 ;END NEW CODE IHS/OIT/LMH
KILL ; Do ERPT, kill vars, quit
 K ACHSDNU,ACHSDOC,ACHSDOC1,ACHSDOC2,ACHSBLNK,ACHSCNX,ACHSDOS,ACHSVNDR,ACHSEIN
 K ACHSSTS,ACHSTOS,ACHSTOTP,ACHSVDFN,ACHSDIEN,DFN,X2,X3,ACHSOPEN,ACHSNAME
 K ACHSBDT,ACHSCMD,ACHSORDT,ACHSEDT,ACHSERR,ACHSACFY,ACHSERR,ACHSFC
 K ACHSTOT,ACHSWFY,DA,ZISHC,ZISHDA1,ACHS13,ACHSFYDT,ACHSFYWK
 K ACHSCAN,ACHSDATA,ACHSDOC,ACHSFILE,ACHSFYI,ACHSPSD,ACHSDFY,ACHSOBJ
 K ACHSPUB,ACHSFAX,ACHSVDFN,ACHSAFF,ACHSDEST
 K ACHSRTYP,ACHSCTYP,ACHSCDFN,ACHSVC,ACHSVCL,X,ACHSTST,ACHSREC
 Q
KILL2 ;
 K I,C,ACHSFYS,ACHSVER,ACHSFAC
 K ACHS,ACHSACFY,ACHSBM,ACHSCNU,ACHSFLG,ACHSLN,ACHSLOC,ACHSPG,ACHSPIID,ACHSTIME,ACHSUSR
 K ACHSVFAX,ASUFAC,X,X1,ACHSFLG1
 I '$D(ZTQUEUED) D ^ACHSVAR
 Q