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

ACHSEOBF.m

Go to the documentation of this file.
ACHSEOBF ; IHS/ITSC/TPF/PMF - SET VARIABLE FROM DOCUMENT FOR EOBR PRNTING ; JUL 10, 2008  
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**14,15,23**;JUN 11,2001;Build 43
 ;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES
 ;3.1*15 11.04.2008 IHS/OIT/FCJ FIXED PRINTING TOTALS
 ;3.1*23 9.19.2013 	IHS/OIT/FCJ ADDED PROC FOR ICD-10
 ;
F ;EP
 ;F ARRAY
 ;F DETAIL RECORD
 F I=8:1:16 S ACHSEOBR("F",I)=""   ;INIT ARRAY
 ;
 ;BELOW GOES THROUGHT THE CPT OR REV INFORMATION SUB FILE OF THE 
 ;DOCUMENT FILE
 ;
F1 ;
 S ACHSCNTR=7    ;INIT F DETAIL FIELD NUMBER
 S ACHSCPT=0
 S ACHSCSEQ=0    ;INIT SEQUENCE NUMBER FOR CPTS
 F  S ACHSCPT=$O(^ACHSF(DUZ(2),"D",ACHSDIEN,11,ACHSCPT)) Q:+ACHSCPT=0  D
 .Q:$P(^ACHSF(DUZ(2),"D",ACHSDIEN,11,ACHSCPT,0),U,10)'=ACHSTIEN
 .S X=$J("",22)
 .S $E(X,19)="F" ; SET THE RECORD TYPE FOR ACHSEOBB
 .;beginning Y2K fix
 .S ACHSCSEQ=ACHSCSEQ+1 ;Y2000
 .;Y2000 use CCYYMMDD format in the following record generation
 .;
 .;GET CPT SUBFILE 0 RECORD
 .S ACHSCPT0=$G(^ACHSF(DUZ(2),"D",ACHSDIEN,11,ACHSCPT,0))
 .Q:'ACHSCPT0     ;IF NO ZERO RECORD NOTHING TO DO
 .;
 .;ACHS*3.1*15 11/4/2008 IHS/OIT/FCJ FIX PRINTING VAULES AT THE BOTTEM OF PAGE
 .;S ^TMP("ACHSEOB",$J,"F",ACHSCSEQ)=X_$P(ACHSCPT0,U,2)+17000000_$P(^(0),U,3)+17000000   ;Y2000  ;DATE OF SERVICE FROM
 .S ^TMP("ACHSEOB",$J,"F",ACHSCSEQ)=X_($P(ACHSCPT0,U,2)+17000000)_($P(ACHSCPT0,U,3)+17000000)   ;Y2000  ;DATE OF SERVICE
 .;end Y2K fix block
 .;
 .S A=$P($P(ACHSCPT0,U),";",1),A=$J(" ",5)_A,A=$E(A,$L(A)-4,$L(A)) ;CPT/REVENUE CODE
 .S B=$P(ACHSCPT0,U,4),B=$J(" ",2)_B,B=$E(B,$L(B)-2,$L(B))         ;UNITS
 .S D=$P(ACHSCPT0,U,5)   ;CHARGES BILLED
 .S X=""
 .F I=1:1:$L(D) I $E(D,I)'="." S X=X_$E(D,I)   ;FORMAT OUT DECIMAL
 .S D=X,D="000000000"_D,D=$E(D,$L(D)-8,$L(D))  ;FILL OUT D TO 8 PLACES
 .S E=$P(ACHSCPT0,U,6)                         ;CHARGES ALLOWABLE
 .S X=""
 .F I=1:1:$L(E) I $E(E,I)'="." S X=X_$E(E,I)
 .S E=X,E="000000000"_E,E=$E(E,$L(E)-8,$L(E))
 .S F=$P(ACHSCPT0,U,7)                          ;MSG CODE
 .S F=$J(" ",4)_F,F=$E(F,$L(F)-3,$L(F))
 .S G=$P(ACHSCPT0,U,8)                          ;TOOTH NUMBER
 .S G=$J(" ",2)_G,G=$E(G,$L(G)-2,$L(G))
 .S H=$P(ACHSCPT0,U,9)                          ;TOOTH SURFACE
 .S H=$J(" ",5)_H,H=$E(H,$L(H)-5,$L(H))
 .;
 .;CONSOLIDATE ALL TEMP VARS INTO THE TMP GLOBAL F DETAIL RECORD
 .S ^TMP("ACHSEOB",$J,"F",ACHSCSEQ)=$G(^TMP("ACHSEOB",$J,"F",ACHSCSEQ))_A_B_D_E_F_G_H
 .;
 .S ACHSEOBR("F",8)=$P(ACHSCPT0,U,2)            ;DOS FROM
 .S ACHSEOBR("F",9)=$P(ACHSCPT0,U,3)            ;DOS TO
 .S ACHSEOBR("F",10)=$P($P(ACHSCPT0,U,1),";",1) ;CPT/REV CODE
 .S ACHSEOBR("F",11)=$P(ACHSCPT0,U,4)           ;UNITS  
 .S ACHSEOBR("F",12)=$P(ACHSCPT0,U,5)           ;CHARGES BILLED
 .S ACHSEOBR("F",13)=$P(ACHSCPT0,U,6)           ;CHARGES ALLOWABLE
 .S ACHSEOBR("F",14)=$P(ACHSCPT0,U,7)           ;MSG CODE
 .S ACHSEOBR("F",15)=$P(ACHSCPT0,U,8)           ;TOOTH NUMBER
 .S ACHSEOBR("F",16)=$P(ACHSCPT0,U,9)           ;TOOTH SURFACE
 .;
 .;"D",9 IS AN ACCUMULATOR (BILLED BY PROV) ADD UP CHARGES BILLED 
 .I ACHSEOBR("F",14)'="" S ACHSEOBR("M","B",ACHSEOBR("F",14))=""
 .S ACHSEOBR("D",9)=ACHSEOBR("D",9)+ACHSEOBR("F",12)
 .I ACHSEOBR("D",9)'["." S ACHSEOBR("D",9)=ACHSEOBR("D",9)_".00"
 .;
 .;"D",10 IS AN ACCUMULATOR (ALLOWABLE AMT) ADD UP CHARGES ALLOWABLE
 .S ACHSEOBR("D",10)=ACHSEOBR("D",10)+ACHSEOBR("F",13)
 .I ACHSEOBR("D",10)'["." S ACHSEOBR("D",10)=ACHSEOBR("D",10)_".00"
 .;
 .;IF EOBR SERVICES BILLED="B" INPATIENT THEN TAKE DIFFERENCE BETWEEN
 .;DOS FROM AND DOS TO., IF THIS IS NOT EQUAL TO "B" THE VARIABLE WAS
 .;ALREADY SET TO THE WORKLOAD FIELD $P(ACHSTRAN,U,9) IN ACHSEOBA
 .I ACHSEOBR("C",10)="B",ACHSCPT=1 S X1=ACHSEOBR("F",9),X2=ACHSEOBR("F",8) D ^%DTC S ACHSEOBR("B",11)=X
 ;
 ;
 ;G ARRAY
 ;G PROCEDURES ARRAY 
