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

ABMASPLT.m

Go to the documentation of this file.
ABMASPLT ; IHS/SD/SDR - Auto-Split check ;     
 ;;2.6;IHS 3P BILLING SYSTEM;;NOV 12, 2009
 ;
 ; IHS/SD/SDR - V2.5 P8 - task 8
 ;   new routine for auto-splitting of claims
 ;
MAIN(ABMCDFN) ;EP - Check if replacement and auto-split
 Q:+$G(ABMAINS)=0
 D REPLACE  ;replace active insurer
 D SPLIT  ;split into multiple bills
 Q
REPLACE ;
 S ABMAINS=$P($G(^ABMDCLM(DUZ(2),ABMCDFN,0)),U,8)  ;active insurer
 S ABMVTYP=$P($G(^ABMDCLM(DUZ(2),ABMCDFN,0)),U,7)  ;visit type
 S ABMVTE=$G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,0))
 Q:ABMVTE=""  ;visit type isn't set up for insurer
 Q:$O(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,0))=0  ;no replacement entry
 S ABMENC=$P($G(^ABMDCLM(DUZ(2),ABMCDFN,0)),U,8)  ;encounter/service date?
 ;find which entry in insurer multiple is the active insurer
 S ABMINSI=0,ABMRPFLG=0
 F  S ABMINSI=$O(^ABMDCLM(DUZ(2),ABMCDFN,13,ABMINSI)) Q:+ABMINSI=0  D  Q:$G(ABMRPFLG)=1
 .S:(ABMAINS=$P($G(^ABMDCLM(DUZ(2),ABMCDFN,13,ABMINSI,0)),U)) ABMRPFLG=1
 ; a replacement exists; now let's see if there's an active one
 ;S ABMVTEDT="",ABMVFLG=0
 S ABMVTEDT=ABMENC+1,ABMVFLG=0
 F  S ABMVTEDT=$O(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,"B",ABMVTEDT),-1) Q:ABMVTEDT=""  D  Q:ABMVFLG=1
 .S ABMVIEN=0
 .F  S ABMVIEN=$O(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,"B",ABMVTEDT,ABMVIEN)) Q:ABMVIEN=""  D  Q:ABMVFLG=1
 ..I $$ISACTIVE($P($G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,ABMVIEN,0)),U),$P($G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,ABMVIEN,0)),U,2),ABMENC) S ABMVFLG=1
 Q:ABMVFLG=0  ;no active replacement--quit
 ;change active insurer
 K DA,DIE,DR,DIC,DD,DO
 S DA=ABMP("CDFN")
 S DIE="^ABMDCLM(DUZ(2),"
 S DR=".08////"_$P($G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,ABMVIEN,0)),U,3)
 D ^DIE
 S ABMPINS=$P($G(^ABMDCLM(DUZ(2),ABMCDFN,0)),U,8)  ;active insurer
 ;stuff replacenment insurer
 K DA,DIE,DR,DIC,DD,DO
 S DA(1)=ABMCDFN
 S DIE="^ABMDCLM(DUZ(2),"_DA(1)_",13,"
 S DA=ABMINSI
 S DR=".011////"_$P($G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,ABMVIEN,0)),U,3)
 D ^DIE
 ;
 ;change visit type - need a new field called 'replacement visit type" ?
 K DA,DIE,DR,DIC,DD,DO
 S DA=ABMP("CDFN")
 S DIE="^ABMDCLM(DUZ(2),"
 S DR=".07////"_$P($G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,12,ABMVIEN,0)),U,4)
 D ^DIE
 Q
 ;now do splitting if auto-split is YES
