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

BARDYSVS.m

Go to the documentation of this file.
BARDYSVS ; IHS/SD/TPF - DAYS IN A/R REPORT BY VISIT ; 
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**16,28**;OCT 26, 2005;Build 92
 ;IHS/SD/SDR - 1.8*28 - HEAT224215 CR8345 - Added code so it will look through DUZ(2)s for 3P Bill entry.  Removed a couple FM calls and replaced with straight
 ;   code so they will work correctly with multiple DUZ(2)s.  Removed check for HOSPITAL LOCATION.  It was using it instead of VISIT LOCATION, which is
 ;   wrong.  Added code to capture detail info.
 ;
 Q
 ;GIVEN A DATE RANGE CALCULATE NUMBER OF VISITS FOR THAT MONTH IN THE VISIT FILE
BYVISIT(START,END) ;EP -
 K ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT")
 N ENTRY
 S ENTRY=START-.01
 S END=END_".24"
 I $E(END,6,7)="00" S $E(END,6,7)="31"
 D INITVIS^BARDYSUT  ;INITIALIZE COUNTERS TO ZERO
 S OLDMOYR=$E(START,2,5)
 S ENTRYNUM=0,VISITNUM=0
 F  S ENTRY=$O(^AUPNVSIT("B",ENTRY)) Q:ENTRY=""!(ENTRY>END)  D
 .S ENTRYNUM=ENTRYNUM+1
 .S THISYR=$E(DT,1,3)
 .;FOR TESTING COMMENT OUT
 .;I (THISYR-$E(VSITADMT,1,3))>0 S MONTHYR="Ovr 1 Yr"
 .S Y=ENTRY X ^DD("DD") S MONTHYR=$P($P(Y,"@"),",",2)_" "_$E(ENTRY,4,5)
 .I $E(ENTRY,6,7)="00" S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","00 DAY","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","00 DAY","MONTHYR",MONTHYR))+1
 .;Q:$E(ENTRY,6,7)="00"  ;ENTRIES WITH NO DAY ARE ALL "E"VENT SERVICE CATEGORIES.
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","ENTRY NUM","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","ENTRY NUM","MONTHYR",MONTHYR))+1
 .;W !,"ENTRY: ",ENTRY
 .S VISITIEN=""
 .F  S VISITIEN=$O(^AUPNVSIT("B",ENTRY,VISITIEN)) Q:'VISITIEN  D
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","IEN VISIT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","IEN VISIT","MONTHYR",MONTHYR))+1
 ..S DELEFLAG=$$GET1^DIQ(9000010,VISITIEN_",",.11,"I")
 ..;I DELEFLAG S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DELEFLAG","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DELEFALG","MONTHYR",MONTHYR))+1 Q  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..I DELEFLAG S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DELEFLAG","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DELEFLAG","MONTHYR",MONTHYR))+1 Q  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S DEPCOUNT=$$GET1^DIQ(9000010,VISITIEN_",",.09)
 ..I 'DEPCOUNT S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DEPCOUNT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DEPCOUNT","MONTHYR",MONTHYR))+1 Q
 ..S VISITNUM=VISITNUM+1
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","IEN NUM","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","IEN NUM","MONTHYR",MONTHYR))+1
 ..;W !?5,"VISIT IEN: ",VISITIEN
 ..I $$GET1^DIQ(9000010,VISITIEN_",",.11,"I") Q  ;DELETE FLAG = 1 if deleted
 ..S DISCHARG=$$DISCHARG^BARDYSUT(VISITIEN)  ;IS THERE A DISCHARGE DATE?
 ..;I DISCHARG'=0 Q:DISCHARG<START!(DISCHARG>END)                ;NOT SURE ABOUT THIS LOGIC
 ..S SERVCATI=$$GET1^DIQ(9000010,VISITIEN_",",.07,"I")
 ..;should the next screen be done before or after the count of visits is made?
 ..I "^A^D^H^O^I^S^R^T^"'[(U_SERVCATI_U) D  Q
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","SERVCAT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","SERVCAT","MONTHYR",MONTHYR))+1
 ..S SERVCAT=$$GET1^DIQ(9000010,VISITIEN_",",.07,"E")
 ..S MERGED=$$GET1^DIQ(9000010,VISITIEN_",",.37)  ;SCREEN OUT MERGED VISITS
 ..I MERGED'="" D  Q
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","MERGED","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","MERGED","MONTHYR",MONTHYR))+1
 ..S LOCENC=$$GET1^DIQ(9000010,VISITIEN_",",.06,"I")
 ..I $G(BARY("LOC"))'="" Q:LOCENC'=$G(BARY("LOC"))  ;NOT LOCATION CHOSEN
 ..S:LOCENC="" LOCENC="UNDEF"
 ..;S DUZ2=$$GET1^DIQ(9000010,VISITIEN_",",.22,"I")  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..;S:DUZ2="" DUZ2=DUZ(2)  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S DUZ2=LOCENC  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LOCENC",LOCENC,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LOCENC",LOCENC,"MONTHYR",MONTHYR))+1
 ..;
 ..S PACKAGE=$$GET1^DIQ(9000010,VISITIEN_",",.24)
 ..;PACKAGE=NULL CHECK MAY NOT BE CORRECT. WE JUST DON'T PULL ANYTHING IN TEST W/O IT
 ..;I '(($E(PACKAGE,1,2)="SD")!($E(PACKAGE,1,3)="BSD")!($E(PACKAGE,1,3)="CIA")!(PACKAGE="")) D  Q  ;DON'T PULL IF NOT CREATED BY THESE PACKAGES
 ..;.S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","PACKREJ","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","PACKREJ","MONTHYR",MONTHYR))+1
 ..;.S PACKREJ=$G(PACKREJ)+1
 ..;
 ..S CLINIC=$$GET1^DIQ(9000010,VISITIEN_",",.08,"I")  ;CLINIC STOP
 ..I 'CLINIC D  Q  ;IF NO CLINIC NO BILL WILL BE PRODUCED COMMENTED FOR TESTING
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOCLINIC","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOCLINIC","MONTHYR",MONTHYR))+1
 ..;S:CLINIC="" CLINIC="UNDEF"
 ..I $D(BARY("CLIN")) Q:'$D(BARY("CLIN",CLINIC))  ;NOT CHOSEN CLINIC
 ..;
 ..;I BAR("LOC")="BILLING" SORT BY DUZ(2)
 ..;I BAR("LOC")="VISIT" SORT BY VISIT LOCATION
 ..;LOCATION TYPE FOR REPORTS
 ..I BAR("LOC")="BILLING" D
 ...S SUB1=DUZ2
 ..E  S SUB1=LOCENC
 ..;VISIT TYPE OR CLINIC SORT
 ..I BARY("SORT")="C" D
 ...S SUB2=CLINIC
 ..E  S SUB2=SERVCAT
 ..;
 ..;S BILLIEN=$O(^ABMDBILL(DUZ(2),"AV",VISITIEN,""))  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..;start new bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S BARCHK=0
 ..S ABMDUZ(2)=0
 ..F  S ABMDUZ(2)=$O(^ABMDBILL(ABMDUZ(2))) Q:'ABMDUZ(2)  D  Q:BARCHK
 ...S BILLIEN=$O(^ABMDBILL(ABMDUZ(2),"AV",VISITIEN,0))
 ...I BILLIEN S BARCHK=1
 ..;end new bar*1.8*28 IHS/SD/SDR HEAT224215
 ..I 'BILLIEN D  ;Q
 ...;W !,"VISITIEN: ",VISITIEN," HAS NO BILLS CAN'T FIND A PROVIDER"
 ...;IF NO BILL CAN WE FIND A PROVIDER RELATED TO THE VISIT?
 ...S VPROV=$$PRVCHK^BARDYSUT(VISITIEN)
 ...S:VPROV=0 VPROV="UNDEF"
 ...;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(NUMVISIT(LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ...;S NUMVISIT=NUMVISIT+1
 ...;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT","MONTHYR",MONTHYR))+1
 ...;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN",LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ...;I ($E(PACKAGE,1,2)="SD")!($E(PACKAGE,1,3)="BSD")!($E(PACKAGE,1,3)="CIA") D
 ...;.S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN","MONTHYR",MONTHYR))+1
 ...;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOBILLS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOBILLS","MONTHYR",MONTHYR))+1
 ...;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOBILLS",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOBILLS",LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ..I BILLIEN D
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","WITBILLS",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","WITBILLS",LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","WITBILLS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","WITBILLS","MONTHYR",MONTHYR))+1
 ..;
 ..I 'BILLIEN Q  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..;S BILLSTAT=$$GET1^DIQ(9002274.4,BILLIEN_",",.04,"I")  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S BILLSTAT=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,0)),U,4)  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S:BILLSTAT="" BILLSTAT="UNDEF"
 ..;W !!,"BILL: ",$$GET1^DIQ(9002274.4,BILLIEN_",",.01,"I")
 ..;W !?5,"BILL STATUS: ",BILLSTAT
 ..I BILLSTAT="X" D  ;BILL STATUS = CANCELLED
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOBILLS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NOBILLS","MONTHYR",MONTHYR))+1
 ..;.S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR))+1
 ..;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR,BILLSTAT)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR,BILLSTAT))+1
 ..;K PROV
 ..;I BILLIEN S PROV=$$GETPRV^BARDYSV1(BILLIEN,$G(BARY("PRV"))) Q:'PROV  ;FIND PROVIDER CHOSEN OR ONLY ATTEND OR RENDERING
 ..;S PROV=$P($G(PROV,"^UNDEF"),U,2)
 ..;IF USER DID NOT CHOSE A PROVIDER THEN SORT BY PROVIDER
 ..;IF THE NEXT SCREEN IS TAKEN OUT YOU GET A LOT OF ZEROES. THE ONLY DATA IS
 ..;CREATED AND REVIEWED DAYS
 ..;
 ..;VISIT & BILL PASSES ALL SCREENS
 ..;now is this the correct logic for "check ins"
 ..;OR IS IT IF THE VISITIEN HAS AN ENTRY IN V HOSPITALIZTION?
 ..I ($E(PACKAGE,1,2)="SD")!($E(PACKAGE,1,3)="BSD")!($E(PACKAGE,1,3)="CIA") D
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN",LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AVGCHKIN","MONTHYR",MONTHYR))+1
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT",LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ...S NUMVISIT=NUMVISIT+1
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT","MONTHYR",MONTHYR))+1
 ..E  D
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT",LOCENC,SUB2,"MONTHYR",MONTHYR))+1
 ...S NUMVISIT=NUMVISIT+1
 ...S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","NUMVISIT","MONTHYR",MONTHYR))+1
 ..;
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","VISIT IEN","MONTHYR",MONTHYR,VISITIEN)=""
 ..S VSITCRET=$P($$GET1^DIQ(9000010,VISITIEN_",",.02,"I"),".")
 ..S VSITADMT=$P($$GET1^DIQ(9000010,VISITIEN_",",.01,"I"),".")
 ..S VPCCREV=$P($$GET1^DIQ(9000010,VISITIEN_",",.13,"I"),".")
 ..S PCCREV=$$GETREV(VISITIEN,VPCCREV)
 ..S BARTREC=VISITIEN_U_MONTHYR_U_LOCENC_U_VSITADMT_U_VSITCRET_U_$$DAYS^BARDYSV1(+VSITCRET,+VSITADMT)_U_PCCREV_U_$$DAYS^BARDYSV1(+PCCREV,+VSITADMT)  ;detail rec  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DET",VISITIEN)=BARTREC  ;detail rec  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 ..;NOW GO GET THE AVG'S FOR THE CLAIMS GENERATED BY THIS VISIT
 ..S CREDAYS=CREDAYS+$$DAYS^BARDYSV1(+VSITCRET,+VSITADMT)
 ..S REVDAYS=REVDAYS+$$DAYS^BARDYSV1(+PCCREV,+VSITADMT)
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DATE DIFF",VISITIEN,$$DAYS^BARDYSV1(+PCCREV,+VSITADMT))=PCCREV_U_VSITADMT
 ..;FOR SORTING WHEN USER SELECTS SORT BY VISIT USE SERVICE CATEGORY
 ..;
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CREDAYS",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CREDAYS",LOCENC,SUB2,"MONTHYR",MONTHYR))+$$DAYS^BARDYSV1(+VSITCRET,+VSITADMT)
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","REVDAYS",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","REVDAYS",LOCENC,SUB2,"MONTHYR",MONTHYR))+$$DAYS^BARDYSV1(+PCCREV,+VSITADMT)
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CREDAYS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CREDAYS","MONTHYR",MONTHYR))+$$DAYS^BARDYSV1(+VSITCRET,+VSITADMT)
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","REVDAYS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","REVDAYS","MONTHYR",MONTHYR))+$$DAYS^BARDYSV1(+PCCREV,+VSITADMT)
 ..;
 ..;D TPBDAYS^BARDYSV1(VISITIEN,VSITADMT,.TPBAPP,.TPBEXP,.NUMBILLS,.BILLAMT)
 ..D TPBDAYS^BARDYSV1(VISITIEN,VSITADMT)
 D PRINTVIS^BARDYSPR
 D ^%ZISC
 Q
 ;
