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

APSQCK1.m

Go to the documentation of this file.
APSQCK1 ;IHS/ASDS/ENM/POC - CONT OF APSQCK NON FORMULARY CALL  [ 06/07/2001  10:56 AM ]
 ;;6.0;IHS PHARMACY MODIFICATIONS;**3**;FEB 20, 2001
 ;PROGRAM FOR ALL CALLS TO NON FORMULARY REQUEST [ 01/22/01  10:42 PM ]
 ;CONTINUATION FROM APSQCK
 ;CALLS FROM PSORXDL PSON52 PSORN52 ROUTINES
 ;A XREF LOOKUP TO KEEP PROVIDER FROM GIVING SAME DRUG TO SAME PERSON ON SAME DAY OR HAVE A RECORD OPEN FOR PATIENT AND A SAME DRUG
 ;D EN^XBVK("APSQC")
 Q
CK ;EP
 K APSQ("PAT"),APSQ("DRUG"),APSQ("DT")
 S JOB=$J
 ;M APSQC=^TMP("DDS",JOB,+DDS,"F"_DDSFILE,"11,") ;)_")") ;,"11,"_")"))
 M APSQC=^TMP("DDS",JOB,+DDS,"F"_DDSFILE,DDSDA) ;)_")") ;,"11,"_")"))
 ;W ABC
 S APSQ("PAT")=$G(APSQC(2,"D"))
 Q:APSQ("PAT")']""
 ;S APSQ("DRUG")=$G(APSQC(3,"D"))
 S APSQ("DRUG")=$G(DDSY)
 Q:APSQ("DRUG")']""
 S APSQ("DT")=$G(APSQC(1,"D"))
 Q:APSQ("DT")']""
 I $D(^APSQNF("M",APSQ("PAT"),APSQ("DRUG"),APSQ("DT"))) S DDSERROR=1 D 
 .S MSG("DIHELP",1)="THIS PATIENT ALREADY HAS A NON FORMULARY REQUEST FOR THIS DRUG TODAY" D MSG^DIALOG("WH","",60,"","MSG")
 .Q
 I $D(DDSERROR) D EN^XBVK("APSQ") Q
 ;
 ;CANT HAVE ANY RECORD FOR THIS PATIENT AND THIS DRUG "OPEN"
 S APSQ("QUIT")=0
 S APSQ("DT")=0 F  S APSQ("DT")=$O(^APSQNF("M",APSQ("PAT"),APSQ("DRUG"),APSQ("DT"))) Q:(APSQ("DT")="")!APSQ("QUIT")  S APSQ("RECIEN")=^(APSQ("DT")) D
 .Q:APSQ("RECIEN")=""
 .S APSQ("CLOSED")=$P($G(^APSQNF(APSQ("RECIEN")),1),U,8)
 .Q:APSQ("CLOSED")]""  ;RECORD CLOSED
 .S DDSERROR=1,APSQ("QUIT")=1
 .Q
 D EN^XBVK("APSQ")
 Q
LOOK ;EP LOOK UP AN ENTRY AND DO SOMETHING
 ;S LOOK TO PRINT TO PRINT OR XMB TO SEND MESSAGE
 W !,"YOU MAY LOOK UP ENTRIES BY CONTROL #, PATIENT, DRUG, OR DATE"
 K DIC
 S DIC="^APSQNF(",DIC(0)="AEMO"
 S DIC("A")="WHAT NON FORMULARY REQUEST DO YOU WANT TO SELECT? "
 D ^DIC
 ;S DUZ=DUZSAVE K DUZSAVE
 ;G:Y<1 EXIT
 ;I (Y<1)!($D(DTOUT))!($D(DUOUT)) G EXIT
 I (Y<1)!($D(DTOUT))!($D(DUOUT))!(+Y=0) G EXIT ;IHS/OKCAO/POC 3/12/2001
 E  S DA=+Y D WRITE,@LOOK
 G EXIT
 Q
 ;
 ;BELOW CAN SEND A MESSAGE TO WHOEVER FOR THE NON FORMULARY REQUEST
