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

APSQAWP.m

Go to the documentation of this file.
APSQAWP ;IHS/DSD/ENM - MATCH LOCAL NDC WITH FACTS & COMPARISON NDC ; [ 08/29/2003  3:11 PM ]
 ;;6.0;IHS PHARMACY MODIFICATIONS;**3,4**;11/11/2002
 ;TRIGGERED FROM NDC FIELD OF DRUG FILE UPDATE AWP,AAC 11/11/2002
 ;THIS WAS THE APSQAWP2 ROUTINE
 Q
 ;
VSET I $D(^PSDRUG(APSPIRN,"I")) Q  ;QUIT IF DRUG IS INACTIVE
 K XMB  ;BE SAFE
 S XMB(9)=$S($G(DUZ)>0:$P($G(^VA(200,DUZ,0)),"^",1),1:"UNKNOWN")  ;PERSON UPDATING
 S APSQCNT=0  ;A COUNTER FOR ENTRIES IN BULLETIN
 S APSDNAME=$P(^PSDRUG(APSPIRN,0),"^")
 S APSPNDC2=""
 I $L(APSPNDC)=11 S APSPNDC2=APSPNDC
 I $L(APSPNDC)<11 D  ;
 .I $L(APSPNDC)=10 S APSPNDC2="0"_APSPNDC
 ;I $L(APSPNDC)=9 S APSPNDC2="00"_APSPNDC
 I $L(APSPNDC)<10!($L(APSPNDC)>11) S APSPERR=4 D ERR  ;NDC < 10 & > 11 DIGITS
 S APSPNOD1=$S($D(^PSDRUG(APSPIRN,660)):^PSDRUG(APSPIRN,660),1:"UNK")
 I APSPNOD1="UNK" S APSPERR=1 D ERR  ;660 NODE MISSING
 S APSP("DISP U")=$P($G(APSPNOD1),"^",5)
 I APSP("DISP U")="" S APSPERR=2 D ERR  ;DISPENSE UNIT MISSING
 ;LOOK IN APSAMDF FOR A MATCHING NDC
 S APSA("MEDI-IRN")=0,APSA("TNDC")=0
 I $O(^APSAMDF("B",APSPNDC2,0)) D  ;
 .S APSA("MEDI-IRN")=$O(^APSAMDF("B",APSPNDC2,APSA("MEDI-IRN")))
 .I APSA("MEDI-IRN")]"" S APSA("TNDC")=$P(^APSAMDF(APSA("MEDI-IRN"),0),"^")
 I APSA("MEDI-IRN")']""!(APSA("MEDI-IRN")=0) S APSPERR=5 D ERR Q  ;NO NDC MATCH IN M-FILE
 S APSA("NODE0")=^APSAMDF(APSA("MEDI-IRN"),0),APSA("NODE1")=^APSAMDF(APSA("MEDI-IRN"),1),APSA("NODE2")=^APSAMDF(APSA("MEDI-IRN"),2)
 S APSA("NODE4")=$G(^APSAMDF(APSA("MEDI-IRN"),4))  ;IHS/OKCAO/POC 6/28/2002
 S APSA("DISP U")=$P($G(APSA("NODE1")),"^",3)  ;AWP DISP UNIT
 I APSP("DISP U") I APSP("DISP U")'=APSA("DISP U") S APSPERR=3 D ERR  ;DISP U 'MATCH
 ;GRAB AWP DATA FOR DRUG FILE UPDATE
 S APSA("AWP E-DATE")=$P($G(APSA("NODE0")),"^",2),APSA("AWP-P-D-U")=$P($G(APSA("NODE0")),"^",3),APSA("AWP-P-O-U")=$P($G(APSA("NODE0")),"^",4)
 S APSA("ACC-PRICE")=$P(APSA("NODE4"),U,4)  ;IHS/OKCAO/POC 6/28/2002
 ;S APSA("ACC-SIZE")=$P(APSA("NODE4"),U,2)  ;IHS/OKCAO/POC 6/28/2002
 S DIE="^PSDRUG(",DA=APSPIRN,DR="9999999.31////^S X=APSA(""AWP-P-O-U"");9999999.32////^S X=APSA(""AWP-P-D-U"");9999999.33////^S X=APSA(""AWP E-DATE"")"
 I +APSA("ACC-PRICE") S DR=DR_";13////^S X=APSA(""ACC-PRICE"")"
 ;IHS/ITSC/ENM/POC 07/09/03 POC CHANGES
 ;E  S APSPERR=6 D ERR  ;LET'S NOT QUIT BUT DO THE AWP STUFF
 E  D
 .N APSPERR S APSPERR=6 D ERR  ;DON'T QUIT BUT DO AWP STUFF
 .;DON'T CHANGE APSPERR VARIABLE IF DEFINED
 ;I +APSA("ACC-SIZE") S DR=DR_";402////^S X=APSA(""ACC-SIZE"")"
 ;E  S APSPERR=7 D ERR  ;LET'S NOT QUIT BUT DO THE AWP STUFF
 D:($G(APSPERR)>5)!('$G(APSPERR)) ^DIE  ;SO DO IF ERR GR THAN 5-PROBLEM WITH AAC  WHAT ABOUT WHEN APSPERR IS NOT DEFINED IHS/OKCAO/POC 12/10/2002
 K DIE,DA,DR,APSA("AWP-P-O-U"),APSA("AWP-P-D-U"),APSA("AWP E-DATE")
 K APSA("NODE0"),APSA("NODE1"),APSA("NODE2")
 K APSA("NODE4")  ;IHS/OKCAO/POC 6/28/2002
 I '$G(APSPERR) S APSPERR=8 D ERR  ;IHS/OKCAO/POC 7/12/2001 FOR REPORTI
 Q
 ;
DEL ;DELETE THE AWP STUFF IF NDC DELETED IHS/OKCAO/POC
 ;S DIE="^PSDRUG(",DA=APSPIRN,DR="9999999.31////@;9999999.32////@;9999999.33////@"
 S DIE="^PSDRUG(",DA=APSPIRN,DR="9999999.31////@;9999999.32////@;9999999.33////@;13////@"  ;IHS/OKCAO/POC 6/28/2002
 D ^DIE
 K DIE,DA,DR
 Q
ERR ;
 S APSQCNT=APSQCNT+1  ;INCREASE CNT EACH TIME ERROR FOR A DRUG
 ;APPEND DRUG NAMES/ERROR CODES - 
 I APSPERR=1 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - MISSING 660 NODE IN DRUG FILE"
 I APSPERR=2 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - MISSING DISPENSE UNIT IN DRUG FILE"
 I APSPERR=3 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - DISP UNITS DON'T MATCH - Medi = "_APSA("DISP U")_" / Local = "_APSP("DISP U")
 I APSPERR=4 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - NDC less than 10 or greater than 11 DIGITS"
 I APSPERR=5 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - NDC'S DON'T MATCH"
 I APSPERR=6 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - NO ACTUAL ACQUISTION PRICE FOR THIS NDC# IN THE AWP MED-TRANSACTION FILE"  ;IHS/OKCAO/POC 6/28/2002
 ;I APSPERR=7 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - NO ACTUAL ACQUISTION SIZE FOR THIS NDC IN ACC FILE"
 I APSPERR=8 S XMB(APSQCNT)="("_APSPIRN_") "_APSDNAME_"-"_$G(APSPNDC)_"  - NO PROBLEM WITH THIS PRICE UPDATE FOR AWP AND AAC"  ;IHS/OKCAO/POC 7/12/2001 FOR REPORTING NO PROBLEMS
 Q
MSG ;SETUP AND SEND BULLETIN
 ;BULLETIN ALREADY SET UP WITH XMB("ARRAY")
 S XMDUZ="PHARMACY NOTIFICATION"
 S XMB="APSQ DRUG AWP/AAC NOTIFICATION"
 D ^XMB
 Q
ZAP ;CLEAN AWP FIELD FROM DRUG - FOR USE DURING TESTING ONLY
 K ^APSPCTRL("AWP DATE")
 S DIE="^PSDRUG(",APSAIRN=0
 F  S APSAIRN=$O(^PSDRUG(APSAIRN)) Q:'APSAIRN  D  ;
 .K DA,D0
 .S DA=APSAIRN,DR="9999999.31////@;9999999.32////@;9999999.33////@"
 .D ^DIE
 K DIE,APSAIRN,DA,D0,DR
 Q
ZAAP ;KILL ALL VARIABLES ON EXIT
 K XMB,APSLNAME,APSP,APSPDG,APSPNAME,APSPZ,XMDUZ,APSA,APSDNAME,APSPERR,APSPIRN,APSPNDC,APSPNDC2,APSPNOD1,APSPNOD2,J,X,XMSUB,XMTEXT
 K APSP("DISP U"),APSA("MEDI-IRN"),APSA("TNDC"),APSA("NODE0"),APSA("NODE1"),APSA("NODE2"),APSA("NODE3"),APSA("NODE4"),APSQCNT
 Q
ZNDC ;EP - ENTRY POINT TO KILL AND RE-INDEX THE ^PSDRUG("ZNDC") X-REF
 W !!,"Re-Indexing the 'ZNDC' x-ref in file 50..........",!
 K ^PSDRUG("ZNDC") S DIK="^PSDRUG(",DIK(1)="31^ZNDC" D ENALL^DIK
 K DIK
 Q
SINGLE ;EP - COME HERE FOR XREF FROM FILE PSDRUG -A TRIGGER IHS/OKCAO/POC 11/12/98
 Q:$D(APSQNOIN)  ;MULTIPLE DIVISIONS DEFINED FROM RTN APSQRXM TO NOT REINDEX!!! IHS/OKCAO/POC 1/10/2001 PATCH 4 IHS/OKCAO/POC
 S APSPIRN=DA ;IEN
 S APSPNDC=$TR(X,"-")
 S APSQWORK=$S($G(APSQDEL):"DEL^APSQAWP",1:"VSET^APSQAWP")
 D EN^XBNEW("DO^APSQAWP","APS*")
 Q
DO ;IF APSQDEL=1 THEN WILL DELETE ENTRY
 ;N DR,DA,D0,DD,DIE,DIC,X,Y
 ;SET VARIABLE
 D @APSQWORK
 D:'$G(APSQDEL) MSG,ZAAP
 K APSQDEL,APSQWORK
 Q