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

BMXRPC1.m

Go to the documentation of this file.
  1. BMXRPC1 ; IHS/OIT/HMW - UTIL: REMOTE PROCEDURE CALLS ;
  1. ;;4.0;BMX;;JUN 28, 2010
  1. ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
  1. ;; UTILITY: CODE FOR REMOTE PROCEDURE CALLS.
  1. ;; RETURNS PATIENT DATA, HEALTH SUMMARY, FACE SHEET.
  1. ;
  1. ;
  1. ;----------
  1. PDATA(BMXDATA,BMXDFN) ;EP
  1. ;---> Return Patient Data in 5 ^-delimited pieces:
  1. ;---> 1 - DOB in format: OCT 01,1994.
  1. ;---> 2 - Age in format: 35 Months.
  1. ;---> 3 - Text of Patient's sex.
  1. ;---> 4 - HRCN in the format XX-XX-XX.
  1. ;---> 5 - Text of ACTIVE/INACTIVE Status.
  1. ;---> Parameters:
  1. ; 1 - BMXDATA (ret) String of patient data||error.
  1. ; 2 - BMXDFN (req) DFN of patient.
  1. ;
  1. ;---> Delimiter to pass error with result to GUI.
  1. N BMX31,BMXERR S BMX31=$C(31)_$C(31)
  1. S BMXDATA="",BMXERR=""
  1. ;
  1. ;---> If DFN not supplied, set Error Code and quit.
  1. I '$G(BMXDFN) D Q
  1. .;D ERRCD^BMXUTL2(201,.BMXERR) S BMXDATA=BMX31_BMXERR
  1. ;
  1. ;---> DOB.
  1. S BMXDATA=$$TXDT1^BMXUTL5($$DOB^BMXUTL1(BMXDFN))
  1. ;
  1. ;---> Age.
  1. S BMXDATA=BMXDATA_U_$$AGEF^BMXUTL1(BMXDFN)
  1. ;
  1. ;---> Text of sex.
  1. S BMXDATA=BMXDATA_U_$$SEXW^BMXUTL1(BMXDFN)
  1. ;
  1. ;---> HRCN, format XX-XX-XX.
  1. S BMXDATA=BMXDATA_U_$$HRCN^BMXUTL1(BMXDFN)
  1. ;
  1. ;---> Active/Inactive Status.
  1. ;S BMXDATA=BMXDATA_U_$$ACTIVE^BMXUTL1(BMXDFN)
  1. ;
  1. S BMXDATA=BMXDATA_BMX31
  1. ;
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. HS(BMXGBL,BMXDFN) ;EP
  1. ;---> Return patient's Health Summary in global array, ^BMXTEMP($J,"HS".
  1. ;---> Lines delimited by "^".
  1. ;---> Called by RPC: BMX IMMSERVE PT PROFILE
  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 BMXGBL="^BMXTEMP("_$J_",""HS"")",BMXERR=""
  1. K ^BMXTEMP($J,"HS")
  1. ;
  1. ;---> If DFN not supplied, set Error Code and quit.
  1. I '$G(BMXDFN) D Q
  1. .;D ERRCD^BMXUTL2(201,.BMXERR) 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. .;D ERRCD^BMXUTL2(203,.BMXERR) S ^BMXTEMP($J,"HS",I)=BMX31_BMXERR
  1. ;
  1. N APCHSPAT,APCHSTYP
  1. S APCHSPAT=BMXDFN,APCHSTYP=7
  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($$HFSPATH^BMXUTL1,BMXFN,"W")
  1. .;
  1. .;---> Call to legacy code for Health Summary display.
  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($$HFSPATH^BMXUTL1,BMXFN,"R")
  1. .;O 51:($$HFSPATH^BMXUTL1_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. ;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. .;D ERRCD^BMXUTL2(407,.BMXERR) 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. ;---> This works; host file gets deleted.
  1. ;S Y=$$DEL^%ZISH($$HFSPATH^BMXUTL1,BMXFN)
  1. K ^TMP("BMXHS",$J)
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. FACE(BMXGBL,BMXDFN) ;EP
  1. ;---> Return patient's Face Sheet in global array, ^BMXTEMP($J,"FACE".
  1. ;---> Lines delimited by "^".
  1. ;---> Called by RPC: BMX IMMSERVE PT PROFILE
  1. ;---> Parameters:
  1. ; 1 - BMXGBL (ret) Name of result global containing patient's
  1. ; Face Sheet, 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 BMXGBL="^BMXTEMP("_$J_",""FACE"")",BMXERR=""
  1. K ^BMXTEMP($J,"FACE")
  1. ;
  1. ;---> If DFN not supplied, set Error Code and quit.
  1. I '$G(BMXDFN) D Q
  1. .;D ERRCD^BMXUTL2(201,.BMXERR) S ^BMXTEMP($J,"FACE",I)=BMX31_BMXERR
  1. ;
  1. ;---> If patient does not exist, set Error Code and quit.
  1. I '$D(^AUPNPAT(BMXDFN,0)) D Q
  1. .;D ERRCD^BMXUTL2(203,.BMXERR) S ^BMXTEMP($J,"FACE",I)=BMX31_BMXERR
  1. ;
  1. N DFN S DFN=BMXDFN
  1. ;---> Doesn't work from Device 56.
  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($$HFSPATH^BMXUTL1,BMXFN,"W")
  1. .;
  1. .;---> Call to legacy code for Face Sheet display.
  1. .U 51
  1. .;D ^BMXFACE
  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($$HFSPATH^BMXUTL1,BMXFN,"R")
  1. .;O 51:($$HFSPATH^BMXUTL1_BMXFN:"R")
  1. .U 51
  1. .;
  1. .;---> Read in the host file.
  1. .D
  1. ..;---> Need some way to mark the end of legacy code output.
  1. ..;---> Stop reading Host File if line contains EOF $C(9).
  1. ..;---> (I added $C(9) above, after ^BMXFACE completed.)
  1. ..;N I,Y F I=1:1 R Y Q:Y[$C(9) S ^TMP("BMXFACE",$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. U 56
  1. ;
  1. ;---> Copy Face Sheet 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("BMXFACE",$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("BMXFACE",$J,N) S:X="" X=" "
  1. .;---> Remove Carriage Return (13)_Formfeed (12) characters.
  1. .I X[$C(13)_$C(12) S X=$P(X,$C(13)_$C(12),2)
  1. .;
  1. .S ^BMXTEMP($J,"FACE",I)=X_BMX30
  1. ;
  1. ;---> If no Health Summary produced, report it as an error.
  1. D:'$O(^BMXTEMP($J,"FACE",0))
  1. .;D ERRCD^BMXUTL2(408,.BMXERR) S ^BMXTEMP($J,"FACE",I)=BMX31_BMXERR
  1. ;
  1. ;---> Tack on Error Delimiter and any error.
  1. S ^BMXTEMP($J,"FACE",I)=BMX31_BMXERR
  1. ;
  1. ;---> This works; host file gets deleted.
  1. ;S Y=$$DEL^%ZISH($$HFSPATH^BMXUTL1,BMXFN)
  1. K ^TMP("BMXFACE",$J)
  1. Q