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

ACHSRPI1.m

Go to the documentation of this file.
ACHSRPI1 ; IHS/ITSC/PMF - TPF RE-WRITE OF ACHSRPI ;
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**13**;JUN 11,2001
 ;ACHS*3.1*13 11/27/06 IHS/OIT/FCJ PRT POLICY # FR CORRECT FILES
 ;
 ;USED BY DENIAL LETTER ROUTINE ACHSDNL3 TO SHOW INSURANCES HELD BY
 ;PATIENT IF DENIAL REASON = ALTERNATE RESOURCES
 ;
TEST ;THIS LOOP FOR TESTING
 S ACHSFAC=3   ;FOR TESTING
 S U="^",INSTAB=15
 K ACHSEFF
 F  S ACHSFAC=$O(^ACHSF(ACHSFAC)) Q:+ACHSFAC=0  D
 .S ACHSDOC=0
 .F  S ACHSDOC=$O(^ACHSF(ACHSFAC,"D",ACHSDOC)) Q:+ACHSDOC=0  D
 ..S ACHSFDT=$P($G(^ACHSF(ACHSFAC,"D",ACHSDOC,3)),U)
 ..S ACHSTDT=$P($G(^ACHSF(ACHSFAC,"D",ACHSDOC,3)),U,2)
 ..S DFN=$P($G(^ACHSF(ACHSFAC,"D",ACHSDOC,0)),U,22)
 ..D PVTINS(DFN,ACHSFDT,ACHSTDT)
 ..D SUPINS(DFN,ACHSFDT,ACHSTDT)
 ..D BOX3H(DFN,.ACHSEFF)
 Q
 ;
 ;
 ;DFN=PATIENT INTERNAL NUMBER
 ;ACHSFDT= AUTHORIZED FROM DATE
 ;ACHSEDT= ATUHORIZED TO DATE
 ;
 ;GET PRIVATE INSURANCE
 ;(PATIENT INTERNAL NUMBER,AUTH FROM DATE,AUTH TO DATE,FACILITY NUMBER,DOCUMENT NUMBER,IGNORE AUTHORZATION DATES)
 ;CALLED BY ACHDNL3
 ;
PVTINS(DFN,ACHSFDT,ACHSTDT,ACHSFAC,ACHSA,IGNORE) ;EP from ACHSDNL3
 Q:DFN=""
 S INSTAB=15
 S ACHSDOC=$P($G(^ACHSDEN(ACHSFAC,"D",ACHSA,0)),U)    ;DOC 0 NODE
 S DTOFSERV=$P($G(^ACHSDEN(ACHSFAC,"D",ACHSA,0)),U,4) ;DATE OF MEDICAL SERVICE
 S ACHSGLOB="AUPNPRVT"
 S INSDA=0
 F X=1:1 S INSDA=$O(^AUPNPRVT(DFN,11,INSDA)) Q:+INSDA=0  D
 .S ACHSPINS=$G(^AUPNPRVT(DFN,11,INSDA,0))
 .S ACHSPEDT=$P(ACHSPINS,U,6)   ;POLICY EFFECTIVE DATE
 .S ACHSPTDT=$P(ACHSPINS,U,7)   ;POLICY TERMINATION DATE
 .;
 .;CHECK IF DATE OF MEDICAL SERVICE IS BEFORE POLICY EFFECTIVE DATE
 .I DTOFSERV<ACHSPEDT Q
 .;CHECK IF DATE OF MEDICAL SERVICE IS AFTER POLICY TERMINATION DATE
 .I DTOFSERV>ACHSPTDT Q
 .I X=1 W !!?INSTAB,"PRIVATE INSURANCE COVERAGE",!?INSTAB,"BASED ON DATE OF SERVICE: " S Y=DTOFSERV X ^DD("DD") W Y
 .;ACHS*3.1*13 11/27/06 IHS/OIT/FCJ PRT POLICY # FR CORRECT FILES
 .;S ACHSPNUM=$P(ACHSPINS,U,2)   ;POLICY NUMBER
 .I $P(ACHSPINS,U,8),$D(^AUPN3PPH($P(ACHSPINS,U,8),0)) S ACHSPNUM=$P(^AUPN3PPH($P(ACHSPINS,U,8),0),U,4) ;POLICY NUMBER
 .S ACHSINSU=$P(ACHSPINS,U)     ;INSURER PTR TO INSURER FILE 9999999.18
 .I ACHSINSU="" S ACHSINAM=" --- "
 .E  S ACHSINAM=$P($G(^AUTNINS(ACHSINSU,0)),U)    ;INSURER NAME
 .D RESULT(ACHSPEDT,ACHSPTDT,ACHSFDT,ACHSTDT,ACHSINAM,ACHSPNUM,IGNORE,DTOFSERV)
 D END
 Q
 ;
 ;LOOK FOR SUPPLEMENTAL INSURANCE ; MEDICARE,MEDICAID,RAILROAD
 ;(PATIENT INTERNAL NUMBER,AUTH FROM DATE,AUTH TO DATE,FACILITY NUMBER,DOCUMENT NUMBER,IGNORE AUTHORIZATION DATES)
 ;CALLED BY ACHDNL3
 ;
