factory.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. import 'package:fis_measure/interfaces/process/items/item.dart';
  2. import 'package:fis_measure/interfaces/process/items/item_metas.dart';
  3. import 'package:fis_measure/interfaces/process/items/types.dart';
  4. import 'package:fis_measure/process/items/item.dart';
  5. import 'package:fis_measure/process/primitives/carotid_imt.dart';
  6. import 'package:fis_measure/process/primitives/combos/afi.dart';
  7. import 'package:fis_measure/process/primitives/combos/area_straightline.dart';
  8. import 'package:fis_measure/process/primitives/combos/depth2baseline.dart';
  9. import 'package:fis_measure/process/primitives/combos/flow_area_vti.dart';
  10. import 'package:fis_measure/process/primitives/combos/lv_mass.dart';
  11. import 'package:fis_measure/process/primitives/combos/lwh_straightline.dart';
  12. import 'package:fis_measure/process/primitives/combos/lv_study.dart';
  13. import 'package:fis_measure/process/primitives/combos/pisa.dart';
  14. import 'package:fis_measure/process/primitives/combos/simpson.dart';
  15. import 'package:fis_measure/process/primitives/combos/sv.dart';
  16. import 'package:fis_measure/process/primitives/combos/three_ray.dart';
  17. import 'package:fis_measure/process/primitives/combos/two_area.dart';
  18. import 'package:fis_measure/process/primitives/combos/two_location.dart';
  19. import 'package:fis_measure/process/primitives/combos/two_ray.dart';
  20. import 'package:fis_measure/process/primitives/combos/two_straightline.dart';
  21. import 'package:fis_measure/process/primitives/combos/two_sv.dart';
  22. import 'package:fis_measure/process/primitives/multi_method/auto_doppler_trace.dart';
  23. import 'package:fis_measure/process/primitives/urm_measure/urm_den.dart';
  24. import 'package:fis_measure/process/primitives/urm_measure/urm_trace_measure.dart';
  25. import 'package:fis_measure/process/primitives/urm_measure/urm_ab_ratio.dart';
  26. import 'package:fis_measure/process/primitives/urm_measure/urm_vel.dart';
  27. import 'package:fis_measure/process/primitives/detection.dart';
  28. import 'package:fis_measure/process/primitives/ellipse.dart';
  29. import 'package:fis_measure/process/primitives/empty.dart';
  30. import 'package:fis_measure/process/primitives/location.dart';
  31. import 'package:fis_measure/process/primitives/multi_method/multiple_trace.dart';
  32. import 'package:fis_measure/process/primitives/multi_method/semiauto_trace.dart';
  33. import 'package:fis_measure/process/primitives/polyline.dart';
  34. import 'package:fis_measure/process/primitives/polyline_angle.dart';
  35. import 'package:fis_measure/process/primitives/ray.dart';
  36. import 'package:fis_measure/process/primitives/rvsp.dart';
  37. import 'package:fis_measure/process/primitives/single_straightline.dart';
  38. import 'package:fis_measure/process/primitives/spline.dart';
  39. import 'package:fis_measure/process/primitives/straightline.dart';
  40. import 'package:fis_measure/process/primitives/trace.dart';
  41. import 'package:fis_measure/process/primitives/twoline_angle.dart';
  42. import 'package:fis_measure/process/primitives/urm_measure/urm_ellipse_measure.dart';
  43. import 'package:fis_measure/process/primitives/urm_measure/urm_location_vel.dart';
  44. import 'package:fis_measure/process/primitives/urm_measure/urm_rect_measure.dart';
  45. import 'package:fis_measure/process/primitives/urm_measure/urm_shell_measure.dart';
  46. import 'package:fis_measure/process/primitives/urm_measure/urm_vessel_measure.dart';
  47. import 'package:fis_measure/process/primitives/urm_measure/urm_curvature_trace_measure.dart';
  48. import 'package:fis_measure/process/primitives/urm_measure/urm_curve_curvature_line_measure.dart';
  49. import 'package:fis_measure/process/primitives/urm_measure/urm_straight_curvature_line_measure.dart';
  50. /// 测量项创建器
  51. ///
  52. /// [meta] 测量项元信息
  53. ///
  54. /// [parent] 父项
  55. typedef MeasureItemCreator = MeasureItem Function(
  56. ItemMeta meta,
  57. IMeasureItem? parent,
  58. );
  59. /// 测量项工厂
  60. class MeasureItemFactory {
  61. MeasureItemFactory._();
  62. static MeasureItemFactory? _singletonInstance;
  63. static MeasureItemFactory get _singleton {
  64. if (_singletonInstance == null) {
  65. _singletonInstance = MeasureItemFactory._();
  66. _registerItemCreators();
  67. }
  68. return _singletonInstance!;
  69. }
  70. final _itemCreatorMap = <String, MeasureItemCreator>{};
  71. void _register(String typeName, MeasureItemCreator creator) {
  72. final key = typeName;
  73. _itemCreatorMap[key] = creator;
  74. }
  75. MeasureItemCreator? _findCreator(String typeName) {
  76. final key = typeName;
  77. if (_itemCreatorMap.containsKey(key)) {
  78. return _itemCreatorMap[key];
  79. }
  80. return null;
  81. }
  82. /// 创建测量项
  83. ///
  84. /// [meta] 元信息
  85. ///
  86. /// [parent] 父项
  87. static MeasureItem? createItem(ItemMeta meta, [IMeasureItem? parent]) {
  88. if (meta.measureType.isEmpty) return null;
  89. final creator = _singleton._findCreator(meta.measureType);
  90. if (creator == null) return null;
  91. final item = creator.call(meta, parent);
  92. return item;
  93. }
  94. static void _registerItemCreators() {
  95. // Cardiac
  96. _singleton._register(
  97. MeasureTypes.LvStudyByLineGroup, LvStudy.createLvStudyByLineGroup);
  98. _singleton._register(MeasureTypes.LvStudyByLineGroupTissue,
  99. LvStudy.createLvStudyByLineGroup);
  100. _singleton._register(
  101. MeasureTypes.LvSimpleTissue, LvStudy.createLvSimpleTissue);
  102. _singleton._register(
  103. MeasureTypes.LvSimpleTissueTm, LvStudy.createLvSimpleTissueTm);
  104. _singleton._register(MeasureTypes.LvdMassAL, LVMass.createLVdMass);
  105. _singleton._register(MeasureTypes.RVSP, Rvsp.createRvsp);
  106. _singleton._register(MeasureTypes.LvSimpson, LvStudySimpson.create);
  107. _singleton._register(
  108. MeasureTypes.LvSingleSimpson, LvStudySingleSimpson.create);
  109. // SV
  110. _singleton._register(MeasureTypes.SV, Sv.createSV);
  111. _singleton._register(MeasureTypes.QpQs, TwoSv.crateQpQs);
  112. _singleton._register(MeasureTypes.MultiQpQs, TwoSv.crateQpQs);
  113. _singleton._register(MeasureTypes.FlowVol, Sv.createFlowVol);
  114. _singleton._register(
  115. MeasureTypes.FlowAreaByVTI, FlowAreaByVti.createFlowAreaByVti);
  116. _singleton._register(MeasureTypes.PISA, Pisa.createPisa);
  117. // Empty
  118. _singleton._register(MeasureTypes.Empty, Empty.createEmpty);
  119. // Locations
  120. _singleton._register(MeasureTypes.Depth, Location.createTissueDepth);
  121. _singleton._register(
  122. MeasureTypes.DepthToBaseLine, DepthToBaseLine.createDepthToBaseLine);
  123. // Two Locations
  124. _singleton._register(
  125. MeasureTypes.AbRatioTwoVelocity, TwoLocation.createAbRatioTwoVelocity);
  126. _singleton._register(MeasureTypes.ResistivityIndex,
  127. TwoLocation.createResistivityIndexTwoLocationByEd);
  128. _singleton._register(MeasureTypes.ResistivityIndexTwoLocationByEd,
  129. TwoLocation.createResistivityIndexTwoLocationByEd);
  130. _singleton._register(
  131. MeasureTypes.MaxPgTwoLocation, TwoLocation.createMaxPgTwoLocation);
  132. _singleton._register(MeasureTypes.PulsatilityIndexTwoLocation,
  133. TwoLocation.createPulsatilityIndex);
  134. // Straight
  135. _singleton._register(MeasureTypes.Distance, StraightLine.createDistance);
  136. _singleton._register(MeasureTypes.Ray, Ray.createRay);
  137. _singleton._register(MeasureTypes.LvDpDt, StraightLine.createLvDpDt);
  138. _singleton._register(
  139. MeasureTypes.VolumeOneDistance, StraightLine.createVolume);
  140. // Three StraightLine
  141. _singleton._register(
  142. MeasureTypes.VolumeThreeDistance, LWHStraightLine.createVolume);
  143. _singleton._register(
  144. MeasureTypes.ThreeDistanceMean, LWHStraightLine.createMean);
  145. _singleton._register(
  146. MeasureTypes.ThreeDistanceMax, LWHStraightLine.createMax);
  147. _singleton._register(
  148. MeasureTypes.VolumeTwoDistance, TwoStraightLine.createVolume);
  149. _singleton._register(MeasureTypes.VolumeEllipse, Ellipse.createVolume);
  150. _singleton._register(MeasureTypes.ThreeVerticalDistance,
  151. LWHStraightLine.createThreeVerticalDistance);
  152. // Two Area
  153. _singleton._register(MeasureTypes.StenosisTwoArea, TwoArea.crateStenosis);
  154. _singleton._register(MeasureTypes.AbRatioTwoArea, TwoArea.crateABRatio);
  155. // Two StraightLine
  156. _singleton._register(
  157. MeasureTypes.TwoDistanceBase, TwoStraightLine.createTwoDistanceBase);
  158. _singleton._register(MeasureTypes.ResidualUrine, TwoStraightLine.createRUV);
  159. _singleton._register(MeasureTypes.StenosisTwoDistance,
  160. TwoStraightLine.createStenosisTwoDistance);
  161. _singleton._register(
  162. MeasureTypes.AbRatioTwoDistance, TwoStraightLine.createAbRatioDistance);
  163. _singleton._register(
  164. MeasureTypes.OBRatioFLBPD, TwoStraightLine.createAbRatioDistance);
  165. _singleton._register(
  166. MeasureTypes.OBRatioBPDOFD, TwoStraightLine.createAbRatioDistance);
  167. _singleton._register(MeasureTypes.TwoDistanceAverage,
  168. TwoStraightLine.createTwoDistanceAverage);
  169. _singleton._register(
  170. MeasureTypes.TwoStraightLineAngle, TwoStraightLine.createAngle);
  171. _singleton._register(MeasureTypes.IvsThck, TwoStraightLine.createIvsThck);
  172. _singleton._register(MeasureTypes.TwoVerticalDistance,
  173. TwoStraightLine.createTwoVerticalDistance);
  174. // Angle
  175. _singleton._register(
  176. MeasureTypes.PolyLineAngle, PolylineAngle.createPolyAngle);
  177. // TissueTM
  178. _singleton._register(
  179. MeasureTypes.VerticalDistance, StraightLine.createVerticalDistance);
  180. _singleton._register(MeasureTypes.TimeSpan, StraightLine.createTimeSpan);
  181. _singleton._register(MeasureTypes.MDepth, Location.createTissueTMDepth);
  182. _singleton._register(MeasureTypes.StenosisTwoVerticalDistance,
  183. TwoStraightLine.createStenosisTwoVerticalDistance);
  184. _singleton._register(MeasureTypes.AbRatioTwoVerticalDistance,
  185. TwoStraightLine.createAbRatioTwoVerticalDistance);
  186. _singleton._register(
  187. MeasureTypes.AbRatioTwoSlope, TwoStraightLine.createAbRatioSlope);
  188. _singleton._register(MeasureTypes.EfTeich, TwoStraightLine.createEfTeich);
  189. _singleton._register(MeasureTypes.Slope, StraightLine.createSlope);
  190. _singleton._register(
  191. MeasureTypes.SlopeDoppler, StraightLine.createSlopeDoppler);
  192. _singleton._register(MeasureTypes.Velocity, Location.createVelocity);
  193. _singleton._register(MeasureTypes.DopplerTrace, MultiTrace.createTrace);
  194. _singleton._register(
  195. MeasureTypes.SemiManualTrace, MultiTrace.createTrace); // 暂时只支持手动
  196. _singleton._register(MeasureTypes.Pht, StraightLine.createTimeSpan);
  197. _singleton._register(MeasureTypes.TeiIndex, TwoStraightLine.createTeiIndex);
  198. _singleton._register(MeasureTypes.AbRatioTwoTimeSpan,
  199. TwoStraightLine.createAbRatioTwoTimeSpan);
  200. // Area Perimeter
  201. _singleton._register(
  202. MeasureTypes.AreaPerimeterEllipse, Ellipse.createAreaPerimeter);
  203. _singleton._register(
  204. MeasureTypes.AreaPerimeterPolyline, Polyline.createAreaPerimeter);
  205. _singleton._register(
  206. MeasureTypes.AreaPerimeterSpline, Spline.createAreaPerimeter);
  207. _singleton._register(
  208. MeasureTypes.AreaPerimeterTrace, Trace.createAreaPerimeter);
  209. _singleton._register(MeasureTypes.AreaPerimeterTwoDistance,
  210. TwoStraightLine.createAreaPerimeter);
  211. // Area & H
  212. _singleton._register(
  213. MeasureTypes.AreaStraightLine, AreaStraightLine.createVolume);
  214. _singleton._register(
  215. MeasureTypes.CurveLengthPolyline, Polyline.createCurveLength);
  216. _singleton._register(
  217. MeasureTypes.CurveLengthSpline, Spline.createCurveLength);
  218. _singleton._register(
  219. MeasureTypes.CurveLengthTrace, Trace.createCurveLength);
  220. // Specific
  221. _singleton._register(MeasureTypes.Afi, Afi.createAfi);
  222. _singleton._register(MeasureTypes.HR, SingleStraightLine.createHeartRate);
  223. _singleton._register(MeasureTypes.HipOneRay, TwoRay.createTwoRay);
  224. _singleton._register(MeasureTypes.HipTwoRay, ThreeRay.createThreeRay);
  225. _singleton._register(
  226. MeasureTypes.CardiacAxis, TwolineAngle.createTwolineAngle);
  227. // AI
  228. _singleton._register(MeasureTypes.AntCCA_IMT, CarotidIMT.createMeasureRect);
  229. _singleton._register(
  230. MeasureTypes.PostCCA_IMT, CarotidIMT.createMeasureRect);
  231. _singleton._register(
  232. MeasureTypes.BothCCA_IMT, CarotidIMT.createMeasureRect);
  233. _singleton._register(
  234. MeasureTypes.PlaqueDetection, CarotidDetection.createDetectionRect);
  235. _singleton._register(
  236. MeasureTypes.IntimaDetection, CarotidDetection.createDetectionRect);
  237. // URM 超分辨
  238. // _singleton._register(MeasureTypes.URMCurvature,
  239. // URMCurvatureMeasure.createURMCurvatureMeasure);
  240. _singleton._register(MeasureTypes.URMStraightCurvatureLineMeasure,
  241. URMStraightCurvatureLineMeasure.createURMStraightCurvatureLineMeasure);
  242. _singleton._register(MeasureTypes.URMCurveCurvatureLineMeasure,
  243. URMCurveCurvatureLineMeasure.createURMCurveCurvatureLineMeasure);
  244. _singleton._register(MeasureTypes.URMCurvatureTraceMeasure,
  245. URMCurvatureTraceMeasure.createURMCurvatureTraceMeasure);
  246. _singleton._register(
  247. MeasureTypes.URMRectDensity, URMRectMeasure.createURMRectDensity);
  248. /// TODO
  249. _singleton._register(
  250. MeasureTypes.URMTraceDensity, URMTraceMeasure.createURMTraceDensity);
  251. _singleton._register(MeasureTypes.URMEllipseDensity,
  252. URMEllipseMeasure.createURMEllipseDensity);
  253. _singleton._register(MeasureTypes.URMLocationVel,
  254. URMLocationVelMeasure.createURMLocationVelMeasure);
  255. _singleton._register(
  256. MeasureTypes.URMRectFractalDim, URMRectMeasure.createURMRectFractalDim);
  257. _singleton._register(MeasureTypes.URMTraceFractalDim,
  258. URMTraceMeasure.createURMTraceFractalDim);
  259. _singleton._register(MeasureTypes.URMEllipseFractalDim,
  260. URMEllipseMeasure.createURMEllipseFractalDim);
  261. // _singleton._register(
  262. // MeasureTypes.FractalDimURM, FractalDimURM.CreateFractalDimURM);
  263. // _singleton._register(MeasureTypes.DensityURM, DensityURM.CreateDensityURM);
  264. _singleton._register(MeasureTypes.URMDen, URMDen.create);
  265. _singleton._register(MeasureTypes.URMVel, URMVel.create);
  266. // _singleton._register(MeasureTypes.AutoUterusVertical,
  267. // AutoUterusVertical.CreateAutoUterusVertical);
  268. // _singleton._register(
  269. // MeasureTypes.AutoUterusCross, AutoUterusCross.CreateAutoUterusCross);
  270. // _singleton._register(MeasureTypes.URMDensityRation, AbRatio.create);
  271. // _singleton._register(MeasureTypes.URMFractalDimRation, AbRatio.create);
  272. _singleton._register(
  273. MeasureTypes.URMRectDenMeasure, URMRectMeasure.createURMRectDenMeasure);
  274. _singleton._register(MeasureTypes.URMTraceDenMeasure,
  275. URMTraceMeasure.createURMTraceDenMeasure);
  276. _singleton._register(MeasureTypes.URMEllipseDenMeasure,
  277. URMEllipseMeasure.createURMEllipseDenMeasure);
  278. _singleton._register(
  279. MeasureTypes.URMRectVelMeasure, URMRectMeasure.createURMRectVelMeasure);
  280. _singleton._register(MeasureTypes.URMTraceVelMeasure,
  281. URMTraceMeasure.createURMTraceVelMeasure);
  282. _singleton._register(MeasureTypes.URMEllipseVelMeasure,
  283. URMEllipseMeasure.createURMEllipseVelMeasure);
  284. ////////// 分界线 ///////////
  285. // _singleton._register(MeasureTypes.URMDensityMeasure,
  286. // URMDensityMeasure.CreateURMDensityMeasure);
  287. // _singleton._register(
  288. // MeasureTypes.URMVelMeasure, URMVelMeasure.CreateURMVelMeasure);
  289. // _singleton._register(MeasureTypes.URMDensityVelMeasure,
  290. // URMDensityVelMeasure.CreateURMDensityVelMeasure);
  291. _singleton._register(
  292. MeasureTypes.URMVesselMeasure, URMVesselMeasure.createURMVesselMeasure);
  293. _singleton._register(
  294. MeasureTypes.URMRectPerfusion, URMRectMeasure.createURMRectPerfusion);
  295. _singleton._register(MeasureTypes.URMTracePerfusion,
  296. URMTraceMeasure.createURMTracePerfusion);
  297. _singleton._register(MeasureTypes.URMEllipsePerfusion,
  298. URMEllipseMeasure.createURMEllipsePerfusion);
  299. // =============== 超声机还未完成 Hist 开始================
  300. // _singleton._register(
  301. // MeasureTypes.URMRectHist, URMRectMeasure.createURMRectHist);
  302. // _singleton._register(
  303. // MeasureTypes.URMTraceHist, URMTraceMeasure.createURMTraceHist);
  304. // _singleton._register(
  305. // MeasureTypes.URMEllipseHist, URMEllipseMeasure.createURMEllipseHist);
  306. // _singleton._register(MeasureTypes.URMShellHistMeasure,
  307. // URMShellMeasure.createURMShellHistMeasure);
  308. // =============== 超声机还未完成 结束================
  309. // _singleton._register(MeasureTypes.URMPerfusionMeasure,
  310. // URMPerfusionMeasure.CreateURMPerfusionMeasure);
  311. // _singleton._register(
  312. // MeasureTypes.URMHistMeasure, URMHistMeasure.CreateURMHistMeasure);
  313. _singleton._register(MeasureTypes.URMShellDenMeasure,
  314. URMShellMeasure.createURMShellDenMeasure);
  315. _singleton._register(MeasureTypes.URMShellVelMeasure,
  316. URMShellMeasure.createURMShellVelMeasure);
  317. _singleton._register(MeasureTypes.URMShellDensityMeasure,
  318. URMShellMeasure.createURMShellDensityMeasure);
  319. _singleton._register(MeasureTypes.URMShellFractalDimMeasure,
  320. URMShellMeasure.createURMShellFractalDimMeasure);
  321. _singleton._register(MeasureTypes.URMShellPerfusionMeasure,
  322. URMShellMeasure.createURMShellPerfusionMeasure);
  323. _singleton._register(MeasureTypes.URMRectDenVelMeasure,
  324. URMRectMeasure.createURMRectDenVelMeasure);
  325. _singleton._register(MeasureTypes.URMTraceDenVelMeasure,
  326. URMTraceMeasure.createURMTraceDenVelMeasure);
  327. _singleton._register(MeasureTypes.URMEllipseDenVelMeasure,
  328. URMEllipseMeasure.createURMEllipseDenVelMeasure);
  329. _singleton._register(MeasureTypes.URMShellDenVelMeasure,
  330. URMShellMeasure.createURMShellDenVelMeasure);
  331. /// 新增的
  332. _singleton._register(
  333. MeasureTypes.DensityTwoURMRect, TwoURMRectDen.createTwoURMRectDen);
  334. _singleton._register(
  335. MeasureTypes.DensityTwoTrace, TwoURMTraceDen.createTwoURMTraceDen);
  336. _singleton._register(MeasureTypes.DensityTwoEllipse,
  337. TwoURMEllipseDen.createTwoURMEllipseDen);
  338. /// 遗漏项
  339. _singleton._register(MeasureTypes.FractalDimTwoURMRect,
  340. TwoURMRectFractal.createTwoURMRectFractal);
  341. _singleton._register(MeasureTypes.FractalDimTwoURMTrace,
  342. TwoURMTraceFractal.createTwoURMTraceFractal);
  343. _singleton._register(MeasureTypes.FractalDimTwoURMEllipse,
  344. TwoURMEllipseFractal.createTwoURMEllipseFractal);
  345. _singleton._register(
  346. MeasureTypes.SemiautoTrace,
  347. SemiautoTrace.createTrace,
  348. );
  349. _singleton._register(
  350. MeasureTypes.AutoDopplerTrace,
  351. AutoDopplerTrace.createTrace,
  352. );
  353. }
  354. }