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

AUPNSEQ.m

Go to the documentation of this file.
AUPNSEQ ;IHS/SD/EFG - API TO CREATE ARRAY OF SEQUENCED INSURERS ; 10/1/2003 10:00:27 AM
 ;;99.1;IHS DICTIONARIES (PATIENT);**12**;MAR 09, 1999;Build 9
 ;
 ; PASS THE PATIENT IEN, DATE OF SERVICE, AND OPTIONALLY, THE
 ;     CATEGORY TO THIS ROUTINE
 ;     CATEGORIES ARE : 'M' FOR MEDICAL
 ;                      'D' FOR DENTAL
 ;                      'O' FOR OPTOMETRY
 ;                      'R' FOR PHARMACY
 ;                      'P' FOR MENTAL HEALTH
 ;                      'A' FOR AUTO ACCIDENT/TORT
 ;                      'W' FOR WORKMAN'S COMP
 ;
 ; IF A CATEGORY IS PASSED TO THIS ROUTINE, THE ARRAY "SEQAR" WILL
 ; CONTAIN ONLY THE RECORDS FOR THE SPECIFIC CATEGORY.
 ; IF NO CATEGORY IS PASSED, THE ARRAY WILL CONTAIN THE
 ; RECORDS EACH CATEGORY FOR THE SPECIFIED DATE OF SERVICE.
 ;
 ; THE ARRAY'S FIRST SUBSCRIPT IS JOB#
 ;       MAKE SURE WHEN USING THIS API, YOU KILL THE ARRAY
 ;       USING THE JOB# WHEN YOU'RE DONE
 ;
 ; ARRAY LAYOUT :
 ;   INSPTR = INSURER POINTER
 ;            FOR MEDICAID, THIS IS A SCREENED POINTER THAT ONLY
 ;                          ALLOWS "MEDICAID". PLANPTR WILL CONTAIN
 ;                          THE POINTER TO THE SPECIFIC INSURER
 ;   INSTYPE = INSURER TYPE FROM THE .21 FIELD IN THE INSURER FILE
 ;   COV :  FOR MEDICARE AND RAILROAD, THIS WILL BE AN "A" OR "B"
 ;          FOR MEDICAID, THIS IS A FREE TEXT FIELD
 ;          FOR PRIVATE, THIS WILL BE FROM THE COVERAGE POINTER
 ;                       FROM THE POLICY HOLDER FILE
 ;   PLANPTR = MEDICAID IS THE ONLY INSURER THAT USES A PLAN NAME FIELD
 ;           WHICH IS A POINTER BACK TO THE INSURER FILE
 ;   BEGDT = ELIGIBILITY BEGINNING DATE
 ;   ENDDT = ELIGIBILITY ENDING DATE
 ;
START(DFN,DOS,CAT) ; PEP - ENTRY POINT FOR EXTERNAL PACKAGES
 K SEQAR($J)
 I '$D(CAT)  G ALL  ; IF NO CAT, SHOW ALL CATEGORIES FOR DOS
 S AUPNDOS=""       ; ELSE SHOW RECORDS FOR DOS AND SPECIFIC CATEGORY
 K HIT
 F  S AUPNDOS=$O(^AUPNICP("EFF2",DFN,AUPNDOS),-1) Q:'AUPNDOS!$D(HIT)  D
 . I AUPNDOS>DOS Q
 . S AUPNREC=0
 . F  S AUPNREC=$O(^AUPNICP("EFF2",DFN,AUPNDOS,CAT,AUPNREC)) Q:'AUPNREC  D
 .. S SEQREC=$G(^AUPNICP(AUPNREC,0))
 .. S SEQ=$P(SEQREC,U,5)
 .. S INSPTR=$P(SEQREC,U,3)
 .. S INSTYPE=$P(^AUTNINS(INSPTR,2),U,1)
 .. S COV=$P(SEQREC,U,7)
 .. S PLANPTR=$P(SEQREC,U,11)
 .. S BEGDT=$P(SEQREC,U,8)
 .. S ENDDT=$P(SEQREC,U,9)
 .. S HIT=""
 .. S SEQAR($J,CAT,SEQ)=INSPTR_"^"_INSTYPE_"^"_COV_"^"_PLANPTR_"^"_BEGDT_"^"_ENDDT
 Q
ALL ;
 S AUPNDOS=0
 F  S AUPNDOS=$O(^AUPNICP("EFF2",DFN,AUPNDOS)) Q:'AUPNDOS  D
 . I AUPNDOS>DOS Q
 . S AUPNCAT=""
 . F  S AUPNCAT=$O(^AUPNICP("EFF2",DFN,AUPNDOS,AUPNCAT)) Q:AUPNCAT=""  D
 .. S AUPNREC=0
 .. F  S AUPNREC=$O(^AUPNICP("EFF2",DFN,AUPNDOS,AUPNCAT,AUPNREC)) Q:'AUPNREC  D
 ... S SEQREC=$G(^AUPNICP(AUPNREC,0))
 ... S SEQ=$P(SEQREC,U,5)
 ... S INSPTR=$P(SEQREC,U,3)
 ... S INSTYPE=$P(^AUTNINS(INSPTR,2),U,1)
 ... S COV=$P(SEQREC,U,7)
 ... S PLANPTR=$P(SEQREC,U,11)
 ... S BEGDT=$P(SEQREC,U,8)
 ... S ENDDT=$P(SEQREC,U,9)
 ... S SEQAR($J,AUPNCAT,SEQ)=INSPTR_"^"_INSTYPE_"^"_COV_"^"_PLANPTR_"^"_BEGDT_"^"_ENDDT
 Q