|
@@ -0,0 +1,73 @@
|
|
|
+import {Remote_application, Exam, Report, Patient, Study, Series, Image} from '../../dao';
|
|
|
+import Sequelize from 'sequelize';
|
|
|
+const fs = require('fs');
|
|
|
+export async function fy(ctx) {
|
|
|
+ const remotes = await Remote_application.findAll({
|
|
|
+ where: {
|
|
|
+ sid: 1,
|
|
|
+ remote_institution_id: {
|
|
|
+ [Sequelize.Op.ne] : 'b5bed8f973852c22'
|
|
|
+ },
|
|
|
+ remote_doctor_id: {
|
|
|
+ [Sequelize.Op.ne] : ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const reports = []
|
|
|
+ for(let i = 0; i < remotes.length; i++) {
|
|
|
+ let report = await getReport(remotes[i]);
|
|
|
+ if(report.description) {
|
|
|
+ reports.push(report);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(reports)
|
|
|
+ fs.writeFileSync('/Users/fuyu/zskk_code/zskkDicomParse/server/common/report.json', JSON.stringify(reports));
|
|
|
+}
|
|
|
+
|
|
|
+async function getReport(remote) {
|
|
|
+ let exam_id = remote.exam_id;
|
|
|
+ const exam = await Exam.findOne({where:{id: exam_id}})
|
|
|
+ const report = await Report.findOne({where: {exam_id, type:'2'}})
|
|
|
+
|
|
|
+ const patient = await Patient.findOne({where: {id: exam.patient_id}})
|
|
|
+ const series = await getSeries(exam.study_id)
|
|
|
+ const r = {
|
|
|
+ description: report.description,
|
|
|
+ impression: report.impression,
|
|
|
+ study_uid: exam.study_uid,
|
|
|
+ exam_datetime: exam.exam_datetime,
|
|
|
+ exam_class: exam.exam_class,
|
|
|
+ sex: patient.sex,
|
|
|
+ birthday: patient.birthday,
|
|
|
+ age: patient.age,
|
|
|
+ series
|
|
|
+ }
|
|
|
+ return r;
|
|
|
+}
|
|
|
+
|
|
|
+async function getSeries(study_id) {
|
|
|
+ const series = await Series.findAll({where: {study_id}});
|
|
|
+ const s = [];
|
|
|
+ for(let i = 0; i < series.length; i++) {
|
|
|
+ let serie = await getSerie(series[i]);
|
|
|
+ s.push(serie);
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+}
|
|
|
+
|
|
|
+async function getSerie(serie) {
|
|
|
+ let images = [];
|
|
|
+ let image = await Image.findAll({where: {series_id: serie.id}})
|
|
|
+ for(let i = 0; i < image.length; i++) {
|
|
|
+ images.push({
|
|
|
+ image_id: image[i].image_id,
|
|
|
+ image_number: image[i].image_number,
|
|
|
+ url: image[i].url.replace('dicomweb', 'http')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ seriesuid: serie.seriesuid,
|
|
|
+ series_num: serie.series_num,
|
|
|
+ images
|
|
|
+ }
|
|
|
+}
|