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

APSQNF.m

Go to the documentation of this file.
APSQNF ;IHS/ASDS/ENM/POC - PROGRAM TO DEAL WITH NON FORMULARY REQUEST 
 ;;6.0;IHS PHARMACY MODIFICATIONS;**3**;FEB 20, 2001
 ;FIRST CHECK IF IEN OF DRUG AND PT DFN
 ;!!! DONT FORGET TO SET FLAG APSQNF TO SET FIELD RX POINTER WHEN PRINT
 Q:('$D(PSODFN))!('$D(PSODRUG("IEN")))
 Q:'($P($G(^PSDRUG(PSODRUG("IEN"),0)),"^",9))  ;CHECK STATUS OF NF FIELD
INIT S U="^"
 D NF(PSODRUG("IEN"),PSODFN) ;CHECK FOR ANY NON FORMULARY REQUESTS FOR THIS PATIENT AND DRUG IN FORM OF APSQDT ARRAY
 ;
 I APSQLAST=0 W !,"A NON FORMULARY REQUEST DOES NOT EXISTS FOR THIS PATIENT FOR THIS DRUG" S APSQDIR=1
 I APSQLAST>0,$P(APSQLAST(APSQLAST),U,2) W !,"A NON FORMULARY REQUEST EXISTS FOR THIS PATIENT DATED "_$$FMTE^XLFDT(9999999-APSQLAST),!,"BUT PRESCRIPTION # ",+^PSRX(APSQLAST(APSQLAST,U,2),0)," HAS BEEN FILLED FOR IT" S APSQDIR=2
 I APSQLAST>0,'$P(APSQLAST(APSQLAST),U,2) W !,"NON FORMULARY REQUEST ON FILE FOR THIS PATIENT AND DRUG DATED "_$$FMTE^XLFDT(9999999-APSQLAST) S APSQDIR=3
 D DIR
 ;W !,"GOT HERE"
NF(DRUG,PATIENT) ;CHECKS FOR NON FORMULARY REQUESTS FOR THIS PATIENT AND DRUG
 K APSQDT
 I '$D(^PSNF("M",DRUG,PATIENT)) S APSQLAST=0,APSQLAST(APSQLAST)="NONE" Q
 S APSQDAT="" F  S APSQDAT=$O(^PSNF("M",DRUG,PATIENT,APSQDAT)) Q:APSQDAT=""  D  ;
 .S APSQIEN=^PSNF("M",DRUG,PATIENT,APSQDAT)
 .S APSQRX=$P(^PSNF(APSQIEN,0),U,13)
 .S APSQDT(9999999-APSQDAT)=APSQIEN_U_APSQRX ;GOT THE IEN AND IF RX FILLED FOR THIS NON FORMULARY REQUEST  
 S APSQLAST=$O(APSQDT(""))
 S APSQLAST(APSQLAST)=APSQDT(APSQLAST)
 K APSQDAT,APSQDT
 Q
 ;
DIR ;ASK QUESTION
 Q:APSQDIR=3
 S DIR(0)="S^1:ADD A NON-FORMULARY REQUEST ON THE FLY;2:DELETE THE DRUG;3:NOTHING"
 S DIR("A")="WHAT DO YOU WANT TO DO?"
 S DIR("B")=3
 D ^DIR
 I $D(DIRUT)!($D(DUOUT))!($D(DTOUT)) S Y=3
 K DIR,DIRUT,DUOUT,DTOUT
 Q
 ;         
XREF(EN,SETKILL) ;CROSS REFERENCE ROUTINE
 Q:'$G(EN)  Q:'$G(SETKILL)  ;SOMETHING WRONG
 S OUTDIEN=$O(^PSDRUG("B","OUTSIDE DRUG",""))
 ;Q:OUTDIEN=""  ;NO OUTSIDE DRUG!!!
 I 'OUTDIEN S LOCAL("DIMSG")="NO DRUG ENTRY 'OUTSIDE DRUG'-ENTER ONE!!" D MSG^DIALOG("WM","","","","LOCAL") S DIK="^APSQNF(" D ^DIK K DIK Q
 I SETKILL="ADD" D ADD
 I SETKILL="KILL" D KILL
 Q
ADD ;ADD A XREF
 ;DRUG FIELD
 I EN=.01 I $P(^PSNF(DA,0),U,10),$P(^(0),U,12) D
 .I X'=OUTDIEN S ^PSNF("M",X,$P(^(0),U,10),$P(^(0),U,12))=DA Q
 .I $P(^PSNF(DA,0),U,2) S ^PSNF("M",X,$P(^(0),U,2),$P(^(0),U,12))=DA
 Q
 ;FREE TEXT FIELD
 I EN=1
KILL ;KILL A XREF
 I EN=.01 I $P(^PSNF(DA,0),U,10),$P(^(0),U,12) D
 .I X'=OUTDIEN K ^PSNF("M",X,$P(^(0),U,10),$P(^(0),U,12)) Q
 .I $P(^PSNF(DA,0),U,2) K ^PSNF("M",X,$P(^(0),U,2),$P(^(0),U,12))
 Q