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

BTIULO18.m

Go to the documentation of this file.
BTIULO18 ; IHS/MSC/MGH - EYE RX OBJECT ;06-Jan-2016 12:11;DU
 ;;1.0;TEXT INTEGRATION UTILITIES;**1016**;NOV 04, 2004;Build 10
EYERX(DFN,EYE,TARGET) ;Print eye-glass prescription
 N INVDT,BGOIEN,CNT
 S (INVDT,BGOIEN)=""
 S EYE=$G(EYE)
 K @TARGET
 S CNT=0
 S INVDT=$O(^AUPNVEYE("AA",DFN,""))
 I INVDT="" S @TARGET@(1,0)="No eye exam on file"
 E  D
 .S BGOIEN=9999999
 .S BGOIEN=$O(^AUPNVEYE("AA",DFN,INVDT,BGOIEN),-1) D
 ..I BGOIEN="" S @TARGET@(1,0)="No eye exam on file"
 ..D PRINT(BGOIEN,EYE)
 I CNT=0 S @TARGET@(1,0)="No eye exam on file"
 Q "~@"_$NA(@TARGET)
PRINT(BGOIEN,EYE) ;print out the RX
 N X,J,BGODFN,ONE,EDATA,READ,PAT,FNUM,DASH,UNDER,SPACE,PROV,PROVNAME,ADDR,ADDR2,FAC
 N VDATE,VIEN,EDATE,COMMENT,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
 N DIWF,DIWL,DIWR
 S FNUM=$$FNUM
 S ONE=$G(^AUPNVEYE(BGOIEN,0))
 S EDATA=$G(^AUPNVEYE(BGOIEN,19))
 ;Get pt data
 S PAT=$P(ONE,U,2)
 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 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)
 I EYE="R" D RIGHT(EDATA)
 I EYE="L" D LEFT(EDATA)
 I EYE="P" D PUPIL(EDATA)
 Q
 ;Get right eye data
 S RSPHERE=$$EXTERNAL^DILFD(FNUM,1902,,$P(EDATA,U,2))
 I RSPHERE="" S RSPHERE="    "
 S RCYL=$$EXTERNAL^DILFD(FNUM,1903,,$P(EDATA,U,3))
 I RCYL="" S RCYL="    "
 S RAXIS=$$EXTERNAL^DILFD(FNUM,1904,,$P(EDATA,U,4))
 I RAXIS="" S RAXIS="  "
 S RREAD=$$EXTERNAL^DILFD(FNUM,1908,,$P(EDATA,U,8))
 S RPRISMH=$$EXTERNAL^DILFD(FNUM,1915,,$P(EDATA,U,15))
 S RPRISMHN=+RPRISMH
 I RPRISMHN=0 S RPRISMHN=""
 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=+RPRISMH
 I RPRISMVN=0 S RPRISMVN=""
 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))
 S READ=$$EXTERNAL^DILFD(FNUM,1901,,$P(EDATA,U,1))
 S COMMENT=$G(^AUPNVEYE(BGOIEN,11))
 S $P(DASH,"-",65)="-"
 S DASH2=$$STRING
 S $P(SPACE," ",65)=" "
 S $p(SPACE2," ",63)=" "
 S $P(UNDER,"_",12)="_"
 D PRIGHT
 Q
 ;Get left eye data
