Dcquery.php 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. public function get_studyinfo(){
  69. $study_id = $_REQUEST['study_id'];
  70. $info = array();
  71. $study_info = DB::table('studies')->where('id',$study_id)->field('studyuid,patient_id')->find();
  72. $info['transactionId'] = $study_info['studyuid'];
  73. $patient_info = DB::table('patient_infos')->where('id',$study_info['patient_id'])->field('name')->find();
  74. $info['patientName'] = $patient_info['name'];
  75. $series_list = DB::table('series')->where('study_id',$study_id)->field('id,seriesuid,description')->select();
  76. $series = array();
  77. foreach($series_list as $k=>$v){
  78. $image = DB::table('images')->where('series_id',$v['id'])->field('columns,image_number as instanceNumber,rows,image_id as sopInstanceUid,url')->select();
  79. foreach($image as $key=>$value){
  80. $image[$key]['url'] = 'http://dcm.pacsonline.cn/'.$value['url'];
  81. }
  82. $series[$k]['instances'] = $image;
  83. $series[$k]['seriesInstanceUid'] = $v['seriesuid'];
  84. $series[$k]['seriesDescription'] = $v['description'];
  85. }
  86. $info['seriesList'] = $series;
  87. return json_encode($info);
  88. }
  89. }