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

IBCOPP2.m

Go to the documentation of this file.
  1. IBCOPP2 ;ALB/NLR - LIST INS. PLANS BY CO. (COMPILE) ; 20-OCT-2015
  1. ;;2.0;INTEGRATED BILLING;**28,62,93,516,528,549**;21-MAR-94;Build 54
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. EN ; Queued Entry Point for Report.
  1. ; Input: IBAI - 0 - User selected Insurance Companies
  1. ; 1 - Run report for all Insurance Companies with Plans
  1. ; IBAIA - 0 - Only select Inactive Insurance Companies
  1. ; 1 - Only select Active Insurance Companies
  1. ; 2 - Select both Active and Inactive Insurance Companies
  1. ; IBAIPA 0 - Only select Inactive Insurance Company Plans
  1. ; 1 - Only select Active Insurance Company Plans
  1. ; 2 - Select both Active and Inactive Insurance Company Plans
  1. ; IBAO= E - Output to Excel
  1. ; R - Report
  1. ; IBAPA - 0 - List Insurance Plans by Insurance Company
  1. ; 1 - List Insurance Plans by Insurance Company
  1. ; with Subscriber information
  1. ; IBAPA - 0 - List Insurance Plans by Insurance Company
  1. ; 1 - List Insurance Plans by Insurance Company with Subscriber
  1. ; information
  1. ; IBAPL - 0 - User selected Group Plans
  1. ; 1 - Run report for all Group Plans for each Ins. Co
  1. ; NOTE: only used if IBAI=1, otherwise, some Insurance
  1. ; companies may select all Group Plans and some
  1. ; may be use selected Group Plans
  1. ; ^TMP("IBINC",$J,IBIC,IBCNS,IBPTR)="" - Selected Ins Cos/Plans
  1. ; Required if all Insurance Companies and all Group Plans
  1. ; not selected Where:
  1. ; IBIC - Insurance Company Name
  1. ; IBCNS - IEN of the selected Insurance Company, file 36
  1. ; IBPTR - IEN of the selected Group Plan, file 355.3
  1. ;
  1. ; Compile report data
  1. N GIEN,XX
  1. S IBI=0
  1. K ^TMP($J,"PR"),^TMP($J,"PL")
  1. ;
  1. ; Display all Insurance Companies and all Group Plans
  1. I IBAI,IBAPL D
  1. . S IBIC1=""
  1. . F S IBIC1=$O(^DIC(36,"B",IBIC1)) Q:IBIC1="" D
  1. . . S IBCNS=0
  1. . . F S IBCNS=$O(^DIC(36,"B",IBIC1,IBCNS)) Q:'IBCNS D
  1. . . . I $D(^IBA(355.3,"B",IBCNS)) D
  1. . . . . S GIEN=$O(^IBA(355.3,"B",IBCNS,"")) ; Group Plan IEN, file 355.3
  1. . . . . ;
  1. . . . . ; Add Insurance Company/Group Plan to 'selected' list
  1. . . . . S ^TMP("IBINC",$J,IBIC1,IBCNS,GIEN)=""
  1. ;
  1. ; Display selected Insurance- user selected companies or plans
  1. S IBIC=""
  1. F S IBIC=$O(^TMP("IBINC",$J,IBIC)) Q:IBIC="" D
  1. . S IBCNS=0
  1. . F S IBCNS=$O(^TMP("IBINC",$J,IBIC,IBCNS)) Q:'IBCNS D GATH
  1. D PRINT
  1. Q
  1. ;
  1. PRINT ; Print report
  1. D ^IBCOPP3
  1. K ^TMP($J,"PR"),^TMP("IBINC",$J)
  1. ;
  1. I $D(ZTQUEUED) S ZTREQ="@" Q
  1. D ^%ZISC
  1. K IBAI,IBAIA,IBAO,IBAIPA,IBAPA,IBAPL,IBCNS,IBCPS,IBCPT,IBCST,IBI,IBIC,IBIC1
  1. Q
  1. ;
  1. GATH ; Gather all data for an Insurance Company.
  1. ; Input: IBI - Current Insurance Company Counter
  1. ; IBIC - Insurance Company Name
  1. ; IBSNS - IEN of the Insurance Company, file 36
  1. ; ^TMP("IBINC",$J,IBIC,IBCNS,IBPTR) - See EN for detail
  1. ; Output: IBI - Updated Insurance Company Counter
  1. ; ^TMP($J,"PR",IBI)=A1^A2^...^A11 Where:
  1. ; IBI - Counter of # of Insurance Companies included
  1. ; (starts at 1)
  1. ; A1 - Ins. Co. Name (1st 25 characters)
  1. ; Leading '*' if inactive
  1. ; A2 - Street Address Line 1
  1. ; A3 - City, State Zip Code (up to 9 digits + dash)
  1. ; A4 - Timely Filing Timeframe
  1. ; A5 - # of total plans for the Insurance Company
  1. ; A6 - # of total subscribers per Insurance Company
  1. ; A7 - # of selected Plans per Insurance Company
  1. ; A8 - # of subscribers per selected plans
  1. ; A9 - Max length of Electronic Plan Type for Ins Co
  1. ; A10 - Max length of Plan Type for Ins Co
  1. ; A11 - Max length of Patient ID for Ins Co
  1. ;
  1. N IBCPS,IBCPT,IBCSS,IBCST,LENEP,LENPID,LENPT,XX
  1. S IBI=IBI+1,(IBCPT,IBCPS,IBCST,IBCSS)=0 ; Initialize counters
  1. S (LENEP,LENPID,LENPT)=0 ; Init Max Elec Plan, Pat Id, Plan Type lengths
  1. D COMP(.LENPID) ; Gather company info
  1. D PLAN(.LENEP,.LENPT) ; Gather plan info
  1. ;
  1. ; Set final company info
  1. S XX=$$COMPINF(IBCNS)
  1. S XX=XX_"^"_IBCPT_"^"_IBCST_"^"_IBCPS_"^"_IBCSS_"^"_LENEP_"^"_LENPT_"^"_LENPID
  1. S ^TMP($J,"PR",IBI)=XX
  1. K ^TMP($J,"PL")
  1. Q
  1. ;
  1. COMP(LENPID) ; Gather Company counts and subscription information, if necessary
  1. ; Input: IBPA - 0 - List Insurance Plans by Insurance Company
  1. ; 1 - List Insurance Plans by Insurance Company
  1. ; with Subscriber information
  1. ; IBAPL - 0 - User selected Group Plans
  1. ; 1 - All Group Plans selected
  1. ; IBCNS - IEN of the insurance company, file #36
  1. ; ^TMP("IBINC",$J,IBIC,ICBNS)) - See EN for details
  1. ; Output: LENPID - Maximum length of Patient ID field for subscribers of
  1. ; this Insurance Company
  1. ; IBCSS - Total # of Subscribers in selected Group Plans
  1. ; IBCST - Total # of Subscribers
  1. ; ^TMP($J,"PR",IBI,IBPTR,IBNAM_"@@"_DFN_"@@"_IBCDFN)=B1^B2^...^B10 Where
  1. ; DFN - IEN of the patient, file 2
  1. ; IBCDFN- Insurance Company multiple
  1. ; IBI - Insurance counter
  1. ; IBNAM - Patient's Name (B1)
  1. ; IBPTR - IEN of the Group Plan, file 355.3
  1. ; B1 - Patient's Name (1st 22 chars)
  1. ; B2 - Last 4 Patient's SSN (with trailing 'P' if pseudo)
  1. ; B3 - Patient's DOB (mm/dd/yy)
  1. ; B4 - Subscriber ID (20 chars max)
  1. ; B5 - Effective Date (mm/dd/yy)
  1. ; B6 - Expiration Date (mm/dd/yy)
  1. ; B7 - Whose Insurance (5 chars max)
  1. ; B8 - Patient ID (30 chars max)
  1. ;
  1. N DFN,IBCDFN,IBIND,IBNAM,IBPTR,IBX,PTLEN,VA,VAERR,VAOA,X,XX,Y
  1. S DFN=0
  1. F S DFN=$O(^DPT("AB",IBCNS,DFN)) Q:'DFN D
  1. . S IBCDFN=0
  1. . ;
  1. . ; NOTE: IBCDFN is the Insurance Company Multiple that contains the
  1. . ; Insurance company with an IEN of IBCNS
  1. . F S IBCDFN=$O(^DPT("AB",IBCNS,DFN,IBCDFN)) Q:'IBCDFN D
  1. . . ;
  1. . . ; Set company subscriber count; plan subscriber counts if necessary
  1. . . ; MRD;IB*2.0*516 - Use $$ZND^IBCNS1 to pull .312 zero node.
  1. . . ;S IBIND=$G(^DPT(DFN,.312,+IBCDFN,0)) Q:+IBIND'=IBCNS
  1. . . S IBIND=$$ZND^IBCNS1(DFN,+IBCDFN)
  1. . . Q:+IBIND'=IBCNS
  1. . . S IBPTR=+$P(IBIND,"^",18) ; Group Plan IEN
  1. . . Q:'+IBPTR
  1. . . S IBCST=IBCST+1 ; Update Total # of Subscribers
  1. . . ;
  1. . . ; Quit if not a selected Group Plan and All Group Plans were not selected
  1. . . I 'IBAPL,'$D(^TMP("IBINC",$J,IBIC,IBCNS,IBPTR)) Q
  1. . . S IBCSS=IBCSS+1 ; Update Tot # of Selected Subscribers
  1. . . S ^TMP($J,"PL",IBPTR)=$G(^TMP($J,"PL",IBPTR))+1
  1. . . Q:'IBAPA ; Subscriber information not selected
  1. . . ;
  1. . . ; Gather Demographic/Policy information
  1. . . ; IB*2.0*549 - Changed fields retrieve for Subscriber Detail display
  1. . . S X=$$PT^IBEFUNC(DFN)
  1. . . S IBNAM=$E($P(X,"^",1),1,22) ; Patient's Name (22 chars)
  1. . . S:IBNAM="" IBNAM="<Pt. "_DFN_" Name Missing>"
  1. . . S IBX=IBNAM
  1. . . ;
  1. . . ; Retrieve last 4 of SSN (last 5 if pseudo SSN)
  1. . . S XX=$$GET1^DIQ(2,DFN_",",.09,"I") ; Patient's SSN
  1. . . S XX=$S($E(XX,$L(XX))="P":$E(XX,$L(XX)-4,$L(XX)),1:$E(XX,$L(XX)-3,$L(XX)))
  1. . . S $P(IBX,"^",2)=XX
  1. . . S XX=$$GET1^DIQ(2,DFN_",",.03,"I") ; Patient's DOB
  1. . . S $P(IBX,"^",3)=$$FMTE^XLFDT(XX,"2DZ")
  1. . . S XX=$P(IBIND,"^",2),XX=$S(XX'="":XX,1:"<NO SUBS ID>")
  1. . . S $P(IBX,"^",4)=XX ; Subscriber ID (20 chars max)
  1. . . S XX=$$FMTE^XLFDT($P(IBIND,"^",8),"2DZ") ; Effective Date
  1. . . S $P(IBX,"^",5)=XX
  1. . . S XX=$$FMTE^XLFDT($P(IBIND,"^",4),"2DZ") ; Expiration Date
  1. . . S $P(IBX,"^",6)=XX
  1. . . ;
  1. . . ; Whose Insurance?
  1. . . S XX=$P(IBIND,"^",6),XX=$S(XX="v":"VET",XX="s":"SPO",XX="o":"OTH",1:"UNK")
  1. . . S $P(IBX,"^",7)=XX
  1. . . S XX=$$GET1^DIQ(2.312,IBCDFN_","_DFN_",",5.01,"I") ; Patient ID
  1. . . S $P(IBX,"^",8)=XX
  1. . . S:LENPID<$L(XX) LENPID=$L(XX)
  1. . . S ^TMP($J,"PR",IBI,IBPTR,IBNAM_"@@"_DFN_"@@"_IBCDFN)=IBX
  1. Q
  1. ;
  1. PLAN(LENEP,LENPT) ; Gather Group Insurance Plan information
  1. ; Input: LENEP - Current Maximum Electronic Plan length for Ins Co
  1. ; LENPT - Current Maximum Plan Type length for Ins Co
  1. ; IBAPL - 0 - User selected Group Plans
  1. ; 1 - All Group Plans
  1. ; IBCNS - IEN of the Insurance Company, file #36
  1. ; IBPTR - IEN of the Group Insurance Plan, file 355.3
  1. ; ^TMP("IBINC",$J,IBIC,ICBNS,IBPTR)) - See EN for details
  1. ; ^TMP($J,"PL",IBPTR) - Total # Subscribers for Group Plan
  1. ; Output: LENEP - Updated Maximum Electronic Plan length for Ins Co
  1. ; LENPT - Updated Maximum Plan Type length for Ins Co
  1. ; IBCPS - Total Number of Selected Group Plans for Ins. Co.
  1. ; IBCPT - Total # of Group Plans for Insurance Company
  1. ; ^TMP($J,"PR",IBI,IBPTR)) - B1^B2^..^B6 where
  1. ; IBI - Counter of # of Insurance Companies included
  1. ; IBPTR- Group Plan IEN
  1. ; B1 - Group Number, field 355.3,2.02
  1. ; B2 - Group Name, field 355.3,2.01
  1. ; B3 - Group Plan Timely Filing Time frame (max len 21)
  1. ; B4 - Electronic Plan Type (max length 26)
  1. ; B5 - Type of Plan (max length 34)
  1. ; B6 - Total # of subscribers for this Group Plan
  1. ;
  1. N IBPTR
  1. S IBPTR=0
  1. F S IBPTR=$O(^IBA(355.3,"B",IBCNS,IBPTR)) Q:'IBPTR D
  1. . S IBCPT=IBCPT+1 ; Total # of Group Plans for Ins. Co.
  1. . ;
  1. . ; Quit if Group Plan was not selected by the user
  1. . I 'IBAPL,'$D(^TMP("IBINC",$J,IBIC,IBCNS,IBPTR)) Q
  1. . S IBCPS=IBCPS+1 ; Total # of Selected Group Plans
  1. . S ^TMP($J,"PR",IBI,IBPTR)=$$PLANINF(IBPTR,.LENEP,.LENPT)_"^"_+$G(^TMP($J,"PL",IBPTR))
  1. Q
  1. ;
  1. PLANINF(PLAN,LENEP,LENPT) ; Return formatted Group Insurance Plan information.
  1. ; Input: PLAN - IEN of the Group Insurance Plan, file #355.3
  1. ; LENEP - Current Maximum Electronic Plan length for Ins Co
  1. ; LENPT - Current Maximum Plan Type length for Ins Co
  1. ; Output: LENEP - Updated Maximum Electronic Plan length for Ins Co
  1. ; LENPT - Updated Maximum Plan Type length for Ins Co
  1. ; Returns: A1^A2^A3^...^AN Where:
  1. ; A1 - Group Plan Number
  1. ; A2 - Group Plan Name (leading '*' if Inactive)
  1. ; A3 - Group Plan Timely Filing Time frame (max len 21)
  1. ; A4 - Electronic Plan Type (max length 26)
  1. ; A5 - Type of Plan (max length 34)
  1. ;
  1. ; IB*2.0*549 Changed output to fields listed above
  1. N NAME,NUM,XX,ZZ
  1. S NUM=$$GET1^DIQ(355.3,PLAN,2.02)
  1. S:NUM="" NUM="<NO GROUP NUMBER>"
  1. S XX=$$GET1^DIQ(355.3,PLAN,.02,"I") ; Group or Individual Plan
  1. S XX=$S(XX=1:"",1:"+")
  1. S ZZ=$$GET1^DIQ(355.3,PLAN,.11,"I") ; Inactive Flag
  1. S ZZ=XX_$S(ZZ=1:"*",1:"")
  1. S $P(XX,"^",1)=ZZ_NUM ; Add Inactive/Individual flags
  1. S NAME=$$GET1^DIQ(355.3,PLAN,2.01)
  1. S:NAME="" NAME="<NO GROUP NAME>"
  1. S $P(XX,"^",2)=NAME ; Group Name
  1. S $P(XX,"^",3)=$$FTFGP^IBCNEUT7(PLAN) ; Timely Filing Time Frame
  1. S ZZ=$$GET1^DIQ(355.3,PLAN_",",.15) ; Electronic Plan Type
  1. S:$L(ZZ)>LENEP LENEP=$L(ZZ) ; Maximum Electronic Plan length
  1. S $P(XX,"^",4)=ZZ
  1. S ZZ=$$GET1^DIQ(355.3,PLAN_",",.09) ; Type of Plan
  1. S:$L(ZZ)>34 ZZ=$E(ZZ,1,34)
  1. S:$L(ZZ)>LENEP LENEP=$L(ZZ) ; Maximum Plan Type length
  1. S $P(XX,"^",5)=ZZ
  1. Q XX
  1. ;
  1. COMPINF(IBCNS) ; Return formatted Insurance Company information
  1. ; Input: IBCNS - IEN of the Insurance Company, file #36
  1. ; Output: A1^A2^A3^A4 Where:
  1. ; A1 - Insurance Company name (first 25 chars)
  1. ; with leading '*' if inactive
  1. ; A2 - Street Address Line 1
  1. ; A3 - City, ST ZIP
  1. ; A4 - Timely Filing
  1. ;
  1. ; IB*2.0*549 Changed output to fields listed above
  1. N ST,X,X0,X11,XX,Z,ZZ
  1. S X0=$G(^DIC(36,IBCNS,0))
  1. S X11=$G(^DIC(36,IBCNS,.11))
  1. S Z=$P(X11,"^",6)
  1. S ST=$S($P(X11,"^",5):$P($G(^DIC(5,$P(X11,"^",5),0)),"^",2),1:"<STATE MISSING>")
  1. S XX=$S($P(X0,"^",5):"*",1:"")
  1. S X=XX_$E($P(X0,"^",1),1,25)
  1. S $P(X,"^",2)=$S($P(X11,"^",1)'="":$P(X11,"^",1),1:"<Street Addr. 1 Missing>")
  1. S $P(X,"^",3)=$P(X11,"^",4)_", "_ST_" "_$E(Z,1,5)_$S($E(Z,6,9)]"":"-"_$E(Z,6,9),1:"")
  1. S $P(X,"^",4)=$$FTFIC^IBCNEUT7(IBCNS)
  1. Q X