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

ACHSTXP2.m

Go to the documentation of this file.
ACHSTXP2 ; IHS/ITSC/FCJ - EXPORT PREV DATA (2/2) - RECORD 2(DHR), SET GLOBALS FOR OTHER RECORD TYPES ;     [ 10/14/2004  12:53 PM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**11**;JUNE 11, 2001
 ;3.1*11 IHS/ITSC/FCJ 8.18.04 NEW ROUTINE-ORIGINAL RTN ACHSTX2
 ;  SETS DATE FOR EXPORT: 10.01.01 THRU 09.30.04
 ;
 D LINES^ACHSFU
 W @IOF,!,ACHS("*"),!?30,"EXPORT CHS DATA",!,ACHS("*"),!
 S ACHSCHSS=""
 D ^ACHSUF
 K ACHSCHSS
 D KILLGLBS^ACHSTX
 ;ITSC/SET/JVK ACHS*3.1*11 FOR OUR PURPOSE ALL SITES WILL BE 638
 ;SO THAT NO DHR RECORDS ARE CREATED
 ;S (J,ACHSDCR)=0,ACHSRR="",ACHSF638=$P(^ACHSF(DUZ(2),0),U,8)
 S (J,ACHSDCR)=0,ACHSRR="",ACHSF638="Y"
 S ACHSEXP="Y"
 S ACHSEDT=3040930,ACHSBDT=3001001
 F ACHS=2:1:7 S ACHSRTYP(ACHS)=0
S2 ;export Re-Generation.
 S ACHSFDT=ACHSBDT,ACHSLDAT=ACHSEDT,ACHSAFAC=$P(^AUTTLOC(DUZ(2),0),U,10)
 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 ACHSEXP="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))
 I ACHSF638="Y",ACHSEXP="Y" F ACHS="252G","252R","254D","254L","254M" S ACHS(ACHS)=$O(^ACHS(3,DUZ(2),1,"B",ACHS,0))
 ;
 S ACHSBDT=ACHSBDT-1
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
 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),"")
 ;I ACHSF638="Y",$$PARM^ACHS(2,9)="Y" G S7
 I ACHSF638="Y",ACHSEXP="Y" G S7
 S:ACHSTY="P"&(ACHSDEST'="F") ^ACHSTXPD(P,DA)=""
 S ACHSPROV=$P(^ACHSF(DUZ(2),"D",P,0),U,8)
 S:'$D(^ACHSTXVN(ACHSPROV)) ^ACHSTXVN(ACHSPROV)=ACHSDEST
S7 ;
 I ACHSDEST="F"!(ACHSTY'="P") G S8
 ;I $$PARM^ACHS(2,9)'="Y" G S7A
 I ACHSEXP'="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
S8 ;
 G S6:ACHSTY="P"
 ;I ACHSF638="Y",$$PARM^ACHS(2,9)="Y" G S6
 I ACHSF638="Y",ACHSEXP="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
 S (ACHSX,X1)=$P(ACHSDOCR,U,14)
 D FYCVT^ACHSFU
 S ACHSXLOC=ACHSFC
 S:ACHSY<1987 ACHSXLOC="0"_$E(ACHSFC,2,3)
 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),ACHSPROV=$P(ACHSDOCR,U,8)
 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 = ",!!
 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
 ;
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
 ;