Dcquery.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace app\inter\controller;
  8. use think\Controller;
  9. use think\Request;
  10. use think\Db;
  11. class Dcquery extends Controller
  12. {
  13. public function index(){
  14. // 将来要添加Session控制
  15. // 不登录不能访问
  16. $request= Request::instance();
  17. $params=$request->param();
  18. if(!empty($params["studyid"]) && !empty($params["pid"])){
  19. //
  20. $whereArr=array();
  21. $whereArr["id"]=$params["studyid"];
  22. $whereArr["patient_id"]=$params["pid"];
  23. $study=Db::table("studies")->where($whereArr)->field("id,studyuid")->find();
  24. if(empty($study)){
  25. // 没有找到片子
  26. echo "empty!";
  27. return;
  28. }else{
  29. // 找到了片子,再去查询图像
  30. // 先找series
  31. $data=array();
  32. $studyListData=array();
  33. $studyData=array();
  34. $studyData["transactionId"]=$study["studyuid"];
  35. $studyData["patientName"]="userName";
  36. $series=Db::table("series")->where("study_id",$study["id"])->field("id,seriesuid,description")->select();
  37. if(count($series)>0){
  38. $seriesListData=array();
  39. foreach($series as $key=>$val){
  40. $seriesData=array();
  41. $seriesData["seriesInstanceUid"]=$val["seriesuid"];
  42. $seriesData["seriesDescription"]=$val["description"];
  43. $imgs=Db::table("images")->where("series_id",$val["id"])->field("id,columns,image_number,rows,sop_uid,url,metadata")->select();
  44. $imgsListData=array();
  45. foreach($imgs as $ikey=>$ival){
  46. $imgsData=array();
  47. $imgsData["columns"]=$ival["columns"];
  48. $imgsData["instanceNumber"]=$ival["image_number"];
  49. $imgsData["rows"]=$ival["rows"];
  50. $imgsData["sopInstanceUid"]=$ival["sop_uid"];
  51. $imgsData["url"]="dicomweb://dcm.pacsonline.cn/" . $ival["metadata"];
  52. array_push($imgsListData, $imgsData);
  53. }
  54. $seriesData["instances"]=$imgsListData;
  55. array_push($seriesListData, $seriesData);
  56. }
  57. $studyData["seriesList"]=$seriesListData;
  58. }
  59. array_push($studyListData, $studyData);
  60. }
  61. $data["transactionId"]=$study["studyuid"];
  62. $data["studies"]=$studyListData;
  63. echo json_encode($data);
  64. }else{
  65. echo "error param!";
  66. }
  67. }
  68. }