G ;
 ;ACHS*3.1*23 CHANGED FOR LOOP FROM 10 TO 12
 F I=8:1:12 S ACHSEOBR("G",I)=""  ;INIT ARRAY
 ;
G1 ;GO THRU PROCEDURE RECORDS AND PULL INFO
 S ACHSCNTR=7     ;INTITALIZE MAINFRAM FIELD NUMBER FOR ARRAY
 S ACHSPROC=0
 F  S ACHSPROC=$O(^ACHSF(DUZ(2),"D",ACHSDIEN,10,ACHSPROC)) Q:+ACHSPROC=0  D
 .;GET PROCEDURE 0 RECORD
 .S ACHSPRC0=$G(^ACHSF(DUZ(2),"D",ACHSDIEN,10,ACHSPROC,0))
 .Q:$P(ACHSPRC0,U,3)'=ACHSTIEN   ;EOBR TRANSACTION # MUST MATCH 
 .S ACHSCNTR=ACHSCNTR+1
 .S ACHSEOBR("G",ACHSCNTR)=$P(ACHSPRC0,U)     ;PROCEDURE PTR
 .Q:ACHSEOBR("G",ACHSCNTR)=""
 .;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
 .;S ACHSEOBR("G",ACHSCNTR)=$P($G(^ICD0(ACHSEOBR("G",ACHSCNTR),0)),U)  ;PROC CODE
 .;S ACHSEOBR("G",ACHSCNTR)=$P($$ICDOP^ICDCODE(ACHSEOBR("G",ACHSCNTR)),U,2)  ;PROC CODE ;ACHS*3.1*23
 .S ACHSEOBR("G",ACHSCNTR)=$P($$ICDOP^ICDEX(ACHSEOBR("G",ACHSCNTR),,,"I"),U,2)  ;PROC CODE ;ACHS*3.1*23
 ;
 ;
