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

PSJCROC.m

Go to the documentation of this file.
PSJCROC ;HP/MJE - CLINICAL REMINDER ORDER CHECKS FOR IP OC ;09/22/11 5:00pm
 ;;5.0;INPATIENT MEDICATIONS;**281,349**;16 DEC 97;Build 4
 ;
 ;Reference to ORDERCHK^PXRMORCH supported by DBIA 5531
 ;Reference to SIG^XUSESIG supported by DBIA 10050
 ;Reference to ^ORD(101.43 supported by DBIA 5430
 ;
CK(CDRG1) ;CHECK FOR CROCS AGAINST PROSPECTIVE DRUG
 N PSJFIRST
 S $P(CROCLN,"=",75)="=",$P(CROCLN2,"-",75)="-"
 W "Now processing Clinical Reminder Order Checks. Please wait ..."
 D ORDERCHK^PXRMORCH(DFN,-1,0,CDRG1,0)
 ;H:'$D(^TMP($J,CDRG1)) 2
 S (CROCSTA,CROCDNM,CROCNUM,CROCSTR,CROCHFLG)="" N DIRUT
 I $D(^TMP($J,CDRG1)) D
 .S CROCHFLG=2,CROCNR=0 ;W CROCLN
 .F  S CROCSTA=$O(^TMP($J,CDRG1,CROCSTA)) Q:CROCSTA=""!$G(PSGORQF)  D
 ..I CROCSTA=1 S CROCHFLG=1
 ..F  S CROCDNM=$O(^TMP($J,CDRG1,CROCSTA,CROCDNM)) Q:CROCDNM=""!$G(PSGORQF)  D
 ...S CROCSTA2=$S(CROCSTA=1:"HIGH",CROCSTA=2:"MEDIUM",CROCSTA=3:"LOW",1:"UNKNOWN")
 ...I '$G(PSJFIRST) W !!,CROCLN S PSJFIRST=1
 ...W !,"*** Clinical Reminder Order Check | Severity: "_CROCSTA2_" ***",!
 ...W !,CROCDNM,!
 ...F  S CROCNUM=$O(^TMP($J,CDRG1,CROCSTA,CROCDNM,CROCNUM)) Q:CROCNUM=""!$G(PSGORQF)  D
 ....I ($Y+5)>IOSL,$E(IOST)="C" D
 .....W ! K DIR S DIR(0)="E",DIR("A")="Press Return to Continue..." D ^DIR K DIR W @IOF
 ....;RTC 182375
 ....;W !,^TMP($J,CDRG1,CROCSTA,CROCDNM,CROCNUM) S PSJCROCF=1
 ....D LONGTEXT($G(^TMP($J,CDRG1,CROCSTA,CROCDNM,CROCNUM)),79)
 ....S PSJCROCF=1
 ...W !!,CROCLN2 I ($Y+5)>IOSL,$E(IOST)="C" W ! K DIR S DIR(0)="E",DIR("A")="Press Return to Continue..." D ^DIR K DIR W @IOF
 K ^TMP($J,CDRG1)
 I $G(PSJDGCK) K CROCSTA,CROCDNM,CROCNUM,CROCSTR,CROCHFLG,CROCLN,CROCLN2,CDRG1 Q
 I CROCHFLG=1 S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Continue? ",DIR("B")="Y" D ^DIR K DIR
 I CROCHFLG=1,Y["^"!(Y=0)!($D(DIRUT)) S (PSGORQF)=1 Q
 I CROCHFLG=1 D SIG^XUSESIG I X1="" W !!,"Signature Code not valid" S (PSGORQF)=1 H 2 Q
 I CROCHFLG=1 I X1'="" D EN3^PSJRXI("CLINICAL REMINDER",CDRG1)
 I CROCHFLG>1 W ! S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="N" D ^DIR K DIR
 I CROCHFLG>1,Y=1 D EN3^PSJRXI("CLINICAL REMINDER",CDRG1)
 K CROCSTA,CROCDNM,CROCNUM,CROCSTR,CROCHFLG,CROCLN,CROCLN2,CDRG1,Y
 Q
 ;
CKIVI ;Log IV interventions
 N DIRUT
 I $G(PSJDGCK) K CROCSTA,CROCDNM,CROCNUM,CROCSTR,CROCHFLG,CROCLN,CROCLN2,CDRG1 Q
 I CROCHFLG=1 D
 .S CROCIXN1="" F  S CROCIXN1=$O(^TMP($J,"CROCDRG",1,CROCIXN1)) Q:CROCIXN1=""!($G(PSGORQF)=1)  D
 ..F CROCIXN2=0:0 S CROCIXN2=$O(^TMP($J,"CROCDRG",1,CROCIXN1,CROCIXN2)) Q:'CROCIXN2!($G(PSGORQF)=1)  D
 ...W ! S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Continue with "_^TMP($J,"CROCDRG",1,CROCIXN1,CROCIXN2)_"? ",DIR("B")="Y" D ^DIR K DIR
 ...I Y["^"!(Y=0)!($D(DIRUT)) S PSGORQF=1 Q
 ...D SIG^XUSESIG I X1="" W !!,"Signature Code not valid" S PSGORQF=1 H 2 Q
 ...I X1'="" D EN3^PSJRXI("CLINICAL REMINDER",+PSPDRG(1))  ;*349
 I CROCHFLG=2!($D(^TMP($J,"CROCDRG",2)))!($D(^TMP($J,"CROCDRG",3))) D
 .I $G(PSGORQF)=1 Q
 .F CROCIXN1=1:0 S CROCIXN1=$O(^TMP($J,"CROCDRG",CROCIXN1)) Q:'CROCIXN1  D
 ..S CROCIXN2="" F  S CROCIXN2=$O(^TMP($J,"CROCDRG",CROCIXN1,CROCIXN2)) Q:CROCIXN2=""  D
 ...I CROCIXN1=2,$D(^TMP($J,"CROCDRG",1,CROCIXN2)) Q
 ...I CROCIXN1=3,$D(^TMP($J,"CROCDRG",2,CROCIXN2))!($D(^TMP($J,"CROCDRG",1,CROCIXN2))) Q
 ...F CROCIXN3=0:0 S CROCIXN3=$O(^TMP($J,"CROCDRG",CROCIXN1,CROCIXN2,CROCIXN3)) Q:'CROCIXN3  D
 ....S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene with "_^TMP($J,"CROCDRG",CROCIXN1,CROCIXN2,CROCIXN3)_"? ",DIR("B")="N" D ^DIR K DIR
 ....I Y=1 D EN3^PSJRXI("CLINICAL REMINDER",+PSPDRG(1)) ;*349
 K CROCSTA,CROCDNM,CROCNUM,CROCSTR,CROCHFLG,CROCLN,CROCLN2,CDRG1,CROCIXN1,CROCIXN2,CROCIXN3,Y,^TMP($J,"CROCDRG")
 Q
 ; 
CKIV(CDRG2,IVFLG) ;CHECK FOR CROCS AGAINST PROSPECTIVE IV ORDER
 S (CROCSTA2,CROCDNM2,CROCNUM2)="" S CROCCTR=1 N PHROI
 I IVFLG="A" S PHROI=$$GET1^DIQ(52.6,CDRG2,15,"I")
 I IVFLG="S" S PHROI=$$GET1^DIQ(52.7,CDRG2,9,"I")
 S ODRI=$O(^ORD(101.43,"ID",PHROI_";99PSP",0))
 D ORDERCHK^PXRMORCH(DFN,ODRI,0,-1,0)
 I $D(^TMP($J,$G(ODRI))) D
 .S CROCNR=0
 .F  S CROCSTA2=$O(^TMP($J,ODRI,CROCSTA2)) Q:CROCSTA2=""  D
 ..I IVFLG="A" S ^TMP($J,"CROCDRG",CROCSTA2,$P(TMPDRG1("AD",CRIV),"^",2)_" "_$P(TMPDRG1("AD",CRIV),"^",3),CRIV)=$P(TMPDRG1("AD",CRIV),"^",2)_" "_$P(TMPDRG1("AD",CRIV),"^",3)
 ..I IVFLG="S" S ^TMP($J,"CROCDRG",CROCSTA2,$P(TMPDRG1("SOL",CRIV),"^",2)_" "_$P(TMPDRG1("SOL",CRIV),"^",3),CRIV)=$P(TMPDRG1("SOL",CRIV),"^",2)_" "_$P(TMPDRG1("SOL",CRIV),"^",3)
 ..S CROCCTR=CROCCTR+1
 ..F  S CROCDNM2=$O(^TMP($J,ODRI,CROCSTA2,CROCDNM2)) Q:CROCDNM2=""  D
 ...F  S CROCNUM2=$O(^TMP($J,ODRI,CROCSTA2,CROCDNM2,CROCNUM2)) Q:CROCNUM2=""  D
 ....S ^TMP($J,"CROCIV",CROCSTA2,CROCDNM2,CROCNUM2)=^TMP($J,ODRI,CROCSTA2,CROCDNM2,CROCNUM2)
 K ^TMP($J,$G(ODRI)),CROCCTR,CROCSTA2,CROCDNM2,CROCNUM2,CROCSTR2,CROCHFLG2,ODRI,IVFLG,CDRG2
 Q
 ;
CKIVD ;DISPLAY IV CROCS
 S (CROCSTA,CROCDNM,CROCNUM,CROCSTR,CROCHFLG)="" S CROCNMF=0
 N PSJFIRST
 I $D(^TMP($J,"CROCIV")) D
 .S CROCHFLG=2 ;W !!,CROCLN
 .F  S CROCSTA=$O(^TMP($J,"CROCIV",CROCSTA)) Q:CROCSTA=""!$G(PSGORQF)  D
 ..I CROCSTA=1 S CROCHFLG=1
 ..F  S CROCDNM=$O(^TMP($J,"CROCIV",CROCSTA,CROCDNM)) Q:CROCDNM=""!$G(PSGORQF)  D
 ...S CROCSTA2=$S(CROCSTA=1:"HIGH",CROCSTA=2:"MEDIUM",CROCSTA=3:"LOW",1:"UNKNOWN")
 ...I '$G(PSJFIRST) W !!,CROCLN S PSJFIRST=1
 ...W !,"*** Clinical Reminder Order Check | Severity: "_CROCSTA2_" ***",!
 ...W !,CROCDNM,! S:'CROCNMF CDRG1=CROCDNM S CROCNMF=1
 ...F  S CROCNUM=$O(^TMP($J,"CROCIV",CROCSTA,CROCDNM,CROCNUM)) Q:CROCNUM=""!$G(PSGORQF)  D
 ....I ($Y+5)>IOSL,$E(IOST)="C" D
 .....W ! K DIR S DIR(0)="E",DIR("A")="Press Return to Continue..." D ^DIR K DIR W @IOF
 ....;RTC 182375
 ....;W !,^TMP($J,"CROCIV",CROCSTA,CROCDNM,CROCNUM) S PSJCROCF=1
 ....D LONGTEXT($G(^TMP($J,"CROCIV",CROCSTA,CROCDNM,CROCNUM)),79)
 ....S PSJCROCF=1
 ...W !!,CROCLN2 I ($Y+5)>IOSL,$E(IOST)="C" W ! K DIR S DIR(0)="E",DIR("A")="Press Return to Continue..." D ^DIR K DIR W @IOF
 K ^TMP($J,"CROCIV"),CROCNMF G CKIVI
 Q
 ;
LONGTEXT(PSJTXT,PSJLEN) ;
 ; The ^DIWP can only handle up to 999 characters. This call is used for long text. 
 I $G(PSJTXT)="" Q
 I '+$G(PSJLEN) S PSJLEN=79
 NEW PSJCNT,PSJLINE,PSJOUT,PSJSTR,PSJSTRB,PSJSTRE,PSJSTRL,PSJX
 S PSJSTR="",PSJLINE=0,(PSJSTRL,PSJCNT,PSJSTRB,PSJSTRE)=1
 ;
 ; If string has no blank space.
 I $L(PSJTXT," ")=1,$L(PSJTXT)>PSJLEN D  D DSPLTXT(.PSJOUT) Q
 . S PSJLINE=$L(PSJTXT)\PSJLEN+$S($L(PSJTXT)#PSJLEN:1,1:0)
 . F PSJX=1:1:PSJLINE-1 D
 .. S PSJSTR="",PSJSTRE=PSJLEN*PSJX+1
 .. S PSJSTR=$E(PSJTXT,PSJSTRB,PSJSTRE),PSJOUT(PSJCNT)=PSJSTR,PSJCNT=PSJCNT+1,PSJSTRB=PSJSTRE+1
 . I PSJSTRB,PSJSTRE S PSJOUT(PSJCNT+1)=$E(PSJTXT,PSJSTRB,$L(PSJTXT))
 ;
 ; This is for text contains at least a space
 F PSJX=1:1:$L(PSJTXT," ") D
 . I ($L(PSJSTR)+$L($P(PSJTXT," ",PSJX)))>PSJLEN S PSJSTR="",PSJCNT=PSJCNT+1
 . S PSJSTR=PSJSTR_$P(PSJTXT," ",PSJX)_" "
 . S PSJOUT(PSJCNT)=PSJSTR
 D DSPLTXT(.PSJOUT)
 Q
DSPLTXT(PSJOUT) ;
 Q:'$D(PSJOUT)
 NEW PSJX
 F PSJX=0:0 S PSJX=$O(PSJOUT(PSJX)) Q:'PSJX  D
 . I ($Y+6)>IOSL D PAUSE^PSJLMUT1 W @IOF
 . W !,$G(PSJOUT(PSJX))
 Q