SPLIT ;
 I $P($G(^ABMNINS(DUZ(2),ABMAINS,1,ABMVTYP,0)),U,23)="Y" D
 .S ABMVFL=0
 .F  S ABMVFL=$O(^ABMDVTYP(ABMVTYP,2,ABMVFL)) Q:+ABMVFL=0  D
 ..S ABMVFLN=$P($G(^ABMDVTYP(ABMVTYP,2,ABMVFL,0)),U)
 ..K ABMMULT
 ..S:ABMVFLN="8A" ABMMULT=27
 ..S:ABMVFLN="8B" ABMMULT=21
 ..S:ABMVFLN="8C" ABMMULT=25
 ..S:ABMVFLN="8D" ABMMULT=23
 ..S:ABMVFLN="8E" ABMMULT=37
 ..S:ABMVFLN="8F" ABMMULT=35
 ..S:ABMVFLN="8G" ABMMULT=39
 ..S:ABMVFLN="8H" ABMMULT=43
 ..S:ABMVFLN="8I" ABMMULT=33
 ..S:ABMVFLN="8J" ABMMULT=45
 ..I $O(^ABMDCLM(DUZ(2),ABMCDFN,ABMMULT,0))="" Q  ;no entry for multiple on this claim
 ..S X=$P($G(^ABMDCLM(DUZ(2),ABMCDFN,0)),U,1)
 ..Q:'X
 ..K DIC,DA,DR,DIE
 ..S DINUM=$$NXNM^ABMDUTL
 ..Q:DINUM=""
 ..S DIC="^ABMDCLM(DUZ(2),"
 ..S DIC(0)="L"
 ..K DD,DO
 ..D FILE^DICN
 ..Q:+Y<0
 ..S ABMC2=+Y
 ..; standard data for all claims
 ..M ^ABMDCLM(DUZ(2),ABMC2,0)=^ABMDCLM(DUZ(2),ABMCDFN,0)
 ..M ^ABMDCLM(DUZ(2),ABMC2,4)=^ABMDCLM(DUZ(2),ABMCDFN,4)
 ..M ^ABMDCLM(DUZ(2),ABMC2,5)=^ABMDCLM(DUZ(2),ABMCDFN,5)
 ..M ^ABMDCLM(DUZ(2),ABMC2,6)=^ABMDCLM(DUZ(2),ABMCDFN,6)
 ..M ^ABMDCLM(DUZ(2),ABMC2,7)=^ABMDCLM(DUZ(2),ABMCDFN,7)
 ..M ^ABMDCLM(DUZ(2),ABMC2,8)=^ABMDCLM(DUZ(2),ABMCDFN,8)
 ..M ^ABMDCLM(DUZ(2),ABMC2,9)=^ABMDCLM(DUZ(2),ABMCDFN,9)
 ..M ^ABMDCLM(DUZ(2),ABMC2,10)=^ABMDCLM(DUZ(2),ABMCDFN,10)
 ..;
 ..M ^ABMDCLM(DUZ(2),ABMC2,11)=^ABMDCLM(DUZ(2),ABMCDFN,11)  ;pcc visits
 ..M ^ABMDCLM(DUZ(2),ABMC2,13)=^ABMDCLM(DUZ(2),ABMCDFN,13)  ;insurers
 ..M ^ABMDCLM(DUZ(2),ABMC2,17)=^ABMDCLM(DUZ(2),ABMCDFN,17)  ;icds
 ..M ^ABMDCLM(DUZ(2),ABMC2,41)=^ABMDCLM(DUZ(2),ABMCDFN,41)  ;providers
 ..;the specified multiple to be split
 ..I $G(ABMMULT)'="" D
 ...M ^ABMDCLM(DUZ(2),ABMC2,ABMMULT)=^ABMDCLM(DUZ(2),ABMCDFN,ABMMULT)
 ...;should multiple be removed from original claim?
 ...I $P($G(^ABMDVTYP(ABMVTYP,2,ABMVFL,0)),U,2)="Y" D
 ....K DA
 ....S DA=0,DA(1)=ABMCDFN
 ....F  S DA=$O(^ABMDCLM(DUZ(2),ABMCDFN,ABMMULT,DA)) Q:+DA=0  D
 .....S DIK="^ABMDCLM(DUZ(2),"_DA(1)_","_ABMMULT_","
 .....D ^DIK
 ..I $G(ABMMULT)="" M ^ABMDCLM(DUZ(2),ABMC2)=^ABMDCLM(DUZ(2),ABMCDFN)
 Q
 ;GIVEN A ENCOUNTER/SERVICE DATE AND BEGIN/END DATES OF REPLACEMENT INSURER
 ;WHICH REPLACEMENT INSURER IS ACTIVE. NOTE: THERE SHOULD NOT BE MORE THAN ONE
 ;REPLACEMENT INSURER ACTIVE FOR ANY GIVEN DATE
ISACTIVE(EFFDT,ENDDT,TARDATE) ;
 NEW OPENEND
 I EFFDT="",(ENDDT="") Q 0
 S ENDDT=ENDDT  ;TRUE IF ENDING DATE IS AT COB OF ENDING DATE - ANSWER FROM ADRIAN IS IT IS
 ;               IN FORCE FOR ALL OF TODAY
 S OPENEND=ENDDT=""
 I OPENEND I TARDATE=EFFDT!(TARDATE>EFFDT) Q 1
 I TARDATE=EFFDT!(TARDATE=ENDDT) Q 1
 I TARDATE>EFFDT&(TARDATE<ENDDT) Q 1
 Q 0