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

ORWRP16.m

Go to the documentation of this file.
  1. ORWRP16 ; ALB/MJK Report Calls - 16bit ;5/22/97 19:13
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;;Dec 17, 1997
  1. ;
  1. LIST(ROOT) ; -- return lists for list boxes
  1. ; RPC: ORWRP REPORT LIST
  1. ; See RPC definition for details on input and output parameters
  1. ;
  1. N EOF
  1. S EOF="$$END",ROOT=$NA(^TMP($J,"ORPTLIST"))
  1. K @ROOT
  1. ;
  1. ; -- get list of reports
  1. D GETRPTS(.ROOT,.EOF)
  1. ; -- get list of health summary types
  1. D GETHS(.ROOT,.EOF)
  1. ; -- get list of date ranges
  1. D GETDT(.ROOT,.EOF)
  1. ;
  1. Q
  1. ;
  1. GETRPTS(ROOT,EOF) ; -- get list of reports
  1. N I,X
  1. D SETITEM(.ROOT,"[REPORT LIST]")
  1. F I=2:1 S X=$P($T(RPTLIST+I),";",3) D SETITEM(.ROOT,X) Q:X=EOF
  1. Q
  1. ;
  1. RPTLIST ; -- list of reports
  1. ;<ID> ^ <report name> ^ <ask date range> ^ <ask health summary type> ^ <right margin>
  1. ;;1^Health Summary^N^Y^80
  1. ;;2^Blood Bank Report^N^N^80
  1. ;;3^Anatomic Path Report^N^N^80
  1. ;;4^Dietetics Profile^N^N^80
  1. ;;5^Vitals Cumulative^Y^N^132
  1. ;;6^Vitals SF511^Y^N^132
  1. ;;$$END
  1. ;
  1. GETHS(ROOT,EOF) ; --get list of health summary types
  1. N I,HSPARM
  1. D GETLST^XPAR(.HSPARM,"SYS","ORWRP HEALTH SUMMARY TYPE LIST","N")
  1. ;
  1. D SETITEM(.ROOT,"[HEALTH SUMMARY TYPES]")
  1. S I=0 F S I=$O(HSPARM(I)) Q:'I D SETITEM(.ROOT,HSPARM(I))
  1. D SETITEM(.ROOT,EOF)
  1. Q
  1. ;
  1. GETDT(ROOT,EOF) ; -- get date range choices
  1. N I,X
  1. D SETITEM(.ROOT,"[DATE RANGES]")
  1. F I=2:1 S X=$P($T(DTLIST+I),";",3) D SETITEM(.ROOT,X) Q:X=EOF
  1. Q
  1. ;
  1. DTLIST ; -- list of date ranges
  1. ;<number of days>^ <display text>
  1. ;;0^Today
  1. ;;7^One Week Back
  1. ;;14^Two Weeks Back
  1. ;;30^One Month Back
  1. ;;180^Six Months Back
  1. ;;365^One Year Back
  1. ;;$$END
  1. ;
  1. SETITEM(ROOT,X) ; -- set item in list
  1. S @ROOT@($O(@ROOT@(9999),-1)+1)=X
  1. Q
  1. ;
  1. RPT(ROOT,DFN,RPTID,HSTYPE,DTRANGE,SECTION) ; -- return report text
  1. ; RPC: ORWRP REPORT TEXT
  1. ; See RPC definition for details on input and output parameters
  1. ;
  1. IF $G(SECTION),$D(^TMP("ORDATA",$J,SECTION)) D G RPTQ
  1. . S ROOT=$NA(^TMP("ORDATA",$J,SECTION))
  1. ;
  1. ; -- init output global for close logic of WORKSTATION device
  1. K ^TMP("ORDATA",$J)
  1. S ROOT=$NA(^TMP("ORDATA",$J,1))
  1. ;
  1. ; -- get report text
  1. IF RPTID=1 D HS(DFN,HSTYPE) G RPTQ
  1. IF RPTID=2 D BL(DFN) G RPTQ
  1. IF RPTID=3 D PATH(DFN) G RPTQ
  1. IF RPTID=4 D DIET(.ROOT,DFN) G RPTQ
  1. IF RPTID=5 D VITALS(DFN,DTRANGE,"VITCUM") G RPTQ
  1. IF RPTID=6 D VITALS(DFN,DTRANGE,"VIT511") G RPTQ
  1. ;
  1. ; -- basic report if id not found above
  1. D NOTYET(.ROOT)
  1. RPTQ Q
  1. ;
  1. HS(ORDFN,ORHS) ; - get health summary report
  1. N ZTQUEUED,ORRM,ORHFS,ORSUB,ORIO
  1. S ORRM=80,ORHFS=$$HFS(),ORSUB="ORDATA"
  1. D OPEN(.ORRM,.ORHFS,"W",.ORIO)
  1. ;
  1. D HSB(.ORDFN,.ORHS)
  1. ;
  1. D CLOSE(.ORRM,.ORHFS,.ORSUB,.ORIO)
  1. Q
  1. ;
  1. HSB(ORDFN,ORHS) ; - build health summary report
  1. N ORVP,GMTYP,Y
  1. S ORVP=ORDFN_";DPT("
  1. S Y=$P($G(^GMT(142,+ORHS,0)),U)
  1. S GMTYP(0)=1,GMTYP(1)=+ORHS_U_Y_U_Y_U_Y
  1. D PQ^ORPRS13
  1. Q
  1. ;
  1. BL(ORDFN) ; -- get blood bank report
  1. N ZTQUEUED,ORRM,ORHFS,ORSUB,ORIO
  1. S ORRM=80,ORHFS=$$HFS(),ORSUB="ORDATA"
  1. D OPEN(.ORRM,.ORHFS,"W",.ORIO)
  1. ;
  1. D BLB(.ORDFN)
  1. ;
  1. D CLOSE(.ORRM,.ORHFS,.ORSUB,.ORIO)
  1. Q
  1. ;
  1. BLB(ORDFN) ; -- build blood bank report
  1. N DFN
  1. ;
  1. D SET^LRBLPD1
  1. IF $G(OREND)'=1 D
  1. . S DFN=ORDFN
  1. . D OERR^LRBLPD1
  1. . D CLEAN^LRBLPD1
  1. Q
  1. ;
  1. PATH(ORDFN) ; -- get anatomic path report
  1. N ZTQUEUED,ORRM,ORHFS,ORSUB,ORIO
  1. S ORRM=80,ORHFS=$$HFS(),ORSUB="ORDATA"
  1. D OPEN(.ORRM,.ORHFS,"W",.ORIO)
  1. ;
  1. D PATHB(.ORDFN)
  1. ;
  1. D CLOSE(.ORRM,.ORHFS,.ORSUB,.ORIO)
  1. Q
  1. ;
  1. PATHB(ORDFN) ; -- build anatomic path report
  1. N DFN
  1. ;
  1. D SET^LRAPS3
  1. IF $G(OREND)'=1 D
  1. . S DFN=ORDFN
  1. . D OERR^LRAPS3
  1. . D CLEAN^LRAPS3
  1. Q
  1. ;
  1. DIET(ROOT,DFN) ; -- get dietetics profile
  1. D NOTYET(.ROOT)
  1. Q
  1. ;
  1. DIETB(DFN) ; -- get dietetics profile
  1. W !!,"Dietetics Profile not yet available."
  1. Q
  1. ;
  1. VITALS(DFN,DTRANGE,ORTAG) ; -- get vitals report
  1. N ZTQUEUED,ORRM,ORHFS,ORSUB,ORIO
  1. S ORRM=132,ORHFS=$$HFS(),ORSUB="ORDATA"
  1. D OPEN(.ORRM,.ORHFS,"W",.ORIO)
  1. ;
  1. D VITALSB(.DFN,.DTRANGE,.ORTAG)
  1. ;
  1. D CLOSE(.ORRM,.ORHFS,.ORSUB,.ORIO)
  1. Q
  1. ;
  1. VITALSB(DFN,DTRANGE,ORTAG) ; -- build vitals report
  1. N ORVP,XQORNOD,ORSSTRT,ORSSTOP
  1. ;
  1. S ORVP=DFN_";DPT(",XQORNOD=1
  1. S X1=DT
  1. ; -- if TODAY then do not substract 1
  1. S X2=-$S(DTRANGE:DTRANGE-1,1:0)
  1. D C^%DTC
  1. S ORSSTRT(XQORNOD)=X-.7641,ORSSTOP(XQORNOD)=DT+.2359
  1. D @ORTAG^ORPRS14
  1. Q
  1. ;
  1. NOTYET(ROOT) ; -- standard not available display text
  1. D SETITEM(.ROOT,"Report not available at this time.")
  1. S @ROOT@(.1)="1^1"
  1. Q
  1. ;
  1. HFS() ; -- get hfs file name
  1. ; -- need to define better unique algorithm
  1. Q "ORU_"_$J_".DAT"
  1. ;
  1. OPEN(ORRM,ORHFS,ORMODE,ORIO) ; -- open WORKSTATION device
  1. ; ORRM: right margin
  1. ; ORHFS: host file name
  1. ; ORMODE: open file in 'R'ead or 'W'rite mode
  1. S ZTQUEUED="" K IOPAR
  1. S IOP="WORKSTATION;"_$G(ORRM,80)
  1. S %ZIS("HFSMODE")=ORMODE,%ZIS("HFSNAME")=ORHFS
  1. D ^%ZIS K IOP,%ZIS
  1. U IO S ORIO=IO
  1. Q
  1. ;
  1. CLOSE(ORRM,ORHFS,ORSUB,ORIO) ; -- close WORKSTATION device
  1. ; ORSUB: unique subscript name for output
  1. IF IO=ORIO D ^%ZISC
  1. U IO
  1. D USEHFS
  1. U IO
  1. Q
  1. USEHFS ; -- use host file to build global array
  1. N IO,OROK
  1. ; D OPEN^%ZISH(ORSUB,"",ORHFS,"R") I POP Q
  1. K ^TMP($J,"ORTMPLST")
  1. S OROK=$$FTG^%ZISH(,ORHFS,$NA(^TMP($J,"ORTMPLST",1)),3)
  1. D BUILD
  1. K ^TMP($J,"ORTMPLST")
  1. ; D CLOSE^%ZISH(ORSUB)
  1. N ORARR S ORARR(ORHFS)=""
  1. S OROK=$$DEL^%ZISH("",$NA(ORARR))
  1. Q
  1. ;
  1. BUILD ; -- build tmp global for report
  1. N INC,CNT,MAX,SECTION,ROOT,STRIP,LN
  1. S SECTION=0,MAX=20000,STRIP=$C(7,12)
  1. D INIT
  1. ; -- strip out ff's and quit on error
  1. S LN=0 F S LN=$O(^TMP($J,"ORTMPLST",LN)) Q:'LN S X=^(LN) D
  1. . ;F U IO R X:5 D Q:$$STATUS^%ZISH
  1. . I (CNT+250)>MAX D INIT
  1. . S X=$TR(X,STRIP,"")
  1. . S INC=INC+1,@ROOT@(INC)=X
  1. . S CNT=CNT+$L(X)
  1. D FINAL
  1. Q
  1. ;
  1. INIT ; -- initialize counts and global section
  1. S (INC,CNT)=0,SECTION=SECTION+1
  1. S ROOT=$NA(^TMP(ORSUB,$J,SECTION))
  1. K @ROOT
  1. Q
  1. ;
  1. FINAL ; -- set 'x of y' for each section
  1. N I
  1. F I=1:1:SECTION S ^TMP(ORSUB,$J,I,.1)=I_U_SECTION
  1. Q
  1. ;