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

IBOEMP1.m

Go to the documentation of this file.
  1. IBOEMP1 ;ALB/ARH - EMPLOYER REPORT (SEARCH) ; 6/19/92
  1. ;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
  1. ;
  1. I IBCH="OPT" G OPT
  1. ;
  1. INPT ;search for outpatient admissions (patient movement file)
  1. S IBB=IBBEG-.001,IBE=IBEND+.3,IBHDR=IBHDR_" FOR INPATIENT ADMISSIONS ",IBQ=0
  1. F S IBB=$O(^DGPM("AMV1",IBB)) Q:'IBB!(IBB>IBE)!(IBQ) D S IBQ=$$STOP^IBOEMP2
  1. . S IBDFN="" F S IBDFN=$O(^DGPM("AMV1",IBB,IBDFN)) Q:'IBDFN D
  1. .. Q:$D(^TMP("IBEMP",$J,IBDFN)) S Y=IBB D DD^%DT S IBAPDT=$P(Y,"@",1),IBPM=""
  1. .. F S IBPM=$O(^DGPM("AMV1",IBB,IBDFN,IBPM)) Q:IBPM="" S IBAPTYP=$P(^DGPM(IBPM,0),"^",2),IBAPTYP=$P($G(^DG(405.3,IBAPTYP,0)),"^",1)
  1. .. S IBAPDT=IBAPDT D PAT
  1. K IBB,IBE,IBDFN,IBAPDT,IBAPTYP,IBPM,X,Y
  1. Q
  1. ;
  1. OPT ;search for outpatient visits
  1. ;find ALL outpatient visits within the date range and division
  1. ;this includes registrations (2,1000), scheduled appointments (44,1900), and unscheduled appointments (409.5)
  1. ;
  1. DIS ;find all dispositions (2,1000) within the date range
  1. ; - (2,1000,1) that are not 2-APPLICATION WITHOUT EXAM
  1. S IBB=IBBEG-.0001,IBE=IBEND+.9,IBHDR=IBHDR_" FOR OUTPATIENT VISITS ",IBQ=0
  1. F S IBB=$O(^DPT("ADIS",IBB)) Q:'IBB!(IBB>IBE)!(IBQ) S IBDFN=0 D S IBQ=$$STOP^IBOEMP2
  1. . F S IBDFN=$O(^DPT("ADIS",IBB,IBDFN)) Q:'IBDFN S IBY=0 I '$D(^TMP("IBEMP",$J,IBDFN)) D
  1. .. F S IBY=$O(^DPT("ADIS",IBB,IBDFN,IBY)) Q:'IBY S IBX=$G(^DPT(IBDFN,"DIS",IBY,0)) I +IBX,$P(IBX,U,2)<2,(VAUTD=1!($D(VAUTD(+$P(IBX,"^",4))))) D
  1. ... S IBAPTYP="DISPOSITION",IBAPDT=IBB\1
  1. ... D PAT
  1. ;
  1. ;
  1. APPT ;outpatient: find all scheduled appointments (44,1900 -> 2,1900)
  1. ; - must be clinic appointments (44,2.1 -> "AC" x-ref)
  1. ; - (2,1900,3) that are outpatient, have not been canceled or no-showed etc.
  1. S IBE=IBEND+.3,IBCLN=0
  1. F S IBCLN=$O(^SC("AC","C",IBCLN)) Q:'IBCLN!(IBQ) D S IBQ=$$STOP^IBOEMP2
  1. . I VAUTD'=1,'$D(VAUTD(+$P($G(^SC(IBCLN,0)),"^",15))) Q ; check division
  1. . S IBB=IBBEG-.0001 F S IBB=$O(^SC(IBCLN,"S",IBB)) Q:'IBB!(IBB>IBE) D
  1. .. S IBY=0 F S IBY=$O(^SC(IBCLN,"S",IBB,1,IBY)) Q:'IBY S IBX=$G(^SC(IBCLN,"S",IBB,1,IBY,0)) I +IBX D
  1. ... S IBDFN=+IBX I $D(^TMP("IBEMP",$J,IBDFN)) Q
  1. ... S IBXP=$G(^DPT(IBDFN,"S",IBB,0)) I +IBXP'=IBCLN,$P(IBXP,U,2)'="" Q
  1. ... S IBAPTYP=$P($G(^SD(409.1,+$P(IBXP,U,16),0)),U,1),IBAPDT=IBB\1
  1. ... D PAT
  1. ;
  1. ;
  1. STOP ;outpatient: find all unscheduled outpatient appointments (409.5, add/edit) for the patient
  1. S IBB=IBBEG-.001,IBE=IBEND+.3
  1. F S IBB=$O(^SDV(IBB)) Q:'IBB!(IBB>IBE)!(IBQ) D S IBQ=$$STOP^IBOEMP2
  1. . S IBX=$G(^SDV(IBB,0)) I IBX'="",(VAUTD=1!($D(VAUTD(+$P(IBX,"^",3))))) S IBDFN=+$P(IBX,"^",2) D
  1. .. Q:$D(^TMP("IBEMP",$J,IBDFN)) S Y=IBB D DD^%DT S IBAPDT=$P(Y,"@",1)
  1. .. S IBAPTYP=$O(^SDV(IBB,"CS",0)),IBAPTYP=$P($G(^SDV(IBB,"CS",+IBAPTYP,0)),"^",5),IBAPTYP=$P($G(^SD(409.1,+IBAPTYP,0)),"^",1)
  1. .. D PAT
  1. K IBB,IBE,IBX,IBY,IBCLN,IBXP,IBDFN,IBAPDT,IBAPTYP,X,Y
  1. Q
  1. ;
  1. ;Input: IBB,IBDFN,IBAPTYP,IBAPDT
  1. PAT ;gather data on patients with no insurance at time of care
  1. N IBX,IBY
  1. I $D(^TMP("IBEMP",$J,IBDFN)) G PEND ; quit if this patient has already been processed
  1. S ^TMP("IBEMP",$J,IBDFN)="" ; once a pt is checked don't check again
  1. S DFN=IBDFN,IBINDT=IBB D ^IBCNS G:IBINS PEND ; quit if patient has insurance
  1. D DEM^VADPT G:+VADM(6) PEND ; quit if patient is dead
  1. D ELIG^VADPT S IBPELG=$G(^DIC(8,+VAEL(1),0)),IBPELG=$S($P(IBPELG,"^",3)'="":$P(IBPELG,"^",3),1:$E($P(VAEL(1),"^",2),1,4)) K VAEL
  1. D OPD^VADPT S IBSES=$P($G(^DPT(DFN,.25)),"^",15) ; spouses employment status
  1. ;
  1. ;get patient and spouse's employer data
  1. ;add to report if patient or spouse employment status is employed or the patients or spouse employer name is defined
  1. S DFN=IBDFN F Z=5,6 S VAOA("A")=Z D OAD^VADPT I VAOA(9)'=""!(Z=5&("1245"[+VAPD(7)))!(Z=6&("1245"[+IBSES)) D K VAOA
  1. . S IBZ=$S(VAOA("A")=5:"P",1:"S"),IBADD="",IBADDN=VAOA(9),VAOA(5)=$P(VAOA(5),"^",2),IBX=0
  1. . S IBY=$A(IBADDN) I IBY>96,IBY<123 S IBY=IBY-82 ; deal with lower case
  1. . I IBY<IBRGB!(IBY>IBRGE) Q ; is employer name within range?
  1. . I IBADDN="" S (VAOA(9),IBADDN)="{EMPLOYER NOT SPECIFIED}"
  1. . F IBI=9,1:1:6,8 S IBX=IBX+1 I VAOA(IBI)'="" S $P(IBADD,"^",IBX)=VAOA(IBI)
  1. . S IBY="",IBX=1
  1. . I $D(^TMP("IBEMP",$J,"E",IBADDN)) F S IBY=$O(^TMP("IBEMP",$J,"E",IBADDN,IBY)) Q:IBY="" Q:^TMP("IBEMP",$J,"E",IBADDN,IBY)=IBADD S IBX=IBX+1
  1. . S ^TMP("IBEMP",$J,"E",IBADDN)=+$G(^TMP("IBEMP",$J,"E",IBADDN))+1
  1. . S ^TMP("IBEMP",$J,"E",IBADDN,IBX)=IBADD
  1. . S ^TMP("IBEMP",$J,"E",IBADDN,IBX,VADM(1),IBDFN,IBZ)=""
  1. . S ^TMP("IBEMP",$J,IBDFN)=VADM(1)_"^"_$P(VADM(2),U,2)_"^"_IBAPDT_"^"_IBAPTYP_"^"_IBPELG
  1. . I IBZ="P" D OPD^VADPT S ^TMP("IBEMP",$J,IBDFN,IBZ)=VADM(1)_"^"_VAPD(6)_"^"_$P(IBES,"^",+VAPD(7))_"^"_$P(VADM(2),"^",2) Q
  1. . D GETREL^DGMTU11(DFN,IBZ,IBEND) S IBY=$G(DGREL("S"))
  1. . S ^TMP("IBEMP",$J,IBDFN,IBZ)=$$NAME^DGMTU1(+IBY)_"^"_$P($G(^DPT(DFN,.25)),"^",14)_"^"_$P(IBES,"^",+IBSES)_"^"_$$SSN^DGMTU1(+IBY)
  1. PEND K VAIP,VADM,VAEL,VAPD,VAOA,DGREL,IBINDT,IBINS,DFN,IBPELG,IBSES,IBPAT,IBADD,IBADDN,IBI,IBX,IBY,IBZ,Z
  1. Q