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

APSQDAWP.m

Go to the documentation of this file.
APSQDAWP ;IHS/ITSC/ENM/POC - CALCULATE THE AWP [ 08/29/2003  3:14 PM ]
 ;;6.0;OUTPATIENT PHARMACY;**3,4**;11/11/2002
 ;ADDED IN ACTUAL ACQISTION COST IHS/OKCAO/POC 11/11/2002
 ;CALCULATE THE AWP EITHER FORM THE NDC NUMBER IN THE DRUG FILE OR THE NDC NUMBER IN THE ^APSAMDF FILE IHS/OKCAO/POC 8/18/2000 [ 06/04/2001  12:28 PM ]
AWP(NDC,DRUGIEN,MESS)     ;EP - NDC NUMBER PASSED MESSAGE IF ANY SENT BACK
 ;REPLACED MESS WITH MESS("DIMSG",1) 2/16/2001
 N DRUGNDC,IENAWP,DISPUNT,DISAWP
 N CKDRUG,CKAWP,CKNDCIEN,CKCOST,DISPUNT,DISPDRUG,DISPNAME  ;ENHANCED 5/21/2001
 ;
 ;LOOKING AT DRUG IN DRUG FILE
 ;Q:'$G(NDC) 0  ;ADDED FOR PSORXED ROUTINE PSFROM="WHERE FROM I.E. EDIT"ENHANCED 5/21/2001
 Q:'$G(DRUGIEN) 0  ;ADDED FOR PSORXED ROUTINE
 S (MESS("DIMSG",1),MESS)=""
 S DRUGNDC=$P($G(^PSDRUG(DRUGIEN,2)),"^",4)
 ;I NDC=DRUGNDC S DRUGAWP=$P($G(^PSDRUG(DRUGIEN,999999931)),"^",2) S:DRUGAWP="" MESS="NDC FOR THIS DRUG IN DRUG FILE HAS NO AWP PER DISPENSE UNIT!" Q $FN(DRUGAWP,"",2)
 ;I NDC=DRUGNDC S DRUGAWP=$P($G(^PSDRUG(DRUGIEN,999999931)),"^",2) S:DRUGAWP="" (MESS("DIMSG",1),MESS)="NDC FOR THIS DRUG IN DRUG FILE HAS NO AWP PER DISPENSE UNIT!" Q $FN(DRUGAWP,"",6)
 I ($G(NDC)']"")!(NDC=DRUGNDC) S DRUGAWP=$P($G(^PSDRUG(DRUGIEN,999999931)),"^",2) S:DRUGAWP="" (MESS("DIMSG",1),MESS)="MESSAGE:  NDC FOR THIS DRUG IN DRUG FILE HAS NO AWP PER DISPENSE UNIT!" Q $FN(DRUGAWP,"",6)  ;ENHANCED 5/21/2001
 Q:$G(NDC)']"" 0  ;SHOULD NEVER GET HERE ENHANCED 5/21/2001
 ;
 ;NOW LOOKING AT OTHER DRUGS IN DRUG FILE
 S (MESS("DIMSG",1),MESS)=""
 S NDC=$TR(NDC,"-")  ;STRIP OUT DASHES
 D  Q:$D(CKAWP) CKAWP  ;CKAWP IS AWP FROM ANOTHER DRUG IN THE DRUG FILE ENHANCE 5/21/2001
 .K CKAWP
 .S CKNDCIEN=0 F  S CKNDCIEN=$O(^PSDRUG("ZNDC",NDC,CKNDCIEN)) Q:(CKNDCIEN'=+CKNDCIEN)!$D(CKAWP)  D
 ..I $S('$D(^PSDRUG(+CKNDCIEN,"I")):0,DT'>^("I"):0,1:1) Q  ;INACTIVE DRUG
 ..I $P($G(^PSDRUG(+CKNDCIEN,9999999)),U,3)'=+PSOSITE Q  ;NOT THIS DIVISION PATCH 4 12/21/2001
 ..S CKDRUG=$P(^PSDRUG(+CKNDCIEN,0),U,1)  ;THIS DRUG NAME
 ..S CKAWP=$P($G(^PSDRUG(+CKNDCIEN,999999931)),U,2)  ;THIS DRUG AWP
 ..S CKUNT=$P($G(^PSDRUG(+CKNDCIEN,660)),U,5)  ;THIS DRUG DISPENSE UNIT PER ORDER UNIT
 ..S DISPUNT=$P($G(^PSDRUG(DRUGIEN,660)),U,5)  ;ORIGINAL DRUG DISPENSE UNIT PER ORDER UNIT
 ..;S DISPDRUG= ;ORIGINAL DRUG NAME
 ..I DISPUNT="" S (MESS("DIMSG",1),MESS)="MESSAGE:  NO DISPENSE UNIT PER ORDER UNIT FOR THE DRUG IN THIS DRUG IN THE DRUG FILE" S CKAWP=0 Q
 ..I CKUNT="" S (MESS("DIMSG",1),MESS)="MESSAGE:  NO DISPENSE UNIT PER ORDER UNIT FOR TEH DRUG IN THE DRUG FILE "_CKDRUG S CKAWP=0 Q
 ..I CKUNT'=DISPUNT S (MESS("DIMSG",1),MESS)="WARNING:  DRUG DISPENSE UNIT PER ORDER UNIT "_DISPUNT_" FOR THIS DRUG IN DRUG FILE NOT THE SAME AS DRUG DISPENSE UNIT PER ORDER UNIT "_CKUNT_" FOR THE DRUG "_CKDRUG_" IN THE DRUG FILE" Q
 ..S (MESS("DIMSG",1),MESS)="MESSAGE:  NDC'S DRUG FILE NAME IS "_CKDRUG
 ..Q
 .Q
 ;END OF ENHANCE 5/21/2001
 ;
 ;NOW LOOKING AT AWP MED TRANSACTION FILE
 ;S NDC=$TR(NDC,"-") ;STRIP OUT DASHES
 S (MESS("DIMSG",1),MESS)=""
 S IENAWP=$O(^APSAMDF("B",NDC,""))
 I IENAWP="" S (MESS("DIMSG",1),MESS)="NDC HAS NO AWP ENTRY IN THE AWP MED-TRANSACTION FILE" Q 0
 S DISPUNT=$P($G(^PSDRUG(DRUGIEN,660)),"^",5)
 I DISPUNT="" S (MESS("DIMSG",1),MESS)="MESSAGE:  NO DISPENSE UNITS PER ORDER UNIT FOR THIS DRUG IN DRUG FILE" Q 0
 S DISPAWP=$P($G(^APSAMDF(IENAWP,1)),"^",3)  ;DISPENSE UNITS PER ORDER UNIT OF AWP FILE
 ;I DISPUNT'=DISPAWP S DISPNAME=$P($G(^APSAMDF(IENAWP,2)),"^",1),MESS="DRUG DISPENSE UNIT "_DISPUNT_" NOT SAME AS AWP DISPENSE UNIT "_DISPAWP_" FOR DRUG "_DISPNAME Q 0
 S DISPNAME=$P($G(^APSAMDF(IENAWP,2)),"^",1),(MESS("DIMSG",1),MESS)="MESSAGE:  NDC'S AWP MED TRANSACTION FILE NAME IS "_DISPNAME  ;IHS/OKCAO/POC 2/12/2001 CHANGE TO BE LESS RESTRICTIVE
 I DISPUNT'=DISPAWP S (MESS("DIMSG",1),MESS)="WARNING:  DRUG DISPENSE UNIT PER ORDER UNIT "_DISPUNT_" NOT SAME AS AWP DISPENSE UNIT PER ORDER UNIT "_DISPAWP_" FOR AWP DRUG "_DISPNAME  ;IHS/OKCAO/POC 2/12/2001
 ;ABOVE LINE - WILL SUBSTITUTE THIS LINE FOR ABOVE MAYBE TO ALLOW UNITS NOT TO BE MATCHED UP BUT TAKE FOR ONE DRUG-CHANGE TO BE LESS RESTRICTIVE 
 ;Q $FN($P($G(^APSAMDF(IENAWP,0)),"^",3),"",2) ;AWP PER DISPENSE UNIT
 Q $FN($P($G(^APSAMDF(IENAWP,0)),"^",3),"",6)  ;AWP PER DISPENSE UNIT
 ;
COST(NDC,DRUGIEN,MESS)     ;EP - NDC NUMBER PASSED MESSAGE IF ANY SENT BACK
 ;IMPROVE COST
 N DRUGNDC,IENAWP,DISPUNT,DISAWP,DISPCOST,COSTPU  ;IHS/OCKAO/POC 6/28/2002
 N CKDRUG,CKAWP,CKNDCIEN,CKCOST,DISPUNT,DISPDRUG,DISPNAME  ;ENHANCED 5/21/2001
 ;LOOKING AT THE DRUG IN THE DRUG FILE
 ;Q:'$G(NDC) 0  ;ADDED FOR PSORXED ROUTINE CAN CHECK OUT PSFROM VARIABLEENHANCE 5/21/2001
 Q:'$G(DRUGIEN) 0  ;ADDED FOR PSORXED ROUTINE
 S (MESS("DIMSG",1),MESS)=""
 S DRUGNDC=$P($G(^PSDRUG(DRUGIEN,2)),"^",4)
 ;I NDC=DRUGNDC S DRUGAWP=$P($G(^PSDRUG(DRUGIEN,999999931)),"^",2) S:DRUGAWP="" MESS="NDC FOR THIS DRUG IN DRUG FILE HAS NO AWP PER DISPENSE UNIT!" Q $FN(DRUGAWP,"",2)
 ;I NDC=DRUGNDC S DRUGCOST=$P($G(^PSDRUG(DRUGIEN,660)),"^",6) S:DRUGCOST="" (MESS("DIMSG",1),MESS)="NDC FOR THIS DRUG IN DRUG FILE HAS NO AWP PER DISPENSE UNIT!" Q $FN(DRUGCOST,"",6)
 I ($G(NDC)']"")!(NDC=DRUGNDC) S DRUGCOST=$P($G(^PSDRUG(DRUGIEN,660)),"^",6) S:DRUGCOST="" (MESS("DIMSG",1),MESS)="NDC FOR THIS DRUG IN DRUG FILE HAS NO AAC PER DISPENSE UNIT!" Q $FN(DRUGCOST,"",6)  ;ENHANCE 5/21/2001
 Q:$G(NDC)']"" 0  ;SHOULD NEVER GET HERE ENHANCE 5/21/2001
 ;
 ;LOOKING AT OTHER DRUGS IN THE DRUG FILE ENHANCE 5/21/2001
 S (MESS("DIMSG",1),MESS)=""
 S NDC=$TR(NDC,"-")  ;STRIP OUT DASHES
 D  Q:$D(CKCOST) CKCOST
 .K CKCOST
 .S CKNDCIEN=0 F  S CKNDCIEN=$O(^PSDRUG("ZNDC",NDC,CKNDCIEN)) Q:((CKNDCIEN'=+CKNDCIEN)!$D(CKCOST))  D
 ..I $S('$D(^PSDRUG(+CKNDCIEN,"I")):0,DT'>^("I"):0,1:1) Q  ;INACTIVE DRUG
 ..I $P($G(^PSDRUG(+CKNDCIEN,9999999)),U,3)'=+PSOSITE Q  ;NOT THIS DIVISION PATCH 4
 ..S CKDRUG=$P(^PSDRUG(+CKNDCIEN,0),U,1)  ;THIS DRUG NAME
 ..S CKCOST=$P($G(^PSDRUG(+CKNDCIEN,660)),U,6)  ;THIS DRUG COST
 ..S CKUNT=$P($G(^PSDRUG(+CKNDCIEN,660)),U,5)  ;THIS DRUG DISPENSE UNIT PER ORDER UNIT
 ..S DISPUNT=$P($G(^PSDRUG(DRUGIEN,660)),U,5)  ;THE ORIGINAL DRUG DISPENSE UNIT PER ORDER UNIT
 ..I DISPUNT="" S (MESS("DIMSG",1),MESS)="MESSAGE:  NO DISPENSE UNIT PER ORDER UNIT FOR THIS DRUG IN DRUG FILE" S CKCOST=0 Q
 ..I CKUNT="" S (MESS("DIMSG",1),MESS)="MESSAGE:  NO DISPENSE UNIT PER ORDER UNIT FOR THE DRUG IN THE DRUG FILE "_CKDRUG S CKCOST=0 Q
 ..I CKUNT'=DISPUNT S (MESS("DIMSG",1),MESS)="WARNING:  DRUG DISPENSE UNIT PER ORDER UNIT OF "_DISPUNT_" FOR THIS DRUG NOT THE SAME AS DRUG DISPENSE UNIT PER ORDER UNIT OF "_CKUNT_" FOR THE DRUG "_CKDRUG Q
 ..S (MESS("DIMSG",1),MESS)="MESSAGE:  NDC'S DRUG FILE NAME IS "_CKDRUG
 ..Q
 .Q
 ;END OF CHANGES ENHANCE 5/21/2001
 ;
 ;BELOW ARE CHANGES FOR COST IHS/OKCAO/POC 6/28/2002
 S (MESS("DIMSG",1),MESS)=""
 ;S NDC=$TR(NDC,"-")  ;STRIP OUT DASHES
 S IENAWP=$O(^APSAMDF("B",NDC,""))  ;&&
 I IENAWP="" S (MESS("DIMSG",1),MESS)="NDC HAS NO COST ENTRY IN THE AWP MED-TRANSACTION FILE" Q 0
 S DISPUNT=$P($G(^PSDRUG(DRUGIEN,660)),"^",5)
 I DISPUNT="" S (MESS("DIMSG",1),MESS)="NO DISPENSE UNITS PER ORDER UNIT FOR THIS DRUG" Q 0
 S DISPCOST=$P($G(^APSAMDF(IENAWP,1)),"^",3)  ;***DISPENSE UNITS PER ORDER UNIT OF SOME COST FILE ;&&
 S DISPNAME=$P($G(^APSAMDF(IENAWP,2)),"^",1),(MESS("DIMSG",1),MESS)="MESSAGE:  NDC'S COST MED TRANSACTION FILE NAME IS "_DISPNAME
 I DISPUNT'=DISPCOST S (MESS("DIMSG",1),MESS)="WARNING:  DRUG DISPENSE UNIT PER ORDER UNIT "_DISPUNT_" NOT SAME AS COST DISPENSE UNIT PER ORDER UNIT "_DISPCOST_" FOR COST DRUG "_DISPNAME
 S COSTPU=$FN($P($G(^APSAMDF(IENAWP,4)),"^",3),"",6)  ;COST PER UNIT OF COST DRUG FIELD 403 IN AWP FILE
 I 'COSTPU S (MESS("DIMSG",1),MESS)="WARNING:  NO COST PER DISPENSE UNIT PER ORDER UNIT FOR THIS DRUG ENTRY "_DISPNAME_" IN COST FILE"
 Q COSTPU