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

BMXRPC5.m

Go to the documentation of this file.
  1. BMXRPC5 ; IHS/OIT/HMW - BMX REMOTE PROCEDURE CALLS ;
  1. ;;4.0;BMX;;JUN 28, 2010
  1. ;
  1. ;Stolen from Mike Remillard. If it doesn't work, it's his fault.
  1. HS(BMXGBL,BMXDFN,BMXTYPE,BMXRDL,BMXFDL) ;EP
  1. ;---> Return patient's Health Summary in global array, ^BMXTEMP($J,"HS"
  1. ;---> Lines delimited by BMXRDL
  1. ;---> File delimited by BMXFDL
  1. ;---> Called by RPC: BMX HEALTH SUMMARY
  1. ;---> Parameters:
  1. ; 1 - BMXGBL (ret) Name of result global containing patient's
  1. ; Health Summary, passed to Broker.
  1. ; 2 - BMXDFN (req) DFN of patient.
  1. ;
  1. ;---> Delimiter to pass error with result to GUI.
  1. N BMX30,BMX31,BMXERR,X
  1. ;S BMX30=$C(30),BMX31=$C(31)_$C(31)
  1. S BMX30=$G(BMXRDL)
  1. I BMX30="" S BMX30=$C(13)_$C(10)
  1. S BMX31=$G(BMXFDL)
  1. S BMXGBL="^BMXTEMP("_$J_",""HS"")",BMXERR=""
  1. K ^BMXTEMP($J,"HS")
  1. ;
  1. N BMXPATH
  1. ;---> Should get path from a Site Parameter. For now, use MSM default.
  1. S BMXPATH="/usr/spool/uucppublic/"
  1. ;S BMXPATH="C:\MSM\" ;TODO: Change to site parameter
  1. ;--->Flag to test whether running as broker job:
  1. N BMXSOCK
  1. S BMXSOCK=0
  1. ;I $I=56 S BMXSOCK=1
  1. ;
  1. ;---> If DFN not supplied, set Error Code and quit.
  1. I '$G(BMXDFN) D Q
  1. . S BMXERR="No Patient DFN" S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
  1. ;
  1. ;---> If patient does not exist, set Error Code and quit.
  1. I '$D(^AUPNPAT(BMXDFN,0)) D Q
  1. . S BMXERR="Patient DFN does not exist" S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
  1. ;
  1. N APCHSPAT,APCHSTYP
  1. S APCHSPAT=BMXDFN
  1. S APCHSTYP=$G(BMXTYPE)
  1. S:'+APCHSTYP APCHSTYP=7
  1. ;S APCHSTYP=9
  1. ;---> Doesn't work from Device 56.
  1. ;D GUIR^XBLM("EN^APCHS","^TMP(""BMXHS"",$J,")
  1. ;
  1. ;---> Generate a host file name.
  1. N BMXFN S BMXFN="XB"_$J
  1. ;
  1. D
  1. .;---> Important to preserve IO variables for when $I returns to 56.
  1. .N IO,IOBS,IOF,IOHG,IOM,ION,IOPAR,IOS,IOSL,IOST,IOT,IOUPAR,IOXY
  1. .;
  1. .;---> Open host file to receive legacy code display.
  1. .S Y=$$OPEN^%ZISH(BMXPATH,BMXFN,"W")
  1. .;O 51:(BMXPATH_BMXFN:"W")
  1. .;S IO=51,IOST="P-OTHER80"
  1. .;K ^HW("HS")
  1. .;S ^HW("HS","IOST")=$G(IOST)
  1. .;S ^HW("HS","IO")=$G(IO)
  1. .;
  1. .;---> Call to legacy code for Health Summary display.
  1. .S IOSL=999,IOM=80
  1. .D EN^APCHS
  1. .;---> Write End of File (EOF) marker.
  1. .W $C(9)
  1. .;
  1. .;---> %ZISC doesn't close Device 51 when called from TCPIP socket?
  1. .;D ^%ZISC
  1. .;---> Buffer won't write out to file until the device is closed
  1. .;---> or the buffer is flushed by some other command.
  1. .;---> At this point, host file exists but has 0 bytes.
  1. .;C 51
  1. .;---> Now host file contains legacy code display data.
  1. .;
  1. .;---> For some reason %ZISH cannot open the host file a second time.
  1. .;S Y=$$OPEN^%ZISH(BMXPATH,BMXFN,"R")
  1. .;O 51:(BMXPATH_BMXFN:"R")
  1. .U 51
  1. .;
  1. .;---> Read in the host file.
  1. .D
  1. ..;---> Stop reading Host File if line contains EOF $C(9).
  1. ..;N I,Y F I=1:1 R Y Q:Y[$C(9) S ^TMP("BMXHS",$J,I)=Y
  1. .;
  1. .;---> %ZISC doesn't close Device 51 when called from TCPIP socket?
  1. .;D ^%ZISC
  1. .;C 51
  1. ;
  1. ;---> At this point $I=1. The job has "forgotten" its $I, even
  1. ;---> though %SS shows 56 as the current device. $I=1 causes a
  1. ;---> <NOPEN> at CAPI+10^XWBBRK2. A simple USE 56 command
  1. ;---> appears to "remind" the job its $I is 56, and it works.
  1. ;---> Possibly this is something %ZISC ordinarily does.
  1. I BMXSOCK U 56
  1. ;U 56
  1. ;
  1. ;---> Copy Health Summary to global array for passing back to GUI.
  1. N I,N,U,X S U="^"
  1. S N=0
  1. F I=1:1 S N=$O(^TMP("BMXHS",$J,N)) Q:'N D
  1. .;---> Set null lines (line breaks) equal to one space, so that
  1. .;---> Windows reader will quit only at the final "null" line.
  1. .S X=^TMP("BMXHS",$J,N) S:X="" X=" "
  1. .S ^BMXTEMP($J,"HS",I)=X_BMX30
  1. ;
  1. ;---> If no Health Summary produced, report it as an error.
  1. D:'$O(^BMXTEMP($J,"HS",0))
  1. . S BMXERR="No Health Summary produced" S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
  1. ;
  1. ;---> Tack on Error Delimiter and any error.
  1. S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
  1. ;
  1. ;---> Delete host file.
  1. ;---> This doesn't work.
  1. S Y=$$DEL^%ZISH(BMXPATH,BMXFN)
  1. ;---> Call system command.
  1. ;S ^MIKE(1)=BMXPATH
  1. ;S ^MIKE(2)=BMXFN
  1. ;S Y=$ZOS(2,BMXPATH_BMXFN)
  1. K ^TMP("BMXHS",$J)
  1. Q