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