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

ACHSTX2.m

Go to the documentation of this file.
ACHSTX2 ; IHS/ITSC/PMF - EXPORT DATA (3/9) - RECORD 2(DHR), SET GLOBALS FOR OTHER RECORD TYPES ;JUL 10, 2008
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**7,13,14,15,16,22**;JUN 11,2001;Build 43
 ;ITSC/SET/JVK 10-29-03 ACHS*3.1*7 - TEST FOR E-SIG ON EXPORT
 ;ACHS*3.1*13 6.13.2007 IHS/OIT/FCJ ADDED REC CNT FOR UFMS and also create UFMS record for live testing
 ;ACHS*3.1*14 8.31.2007 IHS/OIT/FCJ Fixed Tribal Stat records: Only Pay Documents and only if parameter is set
 ;
 ;  This routine was used to create routine ACHSTXA1, which is used in
 ;  creation of DHR records for specifically selected document
 ;  transactions.  If any change is made to the logic in this routine,
 ;  the same logic change should be made to ACHSTXA1.
 ;
 D LINES^ACHSFU
 W @IOF,!,ACHS("*"),!?30,"EXPORT CHS DATA",!,ACHS("*"),!
 S ACHSCHSS=""
 D ^ACHSUF
 K ACHSCHSS
 D KILLGLBS^ACHSTX
 S (J,ACHSDCR,ACHSEDT,ACHSBDT)=0,ACHSRR="",ACHSF638=$P(^ACHSF(DUZ(2),0),U,8)
 ;F ACHS=2:1:7 S ACHSRTYP(ACHS)=0
 F ACHS=2:1:8 S ACHSRTYP(ACHS)=0  ;ACHS*3.1*13 6.13.2007 IHS/OIT/FCJ ADDED RECORD COUNT 8 FOR UFMS
 I '$D(^ACHSTXST(DUZ(2))) S DA=9999998-DT G S1
 F I=1:1 S J=$O(^ACHSTXST(DUZ(2),1,J)) Q:+J<1  S P=J
 S ACHSBDT=$P(^ACHSTXST(DUZ(2),1,P,0),U,3),N=9999998-DT,DA=N
 S DA=DA-1
S1 ;
 S DA=$O(^ACHS(9,DUZ(2),"FY",ACHSCFY,"AR",DA))
 G S2:DA<1
S11 ;
 S ACHSDCR=$O(^ACHS(9,DUZ(2),"FY",ACHSCFY,"AR",DA,ACHSDCR))
 G S1:ACHSDCR<1,S11:'$D(^ACHS(9,DUZ(2),"FY",ACHSCFY,"W",ACHSDCR,0)) I ACHSEDT'>$P(^(0),U,2) S ACHSEDT=$P(^(0),U,2)
 G S11
 ;
S2 ;EP - For export Re-Generation.
 G ERR:ACHSEDT=0
 ;
 ;ACHS*3.1*15 IHS.OIT.FCJ ADDED ACHSFDTT TO NXT LINE
 S ACHSFDT=ACHSBDT,ACHSLDAT=ACHSEDT,ACHSAFAC=$P(^AUTTLOC(DUZ(2),0),U,10),ACHSFDTT=""
 I $$PARM^ACHS(2,25)="Y" S X=$P(^ACHSF(DUZ(2),0),U,12) G AFACERR:+X<1 S ACHSAFAC=$P(^AUTTLOC(X,0),U,10)
 I +ACHSAFAC<1 G AFACERR
 I $$PARM^ACHS(2,9)="Y" F ACHS="252F","254V" S ACHS(ACHS)=$O(^ACHS(3,DUZ(2),1,"B",ACHS,0))
 I ACHSF638="Y",$$PARM^ACHS(2,9)="Y" F ACHS="252G","252R","254D","254L","254M" S ACHS(ACHS)=$O(^ACHS(3,DUZ(2),1,"B",ACHS,0))
S3 ;
 S ACHSBDT=$O(^ACHSF(DUZ(2),"TB",ACHSBDT))
 G CVTEND1:ACHSBDT<1!(ACHSBDT>ACHSEDT)
 S:ACHSRCT=0 ACHSFDT=ACHSBDT
 S ACHSTY=""
