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

ABSPOSRU.m

Go to the documentation of this file.
  1. ABSPOSRU ;IHS/OIT/SCR - Utilities for POS Insurance Report ;
  1. ;;1.0;PHARMACY POINT OF SALE;**38,46,50**;JUN 01, 2001 ;Build 38
  1. ;;BASED ON FILE ABMRMCRD - 2.6;IHS 3P BILLING SYSTEM;;NOV 12, 2009
  1. Q
  1. MEDICARE(ABSPLIST,ABSPELDT,ABSPDEAD,ABSPCNT,ABSPTOT,ABSPPHRM) ; EP From ABSPOSR7
  1. N ABSPEN,ABSPEIEN,ABSPCOV,ABSPQUIT,ABSPSDT,ABSPEDT,ABSPHRN,ABSPNAM,ABSPHRNS,ABSPPIEN,ABSPHRNN,ABSPOUT
  1. N ABSPPN,ABSPDPT,ABSPHRL,ABSPPAT
  1. S ABSPEN=0,ABSPQUIT=0
  1. F S ABSPEN=$O(^AUPNMCR(ABSPEN)) Q:+ABSPEN=0 D
  1. .S ABSPDPT=$P(^AUPNMCR(ABSPEN,0),U,1)
  1. .Q:$G(^DPT(ABSPDPT,0))="" ;Still have to look out for that...
  1. .I $D(^DPT(ABSPDPT,.35)),$P(^(.35),U,1)]"",$P(^(.35),U,1)<ABSPELDT Q
  1. .S ABSPEIEN=0
  1. .F S ABSPEIEN=$O(^AUPNMCR(ABSPEN,11,ABSPEIEN)) Q:+ABSPEIEN=0 D
  1. ..S ABSPCOV=$P($G(^AUPNMCR(ABSPEN,11,ABSPEIEN,0)),U,3) ;coverage type
  1. ..Q:ABSPCOV'="D"
  1. ..S ABSPPIEN=$P($G(^AUPNMCR(ABSPEN,11,ABSPEIEN,0)),U,4) ; plan name (pointer to ins file)
  1. ..I ($G(ABSPPIEN)="") S ABSPQUIT=1 Q
  1. ..I ($G(ABSPLIST(ABSPPIEN))="") S ABSPQUIT=1 Q ;no entry for insurer on requested list
  1. ..I ABSPDEAD=0,($P($G(^DPT(ABSPEN,.35)),U)'="") S ABSPQUIT=1 Q ;check exclude flag and DOD
  1. ..S ABSPSDT=$P($G(^AUPNMCR(ABSPEN,11,ABSPEIEN,0)),U) ;ELIG START DATE
  1. ..S ABSPEDT=$P($G(^AUPNMCR(ABSPEN,11,ABSPEIEN,0)),U,2) ;ELIG END DATE
  1. ..I (ABSPSDT<=ABSPELDT)&((ABSPEDT>ABSPELDT)!(ABSPEDT="")) D
  1. ...S ABSPHRN=0
  1. ...F S ABSPHRN=$O(^AUPNPAT(ABSPEN,41,ABSPHRN)) Q:+ABSPHRN=0 D
  1. ....S ABSPHRL=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,1) ;location?
  1. ....Q:ABSPHRL=""
  1. ....;now look in ABSPPHRM array to see if this location is one that we are interested in...
  1. ....S ABSPPHRM=""
  1. ....F S ABSPPHRM=$O(ABSPPHRM(ABSPPHRM)) Q:ABSPPHRM="" D
  1. .....S ABSPOUT=""
  1. .....F S ABSPOUT=$O(ABSPPHRM(ABSPPHRM,ABSPOUT)) Q:ABSPOUT="" D
  1. ......;Q:$P(ABSPPHRM(ABSPPHRM,ABSPOUT),U,2)'=ABSPHRL ;add info about this patient when we find a pharmacy/outpatient match
  1. ......Q:ABSPOUT'=ABSPHRL ;add info about this patient when we find a pharmacy/outpatient match
  1. ......S ABSPHRNS=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,5) ;inactive?
  1. ......I (ABSPDEAD=0&ABSPHRN)="I" S ABSPQUIT=1 Q ;check exclude inactive flag and status
  1. ......S ABSPPNAM=$P(ABSPPHRM(ABSPPHRM,ABSPOUT),U,1)
  1. ......Q:ABSPPNAM=""
  1. ......;S ABSPPHRM(ABSPPHRM,ABSPHRL)=ABSPPNAM
  1. ......S ABSPNAM=$P($G(^AUTNINS(ABSPPIEN,0)),U) ;insurer name
  1. ......; S ABSPPN=$P($G(^AUPNMCR(ABSPEN,11,ABSPEIEN,0)),U,6) ;ID
  1. ......S ABSPPN=$$GETMCR^AGUTL(ABSPEN,ABSPELDT) ;ID ; /IHS/OIT/RAM ; 18 DEC 17 ; new method of retrieving MCRE number / MBI.
  1. ......S ABSPHRNN=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,2) ;HRN
  1. ......S ABSPPAT(ABSPHRNN)=$G(ABSPPAT(ABSPHRNN))+1 ;count the number of times we use this patient hrn
  1. ......S ABSPDPT(ABSPDPT)=$G(ABSPDPT(ABSPDPT))+1 ;count the number of times we use this patient DPT
  1. ......S ^TMP($J,"ABSPOSR7",ABSPPHRM,ABSPHRL,ABSPPIEN,ABSPDPT)=ABSPHRNN_U_ABSPSDT_U_ABSPEDT_U_ABSPPN
  1. ......S ABSPCNT(ABSPPHRM,ABSPHRL,ABSPNAM,ABSPPIEN)=$G(ABSPCNT(ABSPPHRM,ABSPHRL,ABSPNAM,ABSPPIEN))+1
  1. ......S ABSPTOT(ABSPPHRM,ABSPHRL,"TOTAL")=$G(ABSPTOT(ABSPPHRM,ABSPHRL,"TOTAL"))+1
  1. ......S:($G(ABSPPAT(ABSPHRNN))=1) ABSPTOT(ABSPPHRM,"TOTAL")=$G(ABSPTOT(ABSPPHRM,"TOTAL"))+1
  1. ......S:($G(ABSPDPT(ABSPDPT))=1) ABSPTOT("TOTAL")=$G(ABSPTOT("TOTAL"))+1
  1. Q
  1. ;
  1. PRIVATE(ABSPLIST,ABSPELDT,ABSPDEAD,ABSPCNT,ABSPTOT,ABSPPHRM) ; EP FROM ABSPOSR7
  1. N ABSPTIEN,ABSPEN,ABSPNS,ABSPSDT,ABSPEDT,ABSPHRN,ABSPHRNS,ABSPNAM,ABSPHRNN,ABSPPN,ABSPHRL,ABSPOUT
  1. S ABSPTIEN=0
  1. F S ABSPTIEN=$O(^AUPNPRVT(ABSPTIEN)) Q:+ABSPTIEN=0 D
  1. .S ABSPEN=0
  1. .F S ABSPEN=$O(^AUPNPRVT(ABSPTIEN,11,ABSPEN)) Q:+ABSPEN=0 D
  1. ..S ABSPNS=$P($G(^AUPNPRVT(ABSPTIEN,11,ABSPEN,0)),U)
  1. ..Q:$G(ABSPLIST(ABSPNS))="" ;not on list
  1. ..S ABSPSDT=$P($G(^AUPNPRVT(ABSPTIEN,11,ABSPEN,0)),U,6)
  1. ..S ABSPEDT=$P($G(^AUPNPRVT(ABSPTIEN,11,ABSPEN,0)),U,7)
  1. ..I ((ABSPSDT=ABSPELDT)!(ABSPSDT<ABSPELDT)),((ABSPEDT>ABSPELDT)!(ABSPEDT="")) D ;inside date range
  1. ...S ABSPHRN=0
  1. ...F S ABSPHRN=$O(^AUPNPAT(ABSPTIEN,41,ABSPHRN)) Q:+ABSPHRN=0 D
  1. ....S ABSPHRL=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,1) ;location?
  1. ....Q:ABSPHRL=""
  1. ....S ABSPPHRM=""
  1. ....;now look in ABSPPHRM array to see if this location is one that we are interested in...
  1. ....F S ABSPPHRM=$O(ABSPPHRM(ABSPPHRM)) Q:ABSPPHRM="" D
  1. .....S ABSPOUT=""
  1. .....N ABSPPAT
  1. .....F S ABSPOUT=$O(ABSPPHRM(ABSPPHRM,ABSPOUT)) Q:ABSPOUT="" D
  1. ......;Q:$P(ABSPPHRM(ABSPPHRM,ABSPOUT),U,2)'=ABSPHRL ;add info about this patient when we find a pharmacy/outpatient match
  1. ......Q:ABSPOUT'=ABSPHRL ;add info about this patient when we find a pharmacy/outpatient match
  1. ......S ABSPHRNS=$P($G(^AUPNPAT(ABSPTIEN,41,ABSPHRN,0)),U,5) ;inactive?
  1. ......I ABSPDEAD=0,ABSPHRNS="I" Q ;check exclude inactive flag and status
  1. ......S ABSPPNAM=$P(ABSPPHRM(ABSPPHRM,ABSPOUT),U,1)
  1. ......Q:ABSPPNAM=""
  1. ......;S ABSPPHRM(ABSPPHRM,ABSPHRL)=ABSPPNAM
  1. ......S ABSPNAM=$P($G(^AUTNINS(ABSPNS,0)),U) ;insurer name
  1. ......S:$P($G(^AUPNPRVT(ABSPTIEN,11,ABSPEN,0)),U,8)'="" ABSPPN=$P($G(^AUPN3PPH($P($G(^AUPNPRVT(ABSPTIEN,11,ABSPEN,0)),U,8),0)),U,4)
  1. ......S ABSPHRNN=$P($G(^AUPNPAT(ABSPTIEN,41,ABSPHRN,0)),U,2) ;HRN
  1. ......S:ABSPHRNN="" ABSPHRNN="NONE"
  1. ......S ABSPPAT(ABSPHRNN)=$G(ABSPPAT(ABSPHRNN))+1 ;count the number of times we use this patient hrn
  1. ......S ABSPDPT(ABSPTIEN)=$G(ABSPDPT(ABSPTIEN))+1 ;count the number of times we use this patient IEN
  1. ......S ^TMP($J,"ABSPOSR7",ABSPPHRM,ABSPHRL,ABSPNS,ABSPTIEN)=ABSPHRNN_U_ABSPSDT_U_ABSPEDT_U_ABSPPN
  1. ......S ABSPCNT(ABSPPHRM,ABSPHRL,ABSPNAM,ABSPNS)=+$G(ABSPCNT(ABSPPHRM,ABSPHRL,ABSPNAM,ABSPNS))+1
  1. ......S ABSPTOT(ABSPPHRM,ABSPHRL,"TOTAL")=$G(ABSPTOT(ABSPPHRM,ABSPHRL,"TOTAL"))+1
  1. ......S ABSPTOT(ABSPPHRM,"TOTAL")=$G(ABSPTOT(ABSPPHRM,"TOTAL"))+1
  1. ......S:($G(ABSPPAT(ABSPHRNN))=1) ABSPTOT(ABSPPHRM,"TOTAL")=$G(ABSPTOT(ABSPPHRM,"TOTAL"))+1
  1. ......S:($G(ABSPDPT(ABSPTIEN))=1) ABSPTOT("TOTAL")=$G(ABSPTOT("TOTAL"))+1
  1. Q
  1. ;
  1. MEDICAID(ABSPLIST,ABSPELDT,ABSPDEAD,ABSPCNT,ABSPTOT,ABSPPHRM) ;EP FROM ABSPOSR7
  1. N ABSPEN,ABSPEIEN,ABSPCOV,ABSPQUIT,ABSPSDT,ABSPEDT,ABSPHRN,ABSPNAM,ABSPHRNS,ABSPINSN,ABSPHRNN,ABSPPN
  1. N ABSPPIEN,ABSPPN,ABSPDPT,ABSPHRL,ABSPPAT,ABSPFND,ABSPINSP,ABSPMFI,ABSPSTP,ABSPOUT
  1. S ABSPEN=0,ABSPQUIT=0
  1. F S ABSPEN=$O(^AUPNMCD(ABSPEN)) Q:+ABSPEN=0 D
  1. .S ABSPDPT=$P(^AUPNMCD(ABSPEN,0),U,1)
  1. .Q:$G(^DPT(ABSPDPT,0))="" ;Still have to look out for that...
  1. .I $D(^DPT(ABSPDPT,.35)),$P(^(.35),U,1)]"",$P(^(.35),U,1)<ABSPELDT Q
  1. .Q:$G(^AUPNMCD(ABSPEN,0))="" ;Why would this happen?
  1. .S ABSPINSP=$P(^AUPNMCD(ABSPEN,0),U,2) ;POINTER TO INSURER FILE
  1. .I $P($G(^AUTNINS(ABSPINSP,0)),U,1)="MEDICAID" D
  1. ..S ABSPSTP=$P($G(^AUPNMCD(ABSPEN,0)),U,4) ;pointer to the state file
  1. ..S ABSPMFI=""
  1. ..S ABSPFND=0
  1. ..F S ABSPMFI=$O(^AUTNINS(ABSPINSP,13,ABSPMFI)) Q:(ABSPMFI="")!ABSPFND D
  1. ...I $P($G(^AUTNINS(ABSPINSP,13,ABSPMFI,0)),U,1)=ABSPSTP D
  1. ....S ABSPPIEN=$P($G(^AUTNINS(ABSPINSP,13,ABSPMFI,0)),U,2)
  1. ....S ABSPFND=1
  1. .S ABSPEIEN=0
  1. .F S ABSPEIEN=$O(^AUPNMCD(ABSPEN,11,ABSPEIEN)) Q:+ABSPEIEN=0 D
  1. ..I ($G(ABSPPIEN)="") S ABSPQUIT=1 Q
  1. ..I ($G(ABSPLIST(ABSPPIEN))="") S ABSPQUIT=1 Q ;no entry for insurer on requested list
  1. ..I ABSPDEAD=0,($P($G(^DPT(ABSPEN,.35)),U)'="") S ABSPQUIT=1 Q ;check exclude flag and DOD
  1. ..S ABSPSDT=$P($G(^AUPNMCD(ABSPEN,11,ABSPEIEN,0)),U) ;ELIG START DATE
  1. ..S ABSPEDT=$P($G(^AUPNMCD(ABSPEN,11,ABSPEIEN,0)),U,2) ;ELIG END DATE
  1. ..Q:ABSPSDT=""
  1. ..I (ABSPSDT<=ABSPELDT)&((ABSPEDT>ABSPELDT)!(ABSPEDT="")) D
  1. ...S ABSPHRN=0
  1. ...F S ABSPHRN=$O(^AUPNPAT(ABSPEN,41,ABSPHRN)) Q:+ABSPHRN=0 D
  1. ....S ABSPHRL=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,1) ;location?
  1. ....Q:ABSPHRL=""
  1. ....S ABSPPHRM=""
  1. ....;now look in ABSPPHRM array to see if this location is one that we are interested in...
  1. ....F S ABSPPHRM=$O(ABSPPHRM(ABSPPHRM)) Q:ABSPPHRM="" D
  1. .....S ABSPOUT=""
  1. .....F S ABSPOUT=$O(ABSPPHRM(ABSPPHRM,ABSPOUT)) Q:ABSPOUT="" D
  1. ......;Q:$P(ABSPPHRM(ABSPPHRM,ABSPOUT),U,2)'=ABSPHRL ;add info about this patient when we find a pharmacy/outpatient match
  1. ......Q:ABSPOUT'=ABSPHRL ;add info about this patient when we find a pharmacy/outpatient match
  1. ......S ABSPHRNS=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,5) ;inactive?
  1. ......I (ABSPDEAD=0&ABSPHRN)="I" S ABSPQUIT=1 Q ;check exclude inactive flag and status
  1. ......S ABSPPNAM=$P(ABSPPHRM(ABSPPHRM,ABSPOUT),U,1)
  1. ......Q:ABSPPNAM=""
  1. ......S ABSPNAM=$P($G(^AUTNINS(ABSPPIEN,0)),U) ;insurer name
  1. ......S ABSPPN=$P($G(^AUPNMCD(ABSPEN,0)),U,3) ;ID
  1. ......S ABSPHRNN=$P($G(^AUPNPAT(ABSPEN,41,ABSPHRN,0)),U,2) ;HRN
  1. ......S ABSPPAT(ABSPHRNN)=$G(ABSPPAT(ABSPHRNN))+1 ;count the number of times we use this patient hrn
  1. ......S ABSPDPT(ABSPDPT)=$G(ABSPDPT(ABSPDPT))+1 ;count the number of times we use this patient DPT
  1. ......S ^TMP($J,"ABSPOSR7",ABSPPHRM,ABSPHRL,ABSPPIEN,ABSPDPT)=ABSPHRNN_U_ABSPSDT_U_ABSPEDT_U_ABSPPN
  1. ......S ABSPCNT(ABSPPHRM,ABSPHRL,ABSPNAM,ABSPPIEN)=+$G(ABSPCNT(ABSPPHRM,ABSPHRL,ABSPNAM,ABSPPIEN))+1
  1. ......S ABSPTOT(ABSPPHRM,ABSPHRL,"TOTAL")=+$G(ABSPTOT(ABSPPHRM,ABSPHRL,"TOTAL"))+1
  1. ......S:($G(ABSPPAT(ABSPHRNN))=1) ABSPTOT(ABSPPHRM,"TOTAL")=$G(ABSPTOT(ABSPPHRM,"TOTAL"))+1
  1. ......S:($G(ABSPDPT(ABSPDPT))=1) ABSPTOT("TOTAL")=$G(ABSPTOT("TOTAL"))+1
  1. Q
  1. ;
  1. ;OIT/CAS/RCS 091213 Patch 46 Move subroutines
  1. BDT() ;ENTER BEGINING DATE
  1. N ABSPBDT,DIR,X1,X
  1. W !
  1. K DIR
  1. S DIR(0)="DEX"
  1. S DIR("A")="Enter Beginning Prescription Release Date"
  1. D ^DIR
  1. I $D(DIRUT) Q -1
  1. S ABSPBDT=+Y
  1. S X1=ABSPBDT D C^%DTC
  1. Q X
  1. EDT() ;ENTER END DATE
  1. N ABSPEDT,DIR,X1,X
  1. W !
  1. K DIR
  1. S DIR(0)="DEX"
  1. S DIR("A")="Enter Ending Prescription Release Date"
  1. D ^DIR
  1. I $D(DIRUT) Q -1
  1. S ABSPEDT=+Y
  1. S X1=ABSPEDT D C^%DTC
  1. Q X
  1. CLNC() ; PICK WHICH OR ALL CLINIC PHARMACIES
  1. N DIC,X,Y
  1. S DIC="^ABSP(9002313.56,"
  1. S DIC(0)="AEMQVZ"
  1. S DIC("A")="Please Select a Pharmacy or leave blank for ALL: "
  1. D ^DIC K DIC
  1. I X[U Q -1
  1. I Y=-1 S ABSPPPHM="ALL"
  1. I Y>-1 S ABSPPPHM=$P(Y,U,1),ABSPPHMN=$P(Y,U,2)
  1. Q 1
  1. DEVSEL ; SELECT DEVICE
  1. N ABSPSTOP
  1. S ABSPSTOP=0
  1. D ^%ZIS
  1. I POP D
  1. .D ^%ZIS
  1. .Q
  1. I $D(DUOUT) D
  1. .D ZEND^ABSPOSRZ
  1. .S ABSPSTOP=1
  1. .Q
  1. Q:ABSPSTOP
  1. I POP D
  1. .W "DEVICE UNAVAILABLE" G DEVSEL
  1. Q