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

ACHSEOB1.m

Go to the documentation of this file.
ACHSEOB1 ; IHS/ITSC/TPF/PMF - PROCESS EOBRS (2/6) - READ IN, PROCESS ; 15 Feb 2016  5:00 PM
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**21,22,23**;JUN 11, 2001;Build 43
 ;
 K ^TMP("ACHSEOB",$J)
 D NOW^ACHS
 S ACHSTIME=$$C^XBFUNC(ACHSTIME,80)
 ;ACHS*3.1*23 ADDED ACHSEDXT TO NXT LINE
 S (ACHSEDXT,ACHSTERR,ACHSZRC,ACHSCTR,ACHSEFL9)=0,(ACHSOLD,ACHSZFLC)=""
 ;
 D ^ACHSEOBM                ;BUILD CHS EOBR ERROR MESSAGE FILE
 ;
 I $D(ACHSAEND) S ACHSTERR=1 Q
MAIN ;
 U IO
 R ACHSEOBR:300   ;SAC-FILE READ
 ;I 'ACHSISAO H 1  ;ACHS*3.1*23
 U IO(0)
 I ACHSEOBR="" S ACHSTERR=1 W !,"Unexpected End Of File!  This file is incomplete." G TERR
 ;I ACHSISAO=1 S ACHSEOBR=$E(ACHSEOBR,3,85)  ;ACHS*3.1*21
 I ACHSISAO S ACHSEOBR=$S($$OS^ACHS=2:$E(ACHSEOBR,1,82),1:$E(ACHSEOBR,3,85))   ;ACHS*3.1*21
 ;
 ;GO PRINT THE PROPER REPORT AND UPDATE DOCUMENT DEPENDING ON PARM
 ;ACHS*3.1*22;IF ICD-9 FILE FIX GO TO ACHSEOB9
 ;I ACHSEOBR=""!($E(ACHSEOBR,1,2)="**") D M1^ACHSEOBB D END Q  ;RETURNS ACHSTERR
 I ACHSEOBR=""!($E(ACHSEOBR,1,2)="**") D @($S($P(ACHSMEDA,".",2)="ICD":"M1^ACHSEOB9",1:"M1^ACHSEOBB")) D END Q  ;RETURNS ACHSTERR
 I ACHSOLD="" S ACHSOLD=$E(ACHSEOBR,1,18)
 ;ACHS*3.1*22;IF ICD-9 FILE FIX GO TO ACHSEOB9
 ;I ACHSOLD'=$E(ACHSEOBR,1,18) D M1^ACHSEOBB Q:ACHSTERR   ;QUIT IF SEQ ERROR
 I ACHSOLD'=$E(ACHSEOBR,1,18) D @($S($P(ACHSMEDA,".",2)="ICD":"M1^ACHSEOB9",1:"M1^ACHSEOBB")) Q:ACHSTERR   ;QUIT IF SEQ ERROR
 ;
 ;
 D REC^ACHSEOBB ;BEGIN PROCESS OF RECORDS INTO LOCAL ARRAYS ACHSEOBR(A-I
 G TERR:ACHSTERR
 ;
 I ACHSZFLC=$E(ACHSEOBR,1,6) S ACHSZFLC=$E(ACHSEOBR,1,6) G WRITE
 ;
 S ACHSZZ=$E(ACHSEOBR,1,6)   ;ASUFAC CODE
 ;CHECK LOCATION ASUFAC INDEX X-REF FOR IEN
 S ACHSZFPT="",ACHSZFPT=$O(^AUTTLOC("C",ACHSZZ,ACHSZFPT)) ;GET AREA IEN
 ;
 ;
 ;IF CANT FIND AREA IEN IN ASUFAC INDEX TRY ASUFAC CODE X-REF
 I +ACHSZFPT=0 S ACHSZFPT="",ACHSZFPT=$O(^AUTTLOC("CTOO",ACHSZZ,""))
 ;
 S ACHSZ3=$E(ACHSEOBR,55,57) ;GET FINANCIAL LOCATION CODE
 ;CHECK FINANCIAL LOCATION CODE X-REF FOR LOCATION IEN
 S ACHSZPT3="",ACHSZPT3=$O(^AUTTLOC("FLC",ACHSZ3,ACHSZPT3))
 ;
 ;IF FINANCIAL LOCATION IEN >0 & FINANCIAL LOC. SAME AS DOC LOC. CONT
 I +ACHSZPT3>0,ACHSZFPT=ACHSZPT3 G CONT
 ;
 ;IF FINACIAL CODE DEFINED BUT NOT SAME AS DOC USE DOC. LOCATION
 I +ACHSZPT3>0 U IO(0) W !,"FACILITY CODE PROBLEM -- USING DOCUMENT LOCATION" S ACHSZFPT=ACHSZPT3 G CONT
 ;IF DOC LOC NOT FOUND TRY USING FIANANCIAL LOC CODE LAST DITCH TRY
 I 'ACHSZFPT S ACHSZFPT=$$FLC(ACHSZ3)
 ;
 ;IF STILL CANT FIND LOCATION QUIT THIS MUST BE FIXED 
 I +ACHSZFPT=0 U IO(0) D  D TERR Q
 .W *7,!!,"Invalid Facility Code ",$E(ACHSEOBR,1,6)," in EOBR Data."
 .W !,"File ",$P(ACHSUFLS(+Y)," ")," contains a facility code that"
 .W !,"cannot be found on the system -- JOB CANCELLED" S ACHSTERR=20
CONT ;
 ;GET INSTITUTION NAME
 S ACHSZFNM=$P($G(^DIC(4,ACHSZFPT,0),"UNDEFINED"),U)
 ;
 U IO(0)
 W !!?10,"Processing EOBR Data for: ",ACHSZFNM,!!
 ;
 S ACHSZFLC=$E(ACHSEOBR,1,6)   ;RESET TO FACILITY ASUFAC
 ;
WRITE ;
 S ACHSCTR=ACHSCTR+1   ;INCREMENT COUNTER
 ;
 S ^ACHSEOBR(ACHSZFPT,ACHSCTR)=ACHSEOBR
 ;
 ;IF RECORD IS TYPE "H" SUMMARY RECORD
 ;DO SUMM IF PRINT EOBR'S PARAMETER IS Y OR PRINT SUMM OPTION USED AND
 ;PRINT CANCEL DOCUMENTS IS Y
 I $E(ACHSEOBR,19)="H" D SUMM:$S(ACHSISAO:$$AOP^ACHS(2,6)="Y",1:$$PARM^ACHS(2,14)="Y")
 ;ALL RECORD TYPES BUT "A" GO GET ANOTHER RECORD OTHERWISE KEEP COUNT
 I $E(ACHSEOBR,19)'="A" G MAIN
 ;
 ;KEEP COUNT OF FACILITIES,TOTAL RECORD COUNT, AND WRITE USER FEEDBACK
 S:'$D(ACHSZFCT(ACHSZFPT)) ACHSZFCT(ACHSZFPT)=0
 S ACHSZFCT(ACHSZFPT)=ACHSZFCT(ACHSZFPT)+1
 S ACHSCTR(1)=ACHSCTR
 S ACHSZRC=ACHSZRC+1
 I ACHSZRC#10=0 U IO(0) W $J(ACHSZRC,8)
 F X="B","C","D","E","F","G","I","J" K ACHSEOBR(X)  ;ACHS*3.1*23
 G MAIN
 ;
GBLD ;EP - Build ACHSEOBR("M") MESSAGE ARRAY from "F" records.
 S:'$D(ACHSEOBR("M","ACHSMSEQ")) ACHSEOBR("M","ACHSMSEQ")=0
 S ACHSMSG=""
 ;
 S:$D(ACHSEOBR("F",14)) ACHSMSG=ACHSEOBR("F",14) ;GET MESSAGE
 Q:ACHSMSG=""!("RM"'[$E(ACHSMSG,1,1))          ;??????
 S ACHSMSEQ=ACHSEOBR("M","ACHSMSEQ")+1  ;CAN WE COMBINE THIS AND NEXT LINE????
 S ACHSEOBR("M","ACHSMSEQ")=ACHSMSEQ
 S:'$D(ACHSEOBR("M","B",ACHSMSG)) ACHSEOBR("M",ACHSMSEQ)=ACHSMSG,ACHSEOBR("M","B",ACHSMSG)=""
 Q
 ;
SIGN ;EP - Extract the Sign of the field from the last character in
 ;     the field.
 ;S Y=$E(ACHSEOBR,$P(X,".",3))
 S Y=$E(ACHSREC,$P(X,".",3))
 I "}JKLMNOPQR"[Y S ACHSREC=$E(ACHSREC,1,$P(X,".",2)-1)_"-"_$E(ACHSREC,$P(X,".",2)+1,$P(X,".",3)-1)_$S(Y="}":0,1:$C($A(Y)-25))_$E(ACHSREC,$P(X,".",3)+1,80) Q
 I "{ABCDEFGHI"[Y S ACHSREC=$E(ACHSREC,1,$P(X,".",3)-1)_$S(Y="{":0,1:$C($A(Y)-16))_$E(ACHSREC,$P(X,".",3)+1,80)
 Q
 ;
SUMM ;THIS IS THE SUMMARY
 D REC1^ACHSEOBB
 I ACHSEOIO'=IO S IOP=ACHSEOIO D ^%ZIS   ;ACHS*3.1*21
 U ACHSEOIO
 W @IOF,!!?24,"--- SUMMARY OF EOBR PROCESSED ---",!!,$$C^XBFUNC(ACHSTIME,80),!!!
 ;
 W ?5,"INDIAN HEALTH SERVICE",?40,"CONTRACT HEALTH SERVICES",!!,"AO: ",$S($G(ACHSEOBR("H",1))'="":$P(^AUTTAREA($O(^AUTTAREA("C",ACHSEOBR("H",1),0)),0),U),1:"UNDEFINED")
 ;
 W !!,"SU: "
 I $G(ACHSEOBR("H",1))'="",($G(ACHSEOBR("H",2))'="") W $P(^AUTTSU($O(^AUTTSU("C",ACHSEOBR("H",1)_ACHSEOBR("H",2),0)),0),U)
 E  W "INCOMPLETE INFORMATION TO FIND SERVICE UNIT"
 ;
 W !!!?23,"FISCAL YEAR:  ",$G(ACHSEOBR("H",4))
 ;
 W !!!!!?15,"AUTHORIZING FACILITY:  "
 I $G(ACHSEOBR("H",8))'="" D
 .S Y=$O(^AUTTLOC("C",ACHSEOBR("H",8)))
 .I 'Y W "UNDEFINED" Q
 .S Y=$P($G(^AUTTLOC(Y,0)),U,2)
 .W $G(Y,"UNDEFINED"),!!
 ;
 W ?20,"PERIOD COVER(S):  "
 I +$G(ACHSEOBR("H",9)) D
 .W $$FMTE^XLFDT($S(+$E(ACHSEOBR("H",9),1,2)>50:2,1:3)_"000000"+ACHSEOBR("H",9))
 ;
 I +$G(ACHSEOBR("H",10)) W !?38,$$FMTE^XLFDT($S(+$E(ACHSEOBR("H",10),1,2)>50:2,1:3)_"000000"+ACHSEOBR("H",10))
 ;
 W !!?21,"TYPE 43 CLAIMS:",$J(+$G(ACHSEOBR("H",11)),13),!!?21,"TYPE 57 CLAIMS:",$J(+$G(ACHSEOBR("H",12)),13),!!?21,"TYPE 64 CLAIMS:",$J(+$G(ACHSEOBR("H",13)),13)
 ;
 W !!?18,"TOTAL OF PAYMENTS: $"
 S X=$E($G(ACHSEOBR("H",14)),1,8)_"."_$E($G(ACHSEOBR("H",14)),9,10)
 K X1,X2
 D COMMA^%DTC
 W X,!!," NET ADJ. OF PAYMENT VS. OBLIGATION: $"
 S X=$E($G(ACHSEOBR("H",15)),1,8)_"."_$E($G(ACHSEOBR("H",15)),9,10)
 D COMMA^%DTC
 W X,@IOF
 D HOME^%ZIS   ;ACHS*3.1*21
 Q
 ;
END ;
 I $G(ACHSZRC)>0 U IO(0) W !!,"Total EOBR Records Processed = ",ACHSZRC,!!
KYL ; Close device, kill vars, quit.
 I (IO(0)'=IO)!($D(IO("S"))) D ^%ZISC
 I $D(ACHSEOIO),ACHSEOIO'=IO S IO=ACHSEOIO D ^%ZISC
 D CLOSEALL^ACHS
 K ACHSEOBR,ACHSEOIO,ACHSERRA,ACHSOLD,ACHSTIME,ACHSX
 Q
 ;
ERR ;
 U IO(0)
 W *7,*7,!!,"AN ERROR HAS BEEN DETECTED IN THE",!,"FINANCE PARAMETERS OR DATA GLOBAL STRUCTURE.",!!,"PLEASE CONTACT YOUR SITEMANAGER FOR ASSISTANCE",!!
 S X=$$DIR^XBDIR("E","Press <RETURN> To Continue....")
 D KYL
 Q
 ;
TERR ;
 U IO(0)
 W *7,!!,"EOBR PROCESSING ERROR.",!!,"Notify your supervisor.",!
 I $G(ACHSTERR)=5 W !,"PROBLEM HINT AT NODE ^ACHSEOBR(""SEQ-ERROR"")=",$G(ACHSEOBR)," POSSIBLE CHAR 19 IN RECORD IMPROPER"
 I $G(ACHSTERR)=10 W !,"IMPROPER RECORD TYPE - ",$E(ACHSEOBR,19)
 I $G(ACHSTERR)=20 W !,"INVALID FACILITY CODE - ",$E(ACHSEOBR,1,6)
 ;
 ;
 S X=$$DIR^XBDIR("E","Press <RETURN> To Continue....")
 D END
 Q
 ;
END1 ;EP.
 U IO(0)
 W !!,"No CHS EOBR Data Processed"
 S X=$$DIR^XBDIR("E","Press <RETURN> To Continue....")
 D KYL
 Q
 ;
FLC(ACHSZ3) ;
 ; Attempt to find Location based on FLC of EOBR.
 ; The ASUFAC code for any given facility may have changed since
 ;  the document left the facility, and the EOBR created.
 ; Assume the ^AUTTLOC("FLC" x-ref has a bug, if you get this far,
 ;  (that's why you got this far) and use the ^AUTTLOC("FL" x-ref
 ;  and the single-character code from the AREA file.
 ; Once the "FLC" x-ref is corrected, this code not needed.
 ;
 N X,Y
 S (X,Y)=0
 F  S X=$O(^AUTTLOC("FL",X)) Q:'$L(X)!Y  S Y=0 F  S Y=$O(^AUTTLOC("FL",X,Y)) Q:'Y  I Y,$P(^AUTTAREA($P(^AUTTLOC(Y,0),U,4),0),U,3)_$E(X,2,3)=ACHSZ3 Q
 Q Y
 ;