GETREV(VISITIEN,VPCCREV) ;EP - GET PCC REVIEW DATE
 ;PER DAVID BATTESE GET REVIEW DATE FROM V CHART AUDIT IF TURNED ON
 N TMP,QUEAUDIT,EARLIEST
 S QUEAUDIT=$$GET1^DIQ(9001000,DUZ(2)_",",.12,"I")  ;FIELD 'EHR/CHART AUDIT START DATE' FROM 'PCC MASTER CONTROL'
 Q:$G(VSITADMT)<QUEAUDIT VPCCREV  ;IF ADMIT DATE IS BEFORE AUDIT WAS TURNED ON GET REVIEW DATE FROM 'DATE LAST MODIFIED'
 D  ;OTHERWISE SEE IF YOU CAN GET IT IN THE 'V CHART AUDIT' FILE
 .S (PCCREV,TMP)=""  ;^AUPNVCA = V CHART AUDIT
 .F  S TMP=$O(^AUPNVCA("AD",VISITIEN,TMP)) Q:'TMP  D
 ..I $$GET1^DIQ(9000010.45,TMP_",",.04)="R" D      ;CHART AUDIT STATUS, R=REVIEWED/COMPLETE I=INCOMPLETE
 ...S PCCREV=$$GET1^DIQ(9000010.45,TMP_",",.01)  ;DATE OF AUDIT
 I PCCREV S PCCREV=PCCREV_"A"  ;IF A "R" DATE OF AUDIT WAS FOUND THEN USE IT
 E  S PCCREV=VPCCREV_"V"       ;OTHERWISE STAY WITH THE 'DATE LAST MODIFIED'
 Q PCCREV