source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/m/BMXRPC5.m@ 645

Last change on this file since 645 was 645, checked in by Sam Habiel, 14 years ago

Initial Import of BMX.net code

File size: 3.9 KB
Line 
1BMXRPC5 ; IHS/OIT/HMW - BMX REMOTE PROCEDURE CALLS ;
2 ;;2.1;BMX;;Jul 26, 2009
3 ;
4 ;Stolen from Mike Remillard. If it doesn't work, it's his fault.
5HS(BMXGBL,BMXDFN,BMXTYPE,BMXRDL,BMXFDL) ;EP
6 ;---> Return patient's Health Summary in global array, ^BMXTEMP($J,"HS"
7 ;---> Lines delimited by BMXRDL
8 ;---> File delimited by BMXFDL
9 ;---> Called by RPC: BMX HEALTH SUMMARY
10 ;---> Parameters:
11 ; 1 - BMXGBL (ret) Name of result global containing patient's
12 ; Health Summary, passed to Broker.
13 ; 2 - BMXDFN (req) DFN of patient.
14 ;
15 ;---> Delimiter to pass error with result to GUI.
16 N BMX30,BMX31,BMXERR,X
17 ;S BMX30=$C(30),BMX31=$C(31)_$C(31)
18 S BMX30=$G(BMXRDL)
19 I BMX30="" S BMX30=$C(13)_$C(10)
20 S BMX31=$G(BMXFDL)
21 S BMXGBL="^BMXTEMP("_$J_",""HS"")",BMXERR=""
22 K ^BMXTEMP($J,"HS")
23 ;
24 N BMXPATH
25 ;---> Should get path from a Site Parameter. For now, use MSM default.
26 S BMXPATH="/usr/spool/uucppublic/"
27 ;S BMXPATH="C:\MSM\" ;TODO: Change to site parameter
28 ;--->Flag to test whether running as broker job:
29 N BMXSOCK
30 S BMXSOCK=0
31 ;I $I=56 S BMXSOCK=1
32 ;
33 ;---> If DFN not supplied, set Error Code and quit.
34 I '$G(BMXDFN) D Q
35 . S BMXERR="No Patient DFN" S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
36 ;
37 ;---> If patient does not exist, set Error Code and quit.
38 I '$D(^AUPNPAT(BMXDFN,0)) D Q
39 . S BMXERR="Patient DFN does not exist" S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
40 ;
41 N APCHSPAT,APCHSTYP
42 S APCHSPAT=BMXDFN
43 S APCHSTYP=$G(BMXTYPE)
44 S:'+APCHSTYP APCHSTYP=7
45 ;S APCHSTYP=9
46 ;---> Doesn't work from Device 56.
47 ;D GUIR^XBLM("EN^APCHS","^TMP(""BMXHS"",$J,")
48 ;
49 ;---> Generate a host file name.
50 N BMXFN S BMXFN="XB"_$J
51 ;
52 D
53 .;---> Important to preserve IO variables for when $I returns to 56.
54 .N IO,IOBS,IOF,IOHG,IOM,ION,IOPAR,IOS,IOSL,IOST,IOT,IOUPAR,IOXY
55 .;
56 .;---> Open host file to receive legacy code display.
57 .S Y=$$OPEN^%ZISH(BMXPATH,BMXFN,"W")
58 .;O 51:(BMXPATH_BMXFN:"W")
59 .;S IO=51,IOST="P-OTHER80"
60 .;K ^HW("HS")
61 .;S ^HW("HS","IOST")=$G(IOST)
62 .;S ^HW("HS","IO")=$G(IO)
63 .;
64 .;---> Call to legacy code for Health Summary display.
65 .S IOSL=999,IOM=80
66 .D EN^APCHS
67 .;---> Write End of File (EOF) marker.
68 .W $C(9)
69 .;
70 .;---> %ZISC doesn't close Device 51 when called from TCPIP socket?
71 .;D ^%ZISC
72 .;---> Buffer won't write out to file until the device is closed
73 .;---> or the buffer is flushed by some other command.
74 .;---> At this point, host file exists but has 0 bytes.
75 .;C 51
76 .;---> Now host file contains legacy code display data.
77 .;
78 .;---> For some reason %ZISH cannot open the host file a second time.
79 .;S Y=$$OPEN^%ZISH(BMXPATH,BMXFN,"R")
80 .;O 51:(BMXPATH_BMXFN:"R")
81 .U 51
82 .;
83 .;---> Read in the host file.
84 .D
85 ..;---> Stop reading Host File if line contains EOF $C(9).
86 ..;N I,Y F I=1:1 R Y Q:Y[$C(9) S ^TMP("BMXHS",$J,I)=Y
87 .;
88 .;---> %ZISC doesn't close Device 51 when called from TCPIP socket?
89 .;D ^%ZISC
90 .;C 51
91 ;
92 ;---> At this point $I=1. The job has "forgotten" its $I, even
93 ;---> though %SS shows 56 as the current device. $I=1 causes a
94 ;---> <NOPEN> at CAPI+10^XWBBRK2. A simple USE 56 command
95 ;---> appears to "remind" the job its $I is 56, and it works.
96 ;---> Possibly this is something %ZISC ordinarily does.
97 I BMXSOCK U 56
98 ;U 56
99 ;
100 ;---> Copy Health Summary to global array for passing back to GUI.
101 N I,N,U,X S U="^"
102 S N=0
103 F I=1:1 S N=$O(^TMP("BMXHS",$J,N)) Q:'N D
104 .;---> Set null lines (line breaks) equal to one space, so that
105 .;---> Windows reader will quit only at the final "null" line.
106 .S X=^TMP("BMXHS",$J,N) S:X="" X=" "
107 .S ^BMXTEMP($J,"HS",I)=X_BMX30
108 ;
109 ;---> If no Health Summary produced, report it as an error.
110 D:'$O(^BMXTEMP($J,"HS",0))
111 . S BMXERR="No Health Summary produced" S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
112 ;
113 ;---> Tack on Error Delimiter and any error.
114 S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
115 ;
116 ;---> Delete host file.
117 ;---> This doesn't work.
118 S Y=$$DEL^%ZISH(BMXPATH,BMXFN)
119 ;---> Call system command.
120 ;S ^MIKE(1)=BMXPATH
121 ;S ^MIKE(2)=BMXFN
122 ;S Y=$ZOS(2,BMXPATH_BMXFN)
123 K ^TMP("BMXHS",$J)
124 Q
Note: See TracBrowser for help on using the repository browser.