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

BGOVEYE1.m

Go to the documentation of this file.
BGOVEYE1 ; IHS/MSC/MGH - V EYE GLASS RX ;26-Nov-2013 13:33;DU
 ;;1.1;BGO COMPONENTS;**11,12,13**;Mar 20, 2007;Build 2
 ;-----------------------------------------------------------------
 ; Validate the data entry
VAL(RET,INP) ;EP
 N CODE,X
 S RET=""
 S CODE=$P(INP,U,1)
 I CODE="" S RET="-1^Field header not sent" Q
 S X=$P(INP,U,2)
 I CODE="L SPHERE"!(CODE="R SPHERE") D
 .D VEYE1902^AUPNVEYE
 .I '$D(X) S X="-1^Type a number between -28.00 and +16.00"
 I CODE="L CYL"!(CODE="R CYL") D
 .D VEYE1903^AUPNVEYE
 .I '$D(X) S X="-1^Type a number between -9.50 AND +9.50"
 I CODE="L AXIS"!(CODE="R AXIS") D
 .K:+X'=X!(X>180)!(X<0)!(X?.E1"."1N.N) X
 .I '$D(X) S X="-1^Type a whole number between 0 and 180"
 I CODE="L PRISM H"!(CODE="R PRISM H")!(CODE="L PRISM V")!(CODE="R PRISM V") D
 .K:$L(X)>6!($L(X)<1)!(+X>50)!(+X<.25) X
 .I '$D(X) S X="-1^Enter a number between .25 and 50"
 I CODE="L BASE H"!(CODE="L BASE V")!(CODE="R BASE H")!(CODE="R BASE V") D
 .K:X'["BU"&(X'["BD")&(X'["BI")&(X'["BO") X
 .I '$D(X) S X="-1^Base Up=BU, Base Down=BD, BI or BO"
 I CODE="PD NEAR"!(CODE="PD FAR") D
 .K:+X'=X!(X>80)!(X<40)!(X?.E1"."1N.N) X
 .I '$D(X) S X="-1^Type a whole number between 40 and 80"
 I CODE="LEFT PD"!(CODE="RIGHT PD") D
 .K:+X'=X!(X>40)!(X<25)!(X?.E1"."1N.N) X
 .I '$D(X) S X="-1^Type a whole number between 25 and 40"
 I CODE="R READING"!(CODE="L READING") D
 .K:$L(X)>4!($L(X)<3)!'(X?1"."2N!(X?1N1"."2N)) X
 .I $D(X) I X?1"."2N,+X<.74 K X
 .I '$D(X) S CODE="Type a value between .74 AND 9.99 with decimal pt"
 I '$D(X) S RET="-1^Failed validation "_CODE
 E  S RET=X
 Q
EYERX(BGOIEN) ;Print eye-glass prescription
 N X,J,BGODFN,ONE,EDATA,READ,PAT,FNUM,DASH,UNDER,SPACE,PROV,PROVNAME,ADDR,ADDR2,FAC
 N VDATE,VIEN,EDATE,COMMENT,EYE,LSPHERE,RSPHERE,LAXIS,RAXIS,LCYL,RCYL,LPD,RPD,LREAD,RREAD
 N LPRISMH,PDNEAR,PDFAR,LRPISMH,LPRISMHN,LPRISMHV,LPRISMV,LPRISMVN,LPRISMVV,RPRISMH,RPRISMHN,RPRISMV,RPRISMHV,RPRISMVN,RPRISMVV
 N ZIP,DASH2,SPACE2,STATE,CITY,LHX,LVT,RHX,RVT,PATNAME,INST,X1,FTXT,NTXT,TYPE
 K VADM
 S FNUM=$$FNUM
 S ONE=$G(^AUPNVEYE(BGOIEN,0))
 S EDATA=$G(^AUPNVEYE(BGOIEN,19))
 ;Get pt data
 S PAT=$P(ONE,U,2)
 Q:PAT=""
 S PATNAME=$$FNAME^BTIUPCC2(PAT)_" "_$$LNAME^BTIUPCC2(PAT)
 S PAT=$$GET1^DIQ(2,$P(ONE,U,2),.01)
 S VDATE=$$GET1^DIQ(9000010,$P(ONE,U,3),.01)
 S PROVNAME=""
 S PROV=$P($G(^AUPNVEYE(BGOIEN,12)),U,4)
 I PROV'="" S PROVNAME=$P($G(^VA(200,PROV,20)),U,2)
 S X=$$SITE^VASITE()
 S INST=$P(X,U,1)
 S FAC=$P(X,U,2)
 S ADDR=$$GET1^DIQ(4,INST,1.01)
 S ADDR2=$$GET1^DIQ(4,INST,1.02)
 S STATE=$$GET1^DIQ(4,INST,.02)
 S CITY=$$GET1^DIQ(4,INST,1.03)
 S ZIP=$$GET1^DIQ(4,INST,1.04)
 ;Get right eye data
 S RSPHERE=$$EXTERNAL^DILFD(FNUM,1902,,$P(EDATA,U,2))
 S RCYL=$$EXTERNAL^DILFD(FNUM,1903,,$P(EDATA,U,3))
 S RAXIS=$$EXTERNAL^DILFD(FNUM,1904,,$P(EDATA,U,4))
 S RREAD=$$EXTERNAL^DILFD(FNUM,1908,,$P(EDATA,U,8))
 S RPRISMH=$$EXTERNAL^DILFD(FNUM,1915,,$P(EDATA,U,15))
 S RPRISMHN=+RPRISMH
 S RPRISMHV=$S(RPRISMH["BI":"BI",RPRISMH["BO":"BO",RPRISMH["BU":"BU",RPRISMH["BD":"BD",1:"")
 S RPRISMV=$$EXTERNAL^DILFD(FNUM,1917,,$P(EDATA,U,17))
 S RPRISMVN=+RPRISMV
 S RPRISMVV=$S(RPRISMV["BI":"BI",RPRISMV["BO":"BO",RPRISMV["BU":"BU",RPRISMV["BD":"BD",1:"")
 S RPD=$$EXTERNAL^DILFD(FNUM,1920,,$P(EDATA,U,20))
 ;Get left eye data
 S LSPHERE=$$EXTERNAL^DILFD(FNUM,1902,,$P(EDATA,U,5))
 S LCYL=$$EXTERNAL^DILFD(FNUM,1903,,$P(EDATA,U,6))
 S LAXIS=$$EXTERNAL^DILFD(FNUM,1904,,$P(EDATA,U,7))
 S LREAD=$$EXTERNAL^DILFD(FNUM,1909,,$P(EDATA,U,9))
 S LPRISMH=$$EXTERNAL^DILFD(FNUM,1916,,$P(EDATA,U,16))
 S LPRISMHN=+LPRISMH
 S LPRISMHV=$S(LPRISMH["BI":"BI",LPRISMH["BO":"BO",LPRISMH["BU":"BU",LPRISMH["BD":"BD",1:"")
 S LPRISMV=$$EXTERNAL^DILFD(FNUM,1918,,$P(EDATA,U,18))
 S LPRISMVN=+LPRISMV
 S LPRISMVV=$S(LPRISMV["BI":"BI",LPRISMV["BO":"BO",LPRISMV["BU":"BU",LPRISMV["BD":"BD",1:"")
 S LPD=$$EXTERNAL^DILFD(FNUM,1919,,$P(EDATA,U,19))
 ;Pupil distance
 S PDNEAR=$$EXTERNAL^DILFD(FNUM,1913,,$P(EDATA,U,13))
 S PDFAR=$$EXTERNAL^DILFD(FNUM,1914,,$P(EDATA,U,14))
 S READ=$$EXTERNAL^DILFD(FNUM,1901,,$P(EDATA,U,1))
 S COMMENT=$G(^AUPNVEYE(BGOIEN,11))
 S $P(DASH,"-",65)="-"
 S DASH2=$$STRING^BGOVEYE1
 S $P(SPACE," ",65)=" "
 S $p(SPACE2," ",63)=" "
 S $P(UNDER,"_",12)="_"
 ;Write out prescription
 S LHX=LPRISMHN_LPRISMHV
 S RHX=RPRISMHN_RPRISMHV
 S LVT=LPRISMVN_LPRISMVV
 S RVT=RPRISMVN_RPRISMVV
 W !!
 W !,"| "_DASH_" |"
 W !,"| "_SPACE_" |"
 W !,"|",?22,FAC,?67," |"
 W !,"|",?22,ADDR,?67," |"
 W !,"|",?20,CITY_" "_STATE_" "_ZIP,?67," |"
 I ADDR2'="" W !,"|",?30,ADDR,?67," |"
 W !,"| "_SPACE_" |"
 W !,"| Patient: "_PATNAME,?40,"Date: "_VDATE,?67," |"
 W !,"| ",?40,"Expiration: "_UNDER,?67," |"
 W !,"| "_SPACE_" |"
 ;W !,"| "_"Spectacle Rx",?30,"Reading only? "_READ,?67," |"
 W !,"| |",?4,DASH2,?66,"| |"
 W !,"| |",?8,"SPHERE ",?17,"CYL",?23,"AXIS |",?31,"NEAR",?39,"| PRISM",?47,"BASE",?52,"| PRISM",?60,"BASE",?66,"| |"
 W !,"| |",?28,"|",?31,"ADD",?39,"|  HZ",?52,"|  VT",?66,"| |"
 W !,"| |",?4,DASH2,?66,"| |"
 W !,"| |",?4,"OD|",?8,RSPHERE,?16,RCYL,?23,RAXIS,?28,"|",?31,RREAD,?39,"| "_RHX,?52,"| "_RVT,?66,"| |"
 W !,"| |",?4,DASH2,?66,"| |"
 W !,"| |",?4,"OS|",?8,LSPHERE,?16,LCYL,?23,LAXIS,?28,"|",?31,LREAD,?39,"| "_LHX,?52,"| "_LVT,?66,"| |"
 W !,"| |",?4,DASH2,?66,"| |"
 W !,"| "_SPACE_" |"
 W !,"| "_"Pupil Distance",?68,"|"
 W !,"| |",?4,DASH2,?66,"| |"
 S NTXT="" I +RPD S NTXT="R PUPIL"
 S FTXT="" I +LPD S FTXT="L PUPIL"
 W !,"| |",?10,"NEAR ",?20,"DISTANCE",?30,NTXT,?40,FTXT,?66,"| |"
 W !,"| |",?10,PDNEAR,?20,PDFAR,?30,RPD,?40,LPD,?66,"| |"
 W !,"| |",?4,DASH2,?66,"| |"
 W !,"| "_SPACE_" |"
 W !,"| "_"Instructions",?68,"|"
 S TYPE=$P(COMMENT,"~",1),COMMENT=$P(COMMENT,"~",2)
 W !,"| ",?4,TYPE,?68,"|"
 W !,"| "_SPACE_" |"
 I COMMENT'="" D COMM(COMMENT)
 ;K ^UTILITY($J,"W")
 ;S X=COMMENT,DIWL=0,DIWR=60,DIWF="" D ^DIWP
 ;S J=$G(^UTILITY($J,"W",0))
 ;F I=1:1:J  W !,"| ",?4,$G(^UTILITY($J,"W",0,I,0)),?68,"|"
 ;K ^UTILITY($J,"W")
 W !,"| "_SPACE_" |"
 W !,"| Provider: "_PROVNAME,?67," |"
 W !,"| "_SPACE_" |"
 W !,"| Sig: ___________________________",?67," |"
 W !,"| "_DASH_" |"
 Q
COMM(COMMENT) ;EP-
 N LEFT,STR,TXT,I
 S STR=$L(COMMENT)
 I STR<64 D
 .W !,"| ",?4,COMMENT,?68,"|"
 E  D
 .F I=1:1 D  Q:COMMENT=""
 ..S TXT=$E(COMMENT,1,64),COMMENT=$E(COMMENT,65,$L(COMMENT))
 ..W !,"| ",?4,TXT,?68,"|"
 Q
PRINT(RET,DFN,BGOIEN,BGOIO) ;print RX
 N ZTIU,ZTDTH,ZTRTN,ZTSAVE,ZTDESC,ZTIO,ZTSK,INVDT
 S ZTIO=BGOIO,ZTDTH=$H
 S ZTDESC="Printout of eyeglass RX"
 S (INVDT,BGOIEN)=""
 S INVDT=$O(^AUPNVEYE("AA",DFN,"")) Q:INVDT=""  D
 .S BGOIEN=9999999
 .S BGOIEN=$O(^AUPNVEYE("AA",DFN,INVDT,BGOIEN),-1)
 S ZTRTN="EYERX^BGOVEYE1",ZTSAVE(BGOIEN)="",ZTSAVE(BGOIO)=""
 D ^%ZTLOAD
 I $D(ZTSK) S RET="0^"_" eyeglass RX copy queued to print"
 E  S RET="1^Task Rejected"
 Q
PRINTW(ORY,BGOIEN) ; print to windows printer
 N ZTQUEUED,ORHFS,ORSUB,ORIO,ORSTATUS,ROOT,ORERR,ORWIN,ORHANDLE
 N IOM,IOSL,IOST,IOF,IOT,IOS,POP
 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS",ORWIN=1,ORHANDLE="BGOEYE"
 S ORY=$NA(^TMP(ORSUB,$J,1))
 S ORHFS=$$HFS^ORWRP()
 D HFSOPEN^ORWRP(ORHANDLE,ORHFS,"W")
 I POP D  Q
 . I $D(ROOT) D SETITEM^ORWRP(.ROOT,"ERROR: Unable to open HFS file for BGO print")
 D IOVAR^ORWRP(.ORIO,,,"P-WINHFS80")
 N $ETRAP,$ESTACK
 S $ETRAP="D ERR^ORWRP Q"
 U IO
 D EYERX^BGOVEYE1(BGOIEN)
 D HFSCLOSE^ORWRP(ORHANDLE,ORHFS)
 Q
GETRPT(DATA,BGOIEN,BEHFLG) ;EP
 S DATA=$$TMPGBL^CIAVMRPC
 I '$G(BGOIEN) S @DATA@(1)="An eyeglass prescription was not selected." Q
 D CAPTURE^CIAUHFS("D EYERX^BGOVEYE1(BGOIEN)",DATA,80)
 S:'$D(@DATA) @DATA@(1)="No eyeglass Rx was found."
 Q
LASTEYE(ROOT,ORDFN,ID,ALPHA,OMEGA,ORDTRNG,REMOTE,ORMAX,ORFHIE) ; -- get eyeglass RX
 D START^ORWRP(80,"EYEB^BGOVEYE1(.ROOT,.ORDFN,.ID,.ALPHA,.OMEGA,.ORDTRNG,.REMOTE,.ORMAX,.ORFHIE)")
 Q
EYEB(ROOT,ORDFN,ID,ALPHA,OMEGA,ORDTRNG,REMOTE,ORMAX,ORFHIE) ; -- build eyeglass
 N ORVP,XQORNOD,ORSSTRT,ORSSTOP,IEN,INVDT
 Q:'$G(ORDFN)
 I $L(ORDTRNG),'$G(ALPHA) S ALPHA=$$FMADD^XLFDT(DT,-ORDTRNG),OMEGA=$$NOW^XLFDT
 Q:'$G(ALPHA)  Q:'$G(OMEGA)
 I '$P(OMEGA,".",2) S OMEGA=OMEGA_".2359"
 S ORVP=ORDFN_";DPT(",XQORNOD=1,ORSSTRT(XQORNOD)=ALPHA,ORSSTOP(XQORNOD)=OMEGA
 S (INVDT,IEN)=""
 S INVDT=$O(^AUPNVEYE("AA",ORDFN,"")) Q:INVDT=""  D
 .S IEN=9999999
 .S IEN=$O(^AUPNVEYE("AA",ORDFN,INVDT,IEN),-1)
 I IEN="" W !,"No eyeglass RX on file"
 D EYERX(IEN)
 Q
FNUM() Q 9000010.04
STRING() N STR,VAL,I
 S STR=""
 F I=1:1:62 S STR=STR_"-"
 S VAL=STR
 Q VAL