LEFT(EDATA) ;EP
 S LSPHERE=$$EXTERNAL^DILFD(FNUM,1902,,$P(EDATA,U,5))
 I LSPHERE="" S LSPHERE="    "
 S LCYL=$$EXTERNAL^DILFD(FNUM,1903,,$P(EDATA,U,6))
 I LCYL="" S LCYL="    "
 S LAXIS=$$EXTERNAL^DILFD(FNUM,1904,,$P(EDATA,U,7))
 I LAXIS="" S LAXIS="  "
 S LREAD=$$EXTERNAL^DILFD(FNUM,1909,,$P(EDATA,U,9))
 S LPRISMH=$$EXTERNAL^DILFD(FNUM,1915,,$P(EDATA,U,16))
 S LPRISMHN=+LPRISMH
 I LPRISMHN=0 S LPRISMHN=""
 S LPRISMHV=$S(LPRISMH["BI":"BI",LPRISMH["BO":"BO",LPRISMH["BU":"BU",LPRISMH["BD":"BD",1:"")
 S LPRISMV=$$EXTERNAL^DILFD(FNUM,1917,,$P(EDATA,U,18))
 S LPRISMVN=+LPRISMV
 I LPRISMVN=0 S LPRISMVN=""
 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))
 S READ=$$EXTERNAL^DILFD(FNUM,1901,,$P(EDATA,U,1))
 S COMMENT=$G(^AUPNVEYE(BGOIEN,11))
 S $P(DASH,"-",65)="-"
 S DASH2=$$STRING
 S $P(SPACE," ",65)=" "
 S $p(SPACE2," ",63)=" "
 S $P(UNDER,"_",12)="_"
 D PLEFT
 Q
 ;Pupil distance
PUPIL(EDATA) ;EP for pupil distance
 S RPD=$$EXTERNAL^DILFD(FNUM,1920,,$P(EDATA,U,20))
 S LPD=$$EXTERNAL^DILFD(FNUM,1919,,$P(EDATA,U,19))
 S PDNEAR=$$EXTERNAL^DILFD(FNUM,1913,,$P(EDATA,U,13))
 I PDNEAR="" S PDNEAR="   "
 S PDFAR=$$EXTERNAL^DILFD(FNUM,1914,,$P(EDATA,U,14))
 I PDFAR="" S PDFAR="   "
 S READ=$$EXTERNAL^DILFD(FNUM,1901,,$P(EDATA,U,1))
 S COMMENT=$G(^AUPNVEYE(BGOIEN,11))
 S $P(DASH,"-",65)="-"
 S DASH2=$$STRING
 S $P(SPACE," ",65)=" "
 S $p(SPACE2," ",63)=" "
 S $P(UNDER,"_",12)="_"
 D PPUPIL
 Q
PRIGHT ;Write out right eye prescription
 D COMMON
 S RHX=RPRISMHN_RPRISMHV
 S RVT=RPRISMVN_RPRISMVV
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Right Eye Exam"
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 S CNT=CNT+1
 S @TARGET@(CNT,0)="        SPHERE   CYL   AXIS    NEAR    PRISM    PRISM"
 S CNT=CNT+1
 S @TARGET@(CNT,0)="                               ADD      HZ       VT"
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 S CNT=CNT+1
 S @TARGET@(CNT,0)="OD      "_RSPHERE_"   "_RCYL_"   "_RAXIS_"     "_RREAD_"    "_RHX_"    "_RVT
 W $L(@TARGET@(CNT,0))
 S CNT=CNT+1
 S @TARGET@(CNT,0)=" "
 D FINISH
 Q
PLEFT ; Wright out left eye prescription
 D COMMON
 S LHX=LPRISMHN_LPRISMHV
 S LVT=LPRISMVN_LPRISMVV
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Left Eye Exam"
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 S CNT=CNT+1
 S @TARGET@(CNT,0)="        SPHERE   CYL   AXIS    NEAR    PRISM    PRISM"
 S CNT=CNT+1
 S @TARGET@(CNT,0)="                               ADD      HZ       VT"
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 S CNT=CNT+1
 S @TARGET@(CNT,0)="OS      "_LSPHERE_"   "_LCYL_"   "_LAXIS_"     "_LREAD_"    "_LHX_"    "_LVT
 W $L(@TARGET@(CNT,0))
 S CNT=CNT+1
 S @TARGET@(CNT,0)=" "
 D FINISH
 Q
PPUPIL ;Write out pupil distance
 D COMMON
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Pupil Distance"
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 S NTXT="" I +RPD S NTXT="R PUPIL"
 S FTXT="" I +LPD S FTXT="L PUPIL"
 S CNT=CNT+1
 S @TARGET@(CNT,0)="          NEAR     DISTANCE   "_NTXT_"   "_FTXT
 S CNT=CNT+1
 S @TARGET@(CNT,0)="           "_PDNEAR_"       "_PDFAR_"         "_RPD_"        "_LPD
 S CNT=CNT+1
 S @TARGET@(CNT,0)=" "
 D FINISH
 Q
COMMON ;Write out the data common to all 3 prescriptions
 S CNT=CNT+1
 S @TARGET@(CNT,0)=""
 S CNT=CNT+1
 S @TARGET@(CNT,0)=""
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 S CNT=CNT+1
 S @TARGET@(CNT,0)=SPACE
 S CNT=CNT+1
 S @TARGET@(CNT,0)="                      "_FAC
 S @TARGET@(CNT,0)="                      "_ADDR
 S CNT=CNT+1
 S @TARGET@(CNT,0)="                    "_CITY_" "_STATE_" "_ZIP
 I ADDR2'="" D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="                              "_ADDR2
 S CNT=CNT+1
 S @TARGET@(CNT,0)=SPACE
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Patient: "_PATNAME_"     Date: "_VDATE
 S CNT=CNT+1
 S @TARGET@(CNT,0)="                                        Expiration: "_UNDER
 S CNT=CNT+1
 S @TARGET@(CNT,0)=SPACE
 Q
FINISH ;Bottom of RX
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Instructions"
 S TYPE=$P(COMMENT,"~",1),COMMENT=$P(COMMENT,"~",2)
 S CNT=CNT+1
 S @TARGET@(CNT,0)="   "_TYPE
 S CNT=CNT+1
 S @TARGET@(CNT,0)=""
 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  S CNT=CNT+1 S @TARGET@(CNT,0)="    "_$G(^UTILITY($J,"W",0,I,0))
 K ^UTILITY($J,"W")
 S CNT=CNT+1
 S @TARGET@(CNT,0)=""
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Provider: "_PROVNAME
 S CNT=CNT+1
 S @TARGET@(CNT,0)=DASH
 Q
EYE(DFN,TARGET) ;print RX
FNUM() Q 9000010.04
STRING() N STR,VAL,I
 S STR=""
 F I=1:1:62 S STR=STR_"-"
 S VAL=STR
 Q VAL