SUPINS(DFN,ACHSFDT,ACHSTDT,ACHSFAC,ACHSA,IGNORE) ;EP from ACHSDNL3
 Q:DFN=""
 N ACHSEIN
 S INSTAB=15
 S ACHSDOC=$P($G(^ACHSDEN(ACHSFAC,"D",ACHSA,0)),U)    ;DOC 0 NODE
 S DTOFSERV=$P($G(^ACHSDEN(ACHSFAC,"D",ACHSA,0)),U,4) ;DATE OF MEDICAL SERVICE
 F ACHSGLOB="^AUPNMCR","^AUPNMCD","^AUPNRRE" D
 .S INSDA=0
 .S ACHSEIN=DFN I ACHSGLOB["MCD" S ACHSEIN=$O(^AUPNMCD("B",DFN,""))
 .I ACHSEIN="" Q
 .;
 .;9/13/01  pmf  several lines changed below.  DFN replaced ACHSEIN
 .;
 .F X=1:1 S INSDA=$O(@ACHSGLOB@(ACHSEIN,11,INSDA)) Q:+INSDA=0  D
 ..S ACHSPINS=$G(@ACHSGLOB@(ACHSEIN,11,INSDA,0))    ;
 ..S ACHSPIN0=$G(@ACHSGLOB@(ACHSEIN,0))          ;ZERO NODE
 ..S ACHSPEDT=$P(ACHSPINS,U)     ;POLICY EFFECTIVE DATE
 ..S ACHSPTDT=$P(ACHSPINS,U,2)   ;POLICY TERMINATION DATE
 ..;
 ..;CHECK IF DATE OF MEDICAL SERVICE IS BEFORE POLICY EFFECTIVE DATE
 ..I DTOFSERV<ACHSPEDT Q
 ..;CHECK IF DATE OF MEDICAL SERVICE IS AFTER POLICY TERMINATION DATE
 ..I DTOFSERV>ACHSPTDT Q
 ..;
 ..;I X=1 W !!?INSTAB,"SUPPLEMENTAL INSURANCE COVERAGE",!?INSTAB,"BASED ON DATE OF SERVICE: " S Y=DTOFSERV X ^DD("DD") W Y
 ..;
 ..S ACHSPNUM=""
 ..I ACHSGLOB="^AUPNRRE" S ACHSPNUM=$P(ACHSPIN0,U,4)
 ..E  S ACHSPNUM=$P(ACHSPIN0,U,3)   ;POLICY NUMBER
 ..S ACHSINSU=$P(ACHSPIN0,U,2)   ;INSURER PTR TO INSURER FILE 9999999.18
 ..I ACHSINSU="" S ACHSINAM=" --- "
 ..E  S ACHSINAM=$P($G(^AUTNINS(ACHSINSU,0)),U)      ;INSURER NAME
 ..I ACHSGLOB="^AUPNMCR" S ACHSISUF=$P(ACHSPIN0,U,4)  ;SUFFIX PTR TO
 ..E  S ACHSISUF=""                                  ;MEDICARE SUFFIX
 ..;                                                 ;9999999.32
 ..I ACHSISUF'="" S ACHSISUF=$P($G(^AUTTMCS(ACHSISUF,0)),U)
 ..I ACHSGLOB="^AUPNRRE" S ACHSIPRE=$P(ACHSPIN0,U,3) ;PREFIX PTR TO
 ..E  S ACHSIPRE=""                                   ;RAILROAD PREFIX
 ..I ACHSIPRE'="" S ACHSIPRE=$P($G(^AUPNRRE(ACHSIPRE,0)),U)  ;9999999.33
 ..S ACHSPNUM=ACHSIPRE_" "_ACHSPNUM_" "_ACHSISUF
 ..D RESULT(ACHSPEDT,ACHSPTDT,ACHSFDT,ACHSTDT,ACHSINAM,ACHSPNUM,IGNORE,DTOFSERV)
 D END
 Q
 ;
 ;
 ;DECIDE WHETHER POLICY IS GOOD FOR AUTHORIZED DATE RANGE
 ;(POLICY EFFECT. DATE,POLICY TERM. DATE,AUTH FROM DATE,AUTH TO DATE)
 ;
POLGOOD(ACHSPEDT,ACHSPTDT,ACHSFDT,ACHSTDT,IGNORE) ;
 S:ACHSPTDT="" ACHSPTDT=9999999
 S:ACHSTDT="" ACHSTDT=9999999
 ;
 I ACHSPEDT="" Q 10                      ;MUST HAVE A POLICY EFFECTIVE
                                         ;DATE
 ;
 I ACHSFDT="" Q 15                       ;MUST HAVE AUTHORIZE FROM DATE
 ;
                                         ;
 I ACHSPTDT<ACHSFDT Q 20                 ;POLICY IS NO LONGER EFFECTIVE
                                         ;
                                         ;
 I ACHSPTDT=9999999,ACHSTDT=9999999 D  S Y=X X ^DD("DD") Q 200_U_Y
 .                                       ;IF POLICY TERMINATION DATE AND
 .                                       ;AUTHORIZATION TO DATE ARE OPEN
 .                                       ;TAKE LATEST OF THE TWO AS EFF
 .S X=$S(ACHSPEDT>ACHSFDT:ACHSPEDT,1:ACHSFDT)
 ;
 I ACHSPTDT=ACHSPEDT!(ACHSPTDT<ACHSPEDT) Q 30
                                         ;IF POLICY EFFECTIVE DATE
                                         ;EQUALS POLICY TERMINATION
                                         ;DATE OR POLICY TERMINATION
                                         ;DATE IS LESS THAN THE EFFEC.
                                         ;DATE THEN INVALID POLICY DATES
                                         ;
 I ACHSPEDT<(ACHSFDT+1),(ACHSPTDT>(ACHSTDT+1)) Q 40
                                        ;IF POLICY EFFECTIVE DATE LESS
                                        ;THAN AUTH. FROM DATE AND
                                        ;POLICY TERMINATION DATE IS
                                        ;GREATER THAN AUTHORIZATION TO
                                        ;THEN FULL AUTH RANGE IS COVERE
 ;
 I ACHSPEDT>(ACHSFDT-1),(ACHSPTDT<(ACHSTDT+1)) Q 45
                                         ;IF POLICY EFFECTIVE DATE IS
                                         ;GREATER THAN AUTH. FROM DATE
                                         ;AND THE POLICY TERM. DATE IS
                                         ;LESS THAN THE AUTH. TO DATE
                                         ;THEN PARTIAL AUTH
                                         ;RANGE IS COVERED
 ;
 I ACHSPEDT>ACHSTDT Q 50                 ;IF POLICY EFFECTIVE DATE
                                         ;IS GREATER THAN AUTH TO DATE
                                         ;THEN NO COVERAGE
 ;
 I ACHSPTDT<ACHSFDT Q 20                  ;IF POLICY TERM. DATE IS LESS
                                         ;THAN THE AUTH FROM DATE THEN
                                         ;NO COVERAGE
 ;
 ;
 Q 100                                   ;UNDETERMINED
 ;
 ;
 ;PRINT RESULTS
 ;(POLICY EFFECT. DATE,POLICY TERM. DATE,AUTH FROM DATE,AUTH TO DATE,INSURER NAME,POLICY NUMBER)
 ;
RESULT(ACHSPEDT,ACHSPTDT,ACHSFDT,ACHSTDT,ACHSINAM,ACHSPNUM,RESULT,DTOFSERV) ;
 S:$G(ACHSPEDT)="" ACHSPEDT=" --- "
 S:$G(ACHSPTDT)="" ACHSPTDT=" --- "
 S:$G(ACHSFDT)="" ACHSFDT=" --- "
 S:$G(ACHSTDT)="" ACHSTDT=" --- "
 S:$G(ACHSINAM)="" ACHSINAM=" --- "
 S:$G(ACHSPNUM)="" ACHSPNUM=" --- "
 S STAT=$$POLGOOD(ACHSPEDT,ACHSPTDT,ACHSFDT,ACHSTDT)
 ;
 ;W !!!,"GLOBAL: ",$G(ACHSGLOB)
 ;W !,"PATIENT: ",DFN,?35,"COVERAGE STATUS"
 S INSTAB=15                                 ;INSURANCE INFO TAB
 W !!?INSTAB,"INSURER: ",ACHSINAM
 W !?INSTAB,"POLICY #: ",ACHSPNUM
 ;
 I 'IGNORE D
 . W !?INSTAB,"FOR AUTH. DATE RANGE: "
 . ;
 . ;here we translate the value of STAT into a human readable
 . ;phrase.  we have to keep line length down, so we do it
 . ;in up to three steps.
 . S ACHSYAYA=$S(+STAT=15:"MUST HAVE AUTH FROM DATE",+STAT=1:"YES",+STAT=100:"UNDETERMINED",+STAT=200:"YES AS OF "_$P(STAT,U,2),1:"")
 . I ACHSYAYA="" S ACHSYAYA=$S(+STAT=10:"POLICY EFFECTIVE DATE MISSING",+STAT=20:"POLICY EXPIRED",+STAT=30:"INVALID POLICY DATES",+STAT=40:"FULL COVERAGE",1:"")
 . I ACHSYAYA="" S ACHSYAYA=$S(+STAT=45:"PARTIAL COVERAGE",+STAT=50:"POLICY BEGINS AFTER AUTH ENDS",+STAT=0:"NO INACTIVE",1:"UNDETERMINED")
 . W ACHSYAYA K ACHSYAYA
 . Q
 ;
 ;
 W !?INSTAB,"POLICY BEGIN: " S Y=ACHSPEDT X ^DD("DD") W Y
 W !?INSTAB,"POLICY END: " S Y=ACHSPTDT X ^DD("DD") W Y
 ;
 I 'IGNORE W !?INSTAB,"AUTH FROM: " S Y=ACHSFDT X ^DD("DD") W Y
 I 'IGNORE W !?INSTAB,"AUTH TO: " S Y=ACHSTDT X ^DD("DD") W Y
 ;
 I (U_1_U_200_U_40_U_45_U)'[(U_+STAT_U) S ACHSEFF(DFN,ACHSINAM,ACHSPEDT,ACHSPTDT,ACHSPNUM)="NO EFFECTIVE POLICIES FOUND"
 ;SET THE EFFECTIVE COVERAGE ARRAY
 S ACHSEFF(DFN,ACHSINAM,ACHSPEDT,ACHSPTDT,ACHSPNUM)=STAT
 Q
 ;
 ;DO OTHER HEALTH INSURANCE BOX 3 H
 ;(PATIENT INTERNAL NUMBER,ARRAY OF GOOD POLICIES)
BOX3H(DFN,ACHSEFF) ;
 Q:DFN=""
 Q:'$D(ACHSEFF(DFN))
 W !!!,"*****************"
 S ACHSNAM=""
 F  S ACHSNAM=$O(ACHSEFF(DFN,ACHSNAM)) Q:ACHSNAM=""  D
 .S ACHSPEDT=""
 .F  S ACHSPEDT=$O(ACHSEFF(DFN,ACHSNAM,ACHSPEDT)) Q:ACHSPEDT=""  D
 ..S ACHSPTDT=""
 ..F  S ACHSPTDT=$O(ACHSEFF(DFN,ACHSNAM,ACHSPEDT,ACHSPTDT)) Q:ACHSPTDT=""  D
 ...S ACHSPNUM=""
 ...F  S ACHSPNUM=$O(ACHSEFF(DFN,ACHSNAM,ACHSPEDT,ACHSPTDT,ACHSPNUM)) Q:ACHSPNUM=""  D
 ....I ACHSEFF(DFN,ACHSNAM,ACHSPEDT,ACHSPTDT,ACHSPNUM)[("NO EFFECTIVE") W !,"***NO EFFECTIVE POLICIES FOUND!***" Q
 ....W !,DFN_"  "_$P($G(^DPT(DFN,0)),U)
 ....W !,$E(ACHSNAM,1,8)_" "_ACHSPNUM
 ....W !?8,"EFF: "
 ....I ACHSPEDT=9999999 W ""
 ....E  S Y=ACHSPEDT X ^DD("DD") W Y
 ....W "  TERM: "
 ....I ACHSPTDT=9999999 W ""
 ....E  S Y=ACHSPTDT X ^DD("DD") W Y
 W !,"*******************",!!!
 Q
 ;
 ;CLEAN UP VARAIABLES USED IN THIS ROUTINE
END ;
 K ACHSGLOB,ACHSFAC,ACHSFDT,ACHSEFF,ACHSINAM,ACHSIPRE,ACHSINSU,ACHSISUF
 K ACHSNAM,ACHSPEDT,ACHSPIN0,ACHSPINS,ACHSPNUM,ACHSPTDT,ACHSTDT,DTOFSERV,IGNORE,INSDA,INSTAB,RESULT,X,Y
 Q