J ;LOOP THRU TRANSACTION SUBFILE OF DOCUMENT FILE
 I $D(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA")) S ACHSPA=$P(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA"),U,6)   ;'FINAL PAYMENT AMOUNT'
 S (ACHSTR,ACHSOBG,ACHSPA)=0
J1 F  S ACHSTR=$O(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",ACHSTR)) Q:+ACHSTR=0  D
 .;GET TRANSACTION 0 RECORD
 .S ACHSTRA0=$G(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",ACHSTR,0))
 .Q:ACHSTRA0=""
 .;
 .;IF TRANSACTION TYPE IS "INITIAL" ADD TO OBLIGATION AMT
 .I $P(ACHSTRA0,U,2)="I" S ACHSOBG=ACHSOBG+$P(ACHSTRA0,U,4)
 .;
 .;IF TRANSACTION TYPE IS "SUPPLEMENTAL" ADD TO OBLIGATION AMT
 .I $P(ACHSTRA0,U,2)="S" S ACHSOBG=ACHSOBG+$P(ACHSTRA0,U,4)
 .;
 .;IF TRANSACTION TYPE IS "CANCELATION" SUBTRACT FROM OBLIGATION AMT
 .I $P(ACHSTRA0,U,2)="C" S ACHSOBG=ACHSOBG-$P(ACHSTRA0,U,4)
 .;
 .;IF TRANSACTION TYPE IS "INTERIM PAYMENT" IGNORE
 .;I $P(ACHSTRA0,U,2)="IP" S ACHSPA=ACHSPA+$P(ACHSTRA0,U,4)
 .;
 .;IF TRANSACTION TYPE IS "ADJUSTMENT" ADD TO UNITS BILLED
 .I $P(ACHSTRA0,U,2)="ZA" S ACHSPA=ACHSPA+$P(ACHSTRA0,U,4)
 .;ACHS*3.1*23 CHG "E" TO VAR ACHSREJ FOR REC E OR J
 .S ACHSEOBR(ACHSREJ,10)=ACHSOBG
 .S ACHSEOBR(ACHSREJ,11)=ACHSPA
 .S ACHSEOBR(ACHSREJ,11)=ACHSOBG-ACHSPA  ;UNITS BILLED=OBLIGATION-ADJUSTMENT
 .;
 .;EOBR PAY TYPE   'I'=INTERIM  'F'=FINAL 
 .;IF INTERIM WIPE OUT OBLIGATION AND ADJUSTMENT AMT   ??????
 .;ACHS*3.1*23 CHG "E" TO VAR ACHSREJ FOR REC E OR J
 .I $P(ACHSTRAN,U,15)="I" S (ACHSEOBR(ACHSREJ,10),ACHSEOBR(ACHSREJ,11))="*********" Q    ;IF WIPEING OUT WHY BOTHER WITH NEXT TWO LINES?
 .I ACHSEOBR(ACHSREJ,10)["." S %=ACHSEOBR(ACHSREJ,10),%=$P(%,".")_$E($P(%,".",2)_"00",1,2),ACHSEOBR(ACHSREJ,10)=%
 .E  S ACHSEOBR(ACHSREJ,10)=ACHSEOBR(ACHSREJ,10)_"00"
 .I ACHSEOBR(ACHSREJ,11)["." S %=ACHSEOBR(ACHSREJ,11),%=$P(%,".")_$E($P(%,".",2)_"00",1,2),ACHSEOBR(ACHSREJ,11)=%
 .E  S ACHSEOBR(ACHSREJ,11)=ACHSEOBR(ACHSREJ,11)_"00"
 Q
 ;