S4 ;
 S ACHSTY=$O(^ACHSF(DUZ(2),"TB",ACHSBDT,ACHSTY))
 G S3:ACHSTY="",S4:ACHSTY="ZA"!(ACHSTY="IP")
 S P=0
S5 ;
 S P=$O(^ACHSF(DUZ(2),"TB",ACHSBDT,ACHSTY,P))
 G S4:P<1,S5:$P(^ACHSF(DUZ(2),"D",P,0),U,3)=2
 S DA=0
S6 ;
 S DA=$O(^ACHSF(DUZ(2),"TB",ACHSBDT,ACHSTY,P,DA))
 ;
 G S5:DA<1
 ;ITSC/SET/JVK ACHS*3.1*7 11/26/03 CMT OUT NXT TWO
 ;S ACHSESIG=$P($G(^ACHSF(DUZ(2),"D",P,0)),U,24)
 ;S ACHSADT=$P($G(^ACHSESIG(DUZ(2),0)),U,3)
 ;ITSC/SET/JVK END ACHS*3.1*7
 S ACHSDEST=$P($G(^ACHSF(DUZ(2),"D",P,0)),U,17),ACHSCTY=ACHSTY
 G S6:'$D(^ACHSF(DUZ(2),"D",P,"T",DA,0)) S X=$P(^(0),U,4),X=$P(X,".",1)_$E($P(X,".",2)_"00",1,2),ACHSIPA=$E(X+1000000000000,2,13) I ACHSCTY="C" S ACHSCTY=$P(^(0),U,5)
 G S6:'$D(^ACHSF(DUZ(2),"D",P,0)) S ACHSDOCR=^(0),ACHSTOS=$P(ACHSDOCR,U,4)
 S ACHSDR3=$G(^ACHSF(DUZ(2),"D",P,3),"")
 S ACHSPROV=$P(^ACHSF(DUZ(2),"D",P,0),U,8)
 I ACHSF638="Y",$$PARM^ACHS(2,9)="Y" G S7
 S:ACHSTY="P"&(ACHSDEST'="F") ^ACHSTXPD(P,DA)=""
 S:'$D(^ACHSTXVN(ACHSPROV)) ^ACHSTXVN(ACHSPROV)=ACHSDEST
S7 ;
 ;ITSC/SET/JVK NOTE THIS LINE TO SEND REGARDLESS OF PAYMENT DESTINATION
 ;ONLY FI RECORDS IN RECORD TYPE 5
 ;I ACHSTY'="P" G S8
 ;ACHS*3.1*14 8.31.2007 IHS/OIT/FCJ changed nxt section for tribal stat data, commented out 6 lines added 1
 ;I ACHSDEST="F"!(ACHSTY'="P") G S8
 ;I $$PARM^ACHS(2,9)'="Y" G S7A 
 ;S ^ACHSTXPG(ACHSTOS,P,DA)="" 
S7A ;
 ;I ACHSF638'="Y" G S8
 ;S:'$P(ACHSDOCR,U,3) ^ACHSTXPG(ACHSTOS,P,DA)=""
 ;G S6
 ;ACHS*3.1*15 IHS.OIT.FCJ ADDED ACHSFDTT TO NXT LINE
 I ACHSTY="P",$$PARM^ACHS(2,9)="Y",ACHSF638="Y",$P(ACHSDOCR,U,3)'=2 S ^ACHSTXPG(ACHSTOS,P,DA)="" S:ACHSFDTT="" ACHSFDTT=ACHSBDT
S8 ;
 G S6:ACHSTY="P"
 ;ITSC/SET/JVK ACHS*3.1*7 11/26/03 CMT OUT NXT 1
 ;G S6:(ACHSESIG="")&(ACHSBDT>ACHSADT)
 ;ACHS*3.1*14 8.31.2007 IHS/OIT/FCJ CMT OUT 3 LINES ADDED 2
 ;I ACHSF638="Y",$$PARM^ACHS(2,9)'="Y" G S6
 ;S ^ACHSTXOB(P,DA)=""
 ;I +$P(ACHSDOCR,U,22),+$P(ACHSDOCR,U,20),+$P(ACHSDOCR,U,21) S ^ACHSTXPT(+$P(ACHSDOCR,U,22),+$P(ACHSDOCR,U,20),+$P(ACHSDOCR,U,21))=ACHSDEST
 D AF
 G:ACHSF638="Y" S6   ;ACHS*3.1*14T 9.31.2007 IHS/OIT/FCJ Tribal sites do not need to create DHR records
 S (ACHSX,X1)=$P(ACHSDOCR,U,14)
 D FYCVT^ACHSFU
 S ACHSXLOC=ACHSFC
 S:ACHSY<1987 ACHSXLOC="0"_$E(ACHSFC,2,3)
 ;Y2000 The following line is OK ... YY is Y2K correct in CHS
 ;ACHS*3.1*16 10/15/2009 IHS.OIT.FCJ SPLIT NEXT LINE AND ADDED CORRECT FY
 ;S ACHSEFDT=$E(DT,4,5)_$E(DT,6,7)_$E(DT,2,3),ACHSCDE=$S(ACHSCTY="I":"05013",ACHSCTY="F":"05024",ACHSCTY="P":"05025",ACHSTY="S":"05015",1:""),ACHSDOCN=0_X1_ACHSXLOC_$P(ACHSDOCR,U)
 S ACHSEFDT=$E(DT,4,5)_$E(DT,6,7)_$E(DT,2,3),ACHSCDE=$S(ACHSCTY="I":"05013",ACHSCTY="F":"05024",ACHSCTY="P":"05025",ACHSTY="S":"05015",1:"")
 S ACHSDOCN=$E($P(ACHSDOCR,U,27),3,4)_ACHSXLOC_$P(ACHSDOCR,U)
 S:'$D(^ACHSTXVN(ACHSPROV)) ^ACHSTXVN(ACHSPROV)=ACHSDEST
 G ERROR^ACHSTX:ACHSCDE=""
 D CANOBJ^ACHSTX8
 S ACHSFED=$S($P(^AUTTVNDR(ACHSPROV,11),U,10)=2:2,1:1)
 S ACHSRCT=ACHSRCT+1         ;RECORD COUNT
 S ACHSRTYP(2)=ACHSRTYP(2)+1
 S ^ACHSDATA(ACHSRCT)="2"_ACHSEFDT_ACHSCDE_$S(ACHSTOS=1:323,ACHSTOS=2:324,ACHSTOS=3:325,1:"")_ACHSDOCN_$J("",13)_"1"_X1_ACHSCAN_ACHSOBJC_ACHSIPA_ACHSFED_$J("",16)
 ;
 I $L(^ACHSDATA(ACHSRCT))'=80 W !!,*7,*7,"A DHR RECORD WAS PRODUCED THAT WAS NOT 80 CHARACTERS IN LENGTH:",!!,^(ACHSRCT),!,*7,*7 G ERROR^ACHSTX
 I ACHSRCT=1 S ACHSFDT=ACHSBDT W !!,"NUMBER OF RECORDS PROCESSED = ",!!
 S ACHSERR=0 D S1^ACHSTXFT I ACHSERR G ERROR^ACHSTX  ;ACHS*3.1*13 6.13.2007 IHS/OIT/FCJ Used for testing UFMS data
 I ACHSRCT#25=0 W $J(ACHSRCT,8)
 D BC
 G S6
 ;
ERR ;
 W !!,*7,*7,"DCR REGISTER ERROR YOU MUST CLOSE YOUR REGISTERS FIRST"
 D ^%ZISC,KILL^ACHSTX8,RTRN^ACHS
 Q
 ;
AFACERR ;
 W !!,*7,*7,"AUTHORIZING FACILITY CODE ERROR  -  JOB CANCELLED"
 D ^%ZISC,KILL^ACHSTX8
 Q
 ;
CVTEND1 ;
 S ACHSROUT=ACHSRCT
 S:ACHSRCT>2 ACHSROUT=ACHSRCT
 K ACHSDEST,ACHSDCR,ACHSF638,ACHSIPA,ACHSCAN,ACHSCDE,ACHSCTY,ACHSDOCN,ACHSDOCR,ACHSEFDT,ACHSPROV,ACHSFED,ACHSOBJC,ACHSTOS,DA,ACHSTY,X1,ACHSXLOC
 G ^ACHSTX3
 ;
AF ;Area - FI records set globals   ;ACHS*3.1*14 8.31.2007 IHS/OIT/FCJ ADDED SECTION
 S:ACHSTY="P"&(ACHSDEST'="F")&($$PARM^ACHS(2,12)="Y") ^ACHSTXPD(P,DA)=""
 ;I $$PARM^ACHS(2,11)="Y" S ^ACHSTXOB(P,DA)=""
 I $$PARM^ACHS(2,11)="Y",ACHSDEST="F" S ^ACHSTXOB(P,DA)=""  ;ACHS*3.1*22 IHS/OIT/FCJ "I" TYPE DOC WERE BEING SENT TO THE FI
 I ($$PARM^ACHS(2,11)="Y")!($$PARM^ACHS(2,12)="Y") D
 .I +$P(ACHSDOCR,U,22),+$P(ACHSDOCR,U,20),+$P(ACHSDOCR,U,21) S ^ACHSTXPT(+$P(ACHSDOCR,U,22),+$P(ACHSDOCR,U,20),+$P(ACHSDOCR,U,21))=ACHSDEST
 .S:'$D(^ACHSTXVN(ACHSPROV)) ^ACHSTXVN(ACHSPROV)=ACHSDEST
 Q
BC ;EP - Generate Export records 2B and 2C for CORE.
 ;
 ; 2B
 S ACHSCAN="IHS/AP:"_$E(ACHSCAN,2,3)_"/SU:"_$E(ACHSCAN,4)_"/YR:"_$E(ACHSCAN,5)_"/CC:"_$E(ACHSCAN,6,7)
 S ACHSCAN=ACHSCAN_$J("",30-$L(ACHSCAN))
 ;
 S ACHSOBJC=$E($P($G(^ACHSOCC($P(ACHSDOCR,U,10),0)),U,2),1,20)
 S ACHSOBJC=ACHSOBJC_$J("",20-$L(ACHSOBJC))
 ;
 S ACHSX=$P(ACHSDOCR,U,14)
 I '$D(ACHSDR3) S ACHSDR3=$S($D(ACHSDIEN):$G(^ACHSF(DUZ(2),"D",ACHSDIEN,3)),1:"")
 S ACHSABD=$E($P(ACHSDR3,U,1),4,7)
 S ACHSAED=$E($P(ACHSDR3,U,2),4,7)
 K ACHSDR3
 D FYCVT^ACHSFU
 S %="2B"_ACHSFC_"."_ACHSCAN_ACHSOBJC_ACHSY_ACHSABD_ACHSAED
 D SET(%)
 ;
 ; 2C
 ; Vendor EIN
 S %=$E($P(^AUTTVNDR(ACHSPROV,11),U)_$J("",10),1,10)_$E($P(^AUTTVNDR(ACHSPROV,11),U,2)_"  ",1,2)
 ;
 ; Vendor Name
 S %=%_$E($P(^AUTTVNDR(ACHSPROV,0),U),1,30)
 S %=%_$J("",42-$L(%))
 ;
 ; 1/8/01  pmf  the way this was written, it would crash without
 ; a vendor address in the database.  I'm changing it so that if
 ; no address is on file, it works.  This may backfire - we may
 ;find out that somebody NEEDS the address and are screwed without
 ;it.  But for now, it's gonna go.
 ;
 ; Vendor CityStZip
 ;S %=%_$P(^AUTTVNDR(ACHSPROV,13),U,2)_","_$P(^DIC(5,$P(^AUTTVNDR(ACHSPROV,13),U,3),0),U,2)_","_$P(^AUTTVNDR(ACHSPROV,13),U,4)
 S ACHSVADR=$G(^AUTTVNDR(ACHSPROV,13))
 S %=%_$P(ACHSVADR,U,2)_","
 S ACHSVAD2=$P(ACHSVADR,U,3) I ACHSVAD2'="" S ACHSVAD2=$P(^DIC(5,ACHSVAD2,0),U,2)
 S %=%_ACHSVAD2_","_$P(ACHSVADR,U,4) K ACHSVADR,ACHSVAD2
 ;
 ;end of chaNge to allow no address
 ;
 ;adjust to 72 characters long
 S %=$E(%,1,72),%=%_$J("",72-$L(%))
 ;
 S %="2C"_%
 D SET(%)
 ;
 Q
 ;
SET(%) ;
 S %=%_$J("",80-$L(%))
 S ACHSRCT=ACHSRCT+1,^ACHSDATA(ACHSRCT)=%
 I ACHSRCT#25=0 W $J(ACHSRCT,8)
 Q
 ;