WRITE ;
 K ^UTILITY("DIQ1",$J)
 S DR=".01:999",DIQ(0)="E"
 D EN^XBNEW("EN^DIQ1","DIC;DR;DA;DIQ*") ;HAVE WE SOME CONFLICT HERE 1/21/2001
 ;D EN^DIQ1 ;TO GET WRITTEN TO ^UTILITY("DIQ1",$J,ETC
 M DD=^UTILITY("DIQ1",$J)
 S FILE=$O(DD(""))
 S DA=$O(DD(FILE,""))
 S FIELD=0 F I=1:1 S FIELD=$O(DD(FILE,DA,FIELD)) Q:FIELD=""  D
 .S NAME=$P(@("^DD("_FILE_","_FIELD_",0)"),"^",1)
 .I $D(DD(FILE,DA,FIELD,"E")) S NAME=NAME_":"_DD(FILE,DA,FIELD,"E")
 .S ARRAY(FIELD)=NAME
 .S ARRAY(FIELD-.00001)=""
 .S LAST=0,J=FIELD F J=J+.00001:.00001 S LAST=$O(DD(FILE,DA,FIELD,LAST)) Q:LAST'=+LAST  D
 ..S ARRAY(J)=DD(FILE,DA,FIELD,LAST)
 Q
XMB ;SEND TO WHO EVER
 S XMTEXT="ARRAY(" ;THE ABOVE JUST MADE ABOVE BY WRITE
 S XMSUB="NON FORMULARY REQUEST FROM "_$P(^DIC(4,DUZ(2),0),U,1)
 S XMDUZ=$S($D(DUZSAVE):DUZSAVE,1:DUZ)
 D ^XMD
 Q
EXIT ;CLEAN UP TIME
 I $D(DUZSAVE) S DUZ=DUZSAVE K DUZSAVE
 K EXIT
 K OUT,DISP
 K DDSPARM,DDSFILE,DR,DA,DDSSAVE,DDSCHANG
 K ADD,CNT,PERSON,NUM,MORE,SCR,SEQ,IEN,I,FROM,GET,DEL,HIT
 ;K ADD,CNT,PERSON,NUM,MORE,SCR,SEQ,IEN,I,GET,DEL,HIT
 K XMB,XMDUZ
 Q
VAL1 ;EP CALLED FROM SCREENMAN UPON VALIDATING THE FORM APSQ NF PHARMACIST
 ;I MIGHT NOT USE THIS
 S CHECK=$$GET^DDSVALF(8,2,1,"I") ;CHECK IF RPH WANTS TO SAVE FORM
 I CHECK D
 .S HELP(1)="SAVE AND EXIT THE FORM IF YOU WANT TO SAVE YOUR DATA"
 .D HLP^DDSUTL(.HELP)
 .K DDSERROR
 .;S DDSBR="COM"
 .Q
 I 'CHECK D
 .S HELP(1)="*************"
 .S HELP(2)="IF YOU WANT TO SAVE THE FORM"
 .S HELP(3)="CHANGE THE SAVE THE FORM FIELD TO 'YES'"
 .D HLP^DDSUTL(.HELP)
 .K HELP
 .S DDSBR="8"
 .S DDSERROR=1
 .Q
 K CHECK,HELP
 Q
VAL2 ;EP COME HERE FROM SCREENMAN TO SEE IF WANT TO DELETE FORM
 S KILL=$$GET^DDSVALF(20,1,1,"I")
 I KILL S DIK="^APSQNF(" D ^DIK
 ;K KILL,DIK,DA
 K DIK,DA
 Q
VAL3 ;EP COME HERE FROM SCREENMAN TO SEE IF WANT TO DELETE RPH COMMENTS
 S KILL=$$GET^DDSVALF(8,3,1,"I")
 I KILL D  ;
 .S DIE="^APSQNF(",DR="6///@;10///@;11///@;12///@;13///@;14///@;70///@" D ^DIE
 .K DIE,DA
 .Q
 K KILL
 Q
VAL33 ;EP VALIDATION OF SCREENMAN APSQ NF PHARMACIST ...
 S KILL=$$GET^DDSVALF(8,3,1,"I")
 I KILL D  ;
 .S HELP(1)="IF YOU WANT TO SAVE THE PHARMACIST INFORMATION"
 .S HELP(2)="CHANGE 'DELETE THE PHARMACY INFO AND YOUR SIGNATURE' TO 'NO'"
 .S HELP(3)="IF YOU WANT TO DELETE THE PHARMACIST INFO-EXIT THE FORM W/O SAVING"
 .D HLP^DDSUTL(.HELP)
 .K HELP
 .S DDSBR="8"
 .S DDSERROR=1
 .Q
 K KILL
 Q
VAL4 ;EP COME HERE FROM SCREENMAN TO SEE IF WANT TO DELETE RPH COMMENTS
 S KILL=$$GET^DDSVALF(7,2,1,"I")
 I KILL D 
 .S DIE="^APSQNF(",DR="7///@;7.5///@;80///@" D ^DIE
 .K DIE,DA
 .Q
 K KILL
 Q
VAL44 ;EP VALIDATION OF SCREENMAN APSQ NF PHARMACIST ...
 S KILL=$$GET^DDSVALF(7,2,1,"I")
 I KILL D
 .S HELP(1)="IF YOU WANT TO SAVE THE P/T INFORMATION"
 .S HELP(2)="CHANGE 'DELETE THE P/T INFO AND YOUR SIGNATURE' TO 'NO'"
 .S HELP(3)="IF YOU WANT TO DELETE THE P/T INFO-EXIT THE FORM W/O SAVING"
 .D HLP^DDSUTL(.HELP)
 .K HELP
 .S DDSBR="7"
 .S DDSERROR=1
 .Q
 K KILL
 Q
BULL(GOTIT,BULLETIN,XMY) ;SEND A BULLETIN GOTIT IS THE IEN OF APSQNF( AND BULLETIN IS NAME OF BULLETIN
 ;GOTIT IS THE IEN OF NONFORMULARY REQUEST
 ;BULLETIN  IS NAME OF BULLETIN TO USE
 ;WHO IS ADDITIONAL PERSON TO SEND BULLETIN TO
 W !!,"BULLETIN BEING SENT",!!
 ;S GOTIT="SOMETHING"
 S GOTIT="`"_GOTIT ;WANT IEN I THINK
 D FIND^DIC(9009035.1,,".01;2;3;4;4.1;5;5.1;6;6.1;7;7.1;7.5",,GOTIT,,,,,"GET","OUCH")
 M XMB=GET("DILIST","ID",1) ;MAKE IT EASIER TO WORK WITH
 D BULL2
 D BULL1
 Q
BULL1 S XMDUZ=.5
 S XMB=BULLETIN
 D ^XMB
 K XMY
 Q
 ;
BULL2 ;ADD ANY EXTRA PEOPLE TO BULLETIN
 W !,"ADDITIONAL ENTRIES MAY BE ADDED TO THE BULLETIN"
 W !,"REMEMBER ENTRIES HAVE BEEN ADDED FOR YOURSELF AND THE BULLETIN MAILGROUPS"
DIC S DIC(0)="AEMQ"
 S DIC="^VA(200,"
 S DIC("S")="I ($P(^(0),U,3)'="""")&($S($P(^(0),U,11)]"""":$P(^(0),U,11),1:9999999)>DT)"
 S DIC("A")="ADDITIONAL 'LOCAL USER' TO THE BULLETIN //"
 D ^DIC
 I Y>0 S XMY(+Y)="" G DIC
 K DIC
 Q
 S XMZ=$$FIND1^DIC(3.6,"","MX",BULLETIN)
 S XMDUZ=.5
 S XMDUN=""
 D DEST^XMA21
 ;GETS XMY ARRAY
 ;W !,"SOME STUFF HERE"
 Q
PASS(PROV) ;EP CHECK IF THIS IS A VALID NEW PERSON TO LOOK AT THIS ENTRY
 Q:'$G(PROV) 1
 ;PROV WOULD BE THE REQUESTING PROVIDER.  WOULD TAKE THIS PROV
 ;AND LOOK IN A NEW FILE WITH WHO CAN SIGN OFF AT VARIOUS STAGES
 ;CHECK WHO CAN SIGN OFF AGAINST DUZ
 ;AND RETURN THE QUIT VALUE AS 1 OR 0
 Q 1
 ;
PRINT ;PRINT OR BROWSE A NON FORMULARY REQUEST
 K DIR
 S DIR(0)="SO^P:PRINT NON FORMULARY REQUEST;B:BROWSE NON FORMULARY REQUST"
 S DIR("A")="DO YOU WANT TO "
 S DIR("B")="PRINT"
 W !
 D ^DIR
 K DIR
 Q:($D(DTOUT))!($D(DUOUT))!($D(DIRUT))!($D(DIROUT))  ;CHECK THIS ***
 I $E($G(X))="P" D PRT Q
 I $E($G(X))="B" D BROWSE Q
 Q
BROWSE ; BROWSE IT
 ;NEED ENTRY XB... IN LIST TEMPLATE FILE
 S TOP="NON FORMULARY REQUEST FOR "_$P(^DPT($P(^APSQNF(DA,0),U,3),0),U)
 ;D VIEWR^XBLM("EN^DIQ","NON FORMULARY REQUEST FOR "_TOP)
 D VIEWR^XBLM("PRT1^APSQCK","NON FORMULARY REQUEST FOR "_TOP)
 Q
 ;
PRT ;PRINT IT
 S %ZIS="QM" D ^%ZIS G EXIT:POP
 I $D(IO("Q")) D  D ^%ZTLOAD D HOME^%ZIS K IO("Q") Q
 .S ZTRTN="PRT1^APSQCK",ZTDESC="PRINT OF ONE NON FORMULARY REQUEST"
PRT1 ;EP
 S (END,NUMPT,PAGE)=0
 U IO
 D @("HDR"_(2-($E(IOST,1,2)="C-")))
 S ARRAY=0 F  S ARRAY=$O(ARRAY(ARRAY)) Q:ARRAY=""!END  D
 .W !,ARRAY(ARRAY)
 .I ($Y+5)>IOSL D HDR
 .Q
 D ^%ZISC Q
HDR I $E(IOST,1,2)="C-" W !,"PRESS RETURN TO CONTINUE OR '^' TO EXIT " R X:DTIME S END='$T!(X="^") Q:END  ;
HDR1 W @IOF
HDR2 S TOP="NON FORMULARY REQUEST FOR "_$P(^DPT($P(^APSQNF(DA,0),U,3),0),U)
 S LENG=$L(TOP)
 S PAGE=PAGE+1 W ?(IOM-LENG/2),TOP,?(IOM-12),"PAGE:  ",$J(PAGE,3)
 Q
 ;
RX ;EP COMES FROM PSODRG TO CHECK IF NON FORMULARY REQUEST FOR NF DRUG
 ;PSODFN IS PATIENT,PSODRUG("IEN") IS DRUG 
 ;ROUTINES PSODRG PSORXI MODIFIED 
 W !,"CHECKING NON FORMULARY INFORMATION...",!
 Q:('$D(PSODRUG("IEN"))!('$D(PSODFN)))  ;I HAVEN'T A CLUE
 Q:'$P(^PSDRUG(PSODRUG("IEN"),0),U,9)  ;NOT A NF DRUG
 S NFRXDRUG=PSODRUG("IEN")_";PSDRUG(" ;REMEMBER THIS FIELD IS VARIABLE
 S NFRXPT=PSODFN
 S NFRXDATE=$O(^APSQNF("M",NFRXPT,NFRXDRUG,""),-1)
 I 'NFRXDATE W !,"NO NON FORMULARY REQUESTS EXISTS FOR THIS DRUG" G NFRXEND
 S NFRXIEN=^APSQNF("M",NFRXPT,NFRXDRUG,NFRXDATE)
 G:'NFRXIEN NFRXEND W !,"NON FORMULARY REQUEST "_$P(^APSQNF(NFRXIEN,0),U)_" EXISTS"
 S NFRXSEC=$G(^APSQNF(NFRXIEN,1)) ;SECOND NODE
 S NFRXREF=$P(NFRXSEC,U,15),NFRXAPP=$P(NFRXSEC,U,8)
 I NFRXREF W !,"RX# "_+$G(^PSRX(NFRXREF,0))_" HAS BEEN FILLED PREVIOUSLY USING THIS NON FORMULARY REQUEST"
 W !,"THIS NON FORMULARY REQUEST STATUS IS "_$S(NFRXAPP=1:"APPROVED",NFRXAPP=0:"NOT APPROVED",1:"NOT ACTED UPON YET")
NFRXEND ;FINISH
 W !
 D ASK
 ;S:('NFRXREF)&(NFRXAPP) NFRXAOK=1
 D EN^XBVK("NFRX")
 Q
ASK ;ASK WHAT IS TO BE DONE
 ;LETS DO REVERSE VIDEO
 S X="IORVON;IORVOFF" D ENDR^%ZISS
 ;FIRST WRITE MESSAGES
 S I="" F  S I=$O(AZO(I)) Q:I=""  W:I="MESS" IORVON W !,*7,AZO(I) W:I="MESS" IORVOFF
 ;S DIR("A")="WHAT IS YOUR POISON?  "
 S DIR("A")="WHAT IS YOUR CHOICE?  "
 S DIR("A",1)="1  DO YOU WANT TO DELETE THIS DRUG?"
 S DIR("A",2)="2  DO AN INTERVENTION?"
 S DIR("A",3)="3  DO BOTH 1 AND 2?"
 S DIR("A",4)="4  JUST CONTINUE?"
 S DIR("B")=1
 S DIR(0)="N^1:4:0"
 D ^DIR
 ;IF (Y="")!(Y["^") S Y=1
 IF $D(DIRUT)!($D(DIROUT)) S Y=1
 K DIR,DTOUT,DIRUT,DUOUT,DIROUT
 D @Y
 QUIT
 ;
1 ;DELETE THE DRUG
 S PSORX("DFLG")=1,DGI=""
 QUIT
2 ;DO AN INTERVENTION
 S PSORX("INTERVENE")=4,DGI=""
 ;PSORXI WAS MODIFIED
 ;LOOK AT THIS 4/13/98 IHS/OKCAO/POC
 QUIT
3 ;DO BOTH 1 AND 2
 D 2,1
 QUIT
4 ;DO NOTHING
 QUIT
RXSET ;EP SET THE REFERENCE RX FIELD
 ;CALLED FROM PSON52 AND PSOR52
 ;WITH NFRXIEN DEFINED AS PSRX IEN
 ;QUIT
 D RXSET1,STOP
 Q
RXSET1 S NFRXDRUG=$P(^PSRX(NFRXIEN,0),U,6) ;DRUG IEN
 Q:'$P(^PSDRUG(NFRXDRUG,0),U,9)  ;NOT NON FORMULARY
 S NFRXDRUG=NFRXDRUG_";PSDRUG(" ;REMEMBER THIS FIELD IS VARIABLE
 S NFRXPT=PSODFN
 S NFRXDATE=$O(^APSQNF("M",NFRXPT,NFRXDRUG,""),-1) I NFRXDATE S NFRXNON=^(NFRXDATE)
 Q:'NFRXDATE  ;NO NON FORMULARY REQUEST
 Q:'NFRXNON  ;I HAVEN'T A CLUE
 I '$P($G(^APSQNF(NFRXNON,1)),U,15) S DIE="^APSQNF(",DA=NFRXNON,DR="14///"_"`"_NFRXIEN D ^DIE K DIE ;ONLY SET IF FIELD NOT NULL
 Q
RXSETK ;EP KILL PRESCRIPTION REFERENCE IF RX DELETED
 ;VARIABLE NFRXIEN PASSED FROM DA IN PSORXDL
 ;S KILL=$O(^APSQNF(XREF,NFRXIEN,""))
 S KILL=$O(^APSQNF("RX",NFRXIEN,""))
 I KILL S DIE="^APSQNF(",DA=KILL,DR="14///@" D ^DIE K DIE
 D STOP
 Q
STOP D EN^XBVK("NFRX")
 Q