PdfUtils.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using Common;
  2. using LisPacsDataUpload.Models.Report;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Text;
  8. namespace LisPacsDataUpload.business
  9. {
  10. /// <summary>
  11. /// pdf 工具类
  12. /// </summary>
  13. public class PdfUtils
  14. {
  15. /// <summary>
  16. /// 根据lis版本获取请求生成pdf报告的参数 0中联老版lis 1 中联新版lis 2 专业版临生免 3 三方lis
  17. /// </summary>
  18. /// <returns></returns>
  19. public static string getPdfParamByLisVersion(int lisVersion,long yzid)
  20. {
  21. Paramater paramter = new Paramater
  22. {
  23. ZlSysCode = 2500,
  24. PdfPath = $"pdf={AppDomain.CurrentDomain.BaseDirectory}PDF\\Report\\LIS{yzid}.pdf"
  25. };
  26. if (lisVersion==0)
  27. {
  28. //老版lis
  29. /* Select Distinct 'ZLCISBILL' || Trim(To_Char(b.编号, '00000')) || '-2' 报表编号, a.相关id, d.id 标本id
  30. From 病人医嘱记录 A,检验标本记录 d, 病历文件列表 B, 病历单据应用 C
  31. Where a.诊疗项目id = c.诊疗项目id And a.病人来源 = c.应用场合 And c.病历文件id = b.Id And a.Id = :id and a.相关id = d.医嘱id*/
  32. var id = ""; // 标本id
  33. paramter.Params.Add(new SubParameter { Param = $"标本id={id}" });
  34. }
  35. else if (lisVersion == 1)
  36. {
  37. // 新版lis
  38. /* Select distinct 'ZLLISBILL00' || Decode(b.病人来源, 2, c.住院单据, 3, c.体检单据, 4, c.院外单据, c.门诊单据) || '-2' 报表编号, a.Id 标本id
  39. From 检验报告记录 A, 检验申请组合 B, 检验仪器记录 C
  40. Where a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
  41. }
  42. else if (lisVersion == 2)
  43. {
  44. //专业版临生免
  45. }
  46. else
  47. {
  48. // 三方lis
  49. }
  50. return null;
  51. }
  52. public bool GeneratePdf()
  53. {
  54. // 定义要启动的外部程序的路径
  55. string exePath = @"C:\Path\To\Your\Program.exe";
  56. // 定义要传递给外部程序的参数
  57. string arguments = "strJson value1";
  58. // 创建一个新的 ProcessStartInfo 对象
  59. ProcessStartInfo startInfo = new ProcessStartInfo
  60. {
  61. FileName = exePath, // 设置要启动的程序路径
  62. Arguments = arguments, // 设置传递给程序的参数
  63. RedirectStandardOutput = false, // 是否重定向标准输出(根据需要设置)
  64. RedirectStandardError = false, // 是否重定向标准错误(根据需要设置)
  65. UseShellExecute = true, // 是否使用操作系统的 shell 启动进程(通常设置为 true)
  66. CreateNoWindow = true // 是否创建窗口(如果不需要显示窗口,可以设置为 true)
  67. };
  68. try
  69. {
  70. // 启动外部程序
  71. using (Process process = Process.Start(startInfo))
  72. {
  73. // 如果需要等待程序结束,可以使用 process.WaitForExit()
  74. LogHelper.Info("生成lis报告中");
  75. process.WaitForExit();
  76. LogHelper.Info("成功生成lis报告");
  77. // 如果需要读取输出或错误,可以在这里处理
  78. // string output = process.StandardOutput.ReadToEnd();
  79. // string error = process.StandardError.ReadToEnd();
  80. }
  81. }
  82. catch (Exception ex)
  83. {
  84. // 处理异常,例如文件未找到、路径错误等
  85. LogHelper.Info("启动外部程序时出错: " + ex.Message);
  86. }
  87. return true;
  88. }
  89. }
  90. }