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

PSOERXD1.m

Go to the documentation of this file.
PSOERXD1 ;ALB/BWF - eRx Drug display/actions ; 8/3/2016 5:14pm
 ;;7.0;OUTPATIENT PHARMACY;**467,520,551,582,581,635,617,651,689,700,746**;DEC 1997;Build 106
 ;
EN ; -- main entry point for PSO ERX HOLDING QUEUE
 D EN^VALM("PSO ERX DRUG VALIDATION")
 Q
 ;
LMHDR ; ListMan Header Code
 D SHOW^VALM,HDR^PSOERXD1
 S ORMXQ("??")="D HELP^VALM2,HDR^PSOERXD1"
 Q
 ;
HDR ; -- header code
 N AMATCH,VDRGIEN,VALUSER,VALDTTM,MATCH,HDR,EFFDATE
 S AMATCH=$$GET1^DIQ(52.49,PSOIEN,1.4,"I"),VDRGIEN=$$GET1^DIQ(52.49,PSOIEN,3.2,"I")
 S VALUSER=$$GET1^DIQ(52.49,PSOIEN,1.11,"E"),VALDTTM=$$GET1^DIQ(52.49,PSOIEN,1.12,"I")
 S VALMHDR(1)="eRx Reference #: "_IOINHI_$$GET1^DIQ(52.49,PSOIEN,.01,"E")_IOINORM
 D INSTR^VALM1("eRx Patient: "_IOINHI_$$GET1^DIQ(52.49,PSOIEN,.04,"E")_IOINORM,32,2)
 S VALMHDR(2)="Date Written   : "_IOINHI_$$FMTE^XLFDT($$GET1^DIQ(52.49,PSOIEN,5.9,"I"),"2Y")_IOINORM
 ; Have to use INSTR^VALM1 to reach the end of the line (due to Listman issues/bug with formatting)
 S EFFDATE="Effective Date: "_IOINHI_$$FMTE^XLFDT($$GET1^DIQ(52.49,PSOIEN,6.3,"I"),"2Y")_IOINORM
 D INSTR^VALM1(EFFDATE,29,3)
 S MATCH=$S(AMATCH=1:"AUTO-MATCHED",AMATCH=2:"AUTO-MATCHED/EDITED",VDRGIEN:"MANUALLY-MATCHED",1:"")
 I VALUSER'="",MATCH'="" S MATCH=MATCH_" | VALIDATED by "_$E(VALUSER,1,19)_" on "_$$FMTE^XLFDT(VALDTTM,"2Y")
 I MATCH="" S MATCH="NOT MATCHED"
 S $E(MATCH,81)="" D INSTR^VALM1("Status: "_IOINHI_MATCH_IOINORM,1,4)
 S HDR="",$E(HDR,17)="ERX MED",$E(HDR,40)="|",$E(HDR,56)="VISTA MED"
 S $E(HDR,81)="" D INSTR^VALM1(IORVON_IOUON_HDR_IORVOFF_IOINORM,1,5)
 Q
 ;
INIT ;
 N I,LINE,REVLN,HIGHLN,UNDERLN,HIGUNDLN,DIE,DA,DR,NMSPC
 S NMSPC="PSOERDR1" K ^TMP(NMSPC,$J)
 ; - Resetting list to NORMAL video attributes
 D RESET^PSOERUT0()
 S LINE=1
 ;
 ; Routing (Window/Mail)
 I $$GET1^DIQ(52.49,PSOIEN,20.4,"E")="" D
 . S DIE="^PS(52.49,",DA=PSOIEN,DR="20.4////M" D ^DIE K DIE
 ;
 ; Clinic
 I '$$GET1^DIQ(52.49,PSOIEN,20.6,"I"),$G(PSOCLNC) D
 . S DIE="^PS(52.49,",DA=PSOIEN,DR="20.6////"_PSOCLNC D ^DIE K DIE
 ;
 D ALLERGY^PSOERUT3("LM",NMSPC,PSOIEN,+$$GET1^DIQ(52.49,PSOIEN,.05,"I"))
 ;
 D SETDRUG^PSOERUT2("LM",NMSPC,PSOIEN,0)
 ;
 D SETDIAGS^PSOERUT3("LM",NMSPC,PSOIEN)
 ;
 S VALMCNT=LINE-1
 S EDTYP="D"
 ; - Saving NORMAL video attributes to be reset later
 I LINE>$G(LASTLINE) D
 . F I=($G(LASTLINE)+1):1:LINE D SAVE^VALM10(I)
 . S LASTLINE=LINE
 D VIDEO^PSOERUT0()
 ;
 Q
 ;
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ; -- exit code
 K @VALMAR,EDTYP
 Q
 ;
EXPND ; -- expand code
 Q
 ; ARY - array to store the output (pass by reference)
 ; TEXT - the text to convert into the array format
 ; DELIM - delimiter for text (default is space)
 ; MAXLEN - maximum length of each array items text, defaults to 80
TXT2ARY(ARY,TEXT,DELIM,MAXLEN) ;
 N WORD,I,LCNT,LINETXT,S
 S S=$S($D(DELIM):DELIM,1:" ")
 I '$G(MAXLEN) S MAXLEN=80
 S LCNT=1,LINETXT=""
 F I=1:1:$L(TEXT,S) D
 .S WORD=$P(TEXT,S,I)
 .;PSO*7*635 - Begin parsing modications
 .N TOTLEN,NUMLINES,STRT,ARYCNT,NLINE,J
 .S TOTLEN=$L(WORD)
 .I TOTLEN>MAXLEN D  Q
 ..; if there was data in linetxt, file it and update the counter before continuing
 ..I $L(LINETXT) S ARY(LCNT)=LINETXT,LCNT=LCNT+1,LINETXT=""
 ..S NUMLINES=TOTLEN/MAXLEN+1
 ..S (STRT,ARYCNT)=1
 ..; loop through the long line and break it into sub-sections based on the maxlen
 ..F J=1:1:+$G(NUMLINES) D
 ...S NLINE=$E(WORD,STRT,MAXLEN*ARYCNT) Q:NLINE=""
 ...S ARY(LCNT)=NLINE,STRT=MAXLEN*ARYCNT+1,ARYCNT=ARYCNT+1,LCNT=LCNT+1
 .I $L(LINETXT)+$L(S)+$L(WORD)>MAXLEN D  Q
 ..S ARY(LCNT)=LINETXT
 ..S LCNT=LCNT+1,LINETXT=WORD
 .I '$L(LINETXT) D  Q
 ..; if the current word plus the next word are greater than the maxlength, set the current word and quit.
 ..I $L(WORD)+$L($P(TEXT,S,I+1))>MAXLEN D  Q
 ...S ARY(LCNT)=WORD,LCNT=LCNT+1 Q
 ..S LINETXT=WORD Q
 .; PSO*7*635 - End modifications
 .S LINETXT=LINETXT_S_WORD
 ; if there is information left, set it into the array
 I $L(LINETXT) S ARY(LCNT)=$G(LINETXT)
 Q
DOSE ;displays dosing info for pending orders.  called from psoorfi1
 K II,UNITS S DS=1
 I '$O(^PS(52.49,PSOIEN,21,0)) S LINE=LINE+1,LINETXT="" D ADDITEM^PSOERX1A(.LINETXT," (2)          *Dosage:",,1,30) D SET^VALM10(LINE,LINETXT) S LINETXT="" G DOSEX
 F I=0:0 S I=$O(^PS(52.49,PSOIEN,21,I)) Q:'I  S DOSE=$G(^PS(52.49,PSOIEN,21,I,1)),DOSE1=$G(^(2)) D  D DOSE1
 .S II=$G(II)+1 K PSONEW("UNITS",II)
 .S PSONEW("DOSE",II)=$P(DOSE1,"^"),PSONEW("DOSE ORDERED",II)=$P(DOSE1,"^",2),PSONEW("UNITS",II)=$P(DOSE,"^",9),PSONEW("NOUN",II)=$P(DOSE,"^",5)
 .S:$P(DOSE,"^",9) UNITS=$P(^PS(50.607,$P(DOSE,"^",9),0),"^")
 .S PSONEW("VERB",II)=$P(DOSE,"^",10),PSONEW("ROUTE",II)=$P(DOSE,"^",8)
 .S ROUTE="" S:$P(DOSE,"^",8) ROUTE=$P(^PS(51.2,$P(DOSE,"^",8),0),"^")
 .S PSONEW("SCHEDULE",II)=$P(DOSE,"^"),PSONEW("DURATION",II)=$P(DOSE,"^",2)
 .S DOENT=$G(DOENT)+1 I $P(DOSE,"^",6)]"" S PSONEW("CONJUNCTION",II)=$S($P(DOSE,"^",6)="S":"T",$P(DOSE,"^",6)="X":"X",1:"A")
 .I 'PSONEW("DOSE ORDERED",II),$G(PSONEW("VERB",II))]"" D
 ..S LINETXT="" S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"               Verb: ",$G(PSONEW("VERB",II)),1,40)
 ..D SET^VALM10(LINE,LINETXT) S LINETXT=""
 .S:$G(DS) LINE=LINE+1 D:II=1 ADDITEM^PSOERX1A(.LINETXT," (2)","",1,5)
DOSEX S PSONEW("ENT")=+$G(II) K DOSE,DOSE1,II,I,UNITS,ROUTE,DG
 Q
DOSE1 ;
 I $G(DS)=1 D ADDITEM^PSOERX1A(.LINETXT,"        *Dosage:","",4,30) D FMD G DU
 S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"            *Dosage:","",1,30) D FMD
DU ;
 S PSODFN=$G(PATIEN)
 I 'PSONEW("DOSE ORDERED",I),$P($G(^PS(55,PSODFN,"LAN")),"^") D
 .S LINE=LINE+1,LINETXT="" D ADDITEM^PSOERX1A(.LINETXT,"  Oth. Lang. Dosage: ",$G(PSONEW("ODOSE",I)),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 I PSONEW("DOSE ORDERED",II),$G(PSONEW("VERB",II))]"" D
 .S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"               Verb: ",$G(PSONEW("VERB",II)),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 .S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"     Dispense Units: ",$S($E(PSONEW("DOSE ORDERED",II),1)=".":"0",1:"")_PSONEW("DOSE ORDERED",II),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 I PSONEW("NOUN",II)]"" D
 .S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"               Noun: ",PSONEW("NOUN",II),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 I $G(ROUTE)]"" D
 .S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"             *Route: ",$G(ROUTE),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"          *Schedule: ",PSONEW("SCHEDULE",II),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 I $G(PSONEW("DURATION",II))]"" D
 .S PSONEW("DURATION",II)=$S($E(PSONEW("DURATION",II),1)'?.N:$E(PSONEW("DURATION",II),2,99)_$E(PSONEW("DURATION",II),1),1:PSONEW("DURATION",II))
 .S TDUR=PSONEW("DURATION",II)_" ("_$S(PSONEW("DURATION",II)["M":"MINUTES",PSONEW("DURATION",II)["H":"HOURS",PSONEW("DURATION",II)["L":"MONTHS",PSONEW("DURATION",II)["W":"WEEKS",1:"DAYS")_")"
 .S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"          *Duration: ",TDUR,1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 I $G(PSONEW("CONJUNCTION",II))]"" D
 .S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT,"       *Conjunction: ",$S(PSONEW("CONJUNCTION",II)="T":"THEN",PSONEW("CONJUNCTION",II)="X":"EXCEPT",1:"AND"),1,50) D SET^VALM10(LINE,LINETXT) S LINETXT=""
 Q
FMD ;
 Q:$G(PSONEW("DOSE",II))']""  S MIG=PSONEW("DOSE",II)
 I $E(MIG,1)=".",$G(PSONEW("DOSE ORDERED",II)) S MIG="0"_MIG
 F SG=1:1:$L(MIG," ") D
 .I $L(LINETXT_" "_$P(MIG," ",SG))>80 D  Q
 ..S LINE=LINE+1 D ADDITEM^PSOERX1A(.LINETXT," ","",20,1)
 ..D ADDITEM^PSOERX1A(.LINETXT," ",$P(MIG," ",SG),$L(LINETXT),$L($P(MIG," ",SG))+1)
 .D ADDITEM^PSOERX1A(.LINETXT," ",$P(MIG," ",SG),$L(LINETXT),$L($P(MIG," ",SG))+1)
 D SET^VALM10(LINE,LINETXT) S LINETXT=""
 I $G(UNITS)]"" D
 .I $L(LINETXT_" ("_UNITS_")")>80 D  Q
 ..S LINE=LINE+1,LINETXT=""
 ..D ADDITEM^PSOERX1A(.LINETXT," ","",20,1)
 ..D ADDITEM^PSOERX1A(.LINETXT," ("_UNITS_")",22,50)
 ..D SET^VALM10(LINE,LINETXT) S LINETXT=""
 K DS,MIG,SG
 Q