followTaskMapper.xml 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="followTaskMapper">
  6. <!-- 查询任务 -->
  7. <select id="selectFollowTasks111" parameterType="pd" resultType="pd">
  8. SELECT
  9. t.*,
  10. n.useForm,
  11. n.followUpSubject,
  12. n.taskMaterial,
  13. n.taskActionTaskType,
  14. v.sum_total - DATEDIFF(CURRENT_DATE(), sum_total_update_time) AS adjusted_sum_total,
  15. v.dValueCode,
  16. a.dl
  17. FROM
  18. s_gxhpz_follow_task t
  19. LEFT JOIN
  20. s_gxhpz_follow_task_node n ON t.taskId = n.taskId
  21. LEFT JOIN
  22. s_dtp_ysfw_archive_management a ON t.patientId = a.id
  23. LEFT JOIN
  24. s_gxhpz_patient_d_value v ON CONVERT(t.storeId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.storeId USING utf8mb4) COLLATE utf8mb4_unicode_ci
  25. AND CONVERT(t.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci
  26. AND CONVERT(t.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci
  27. where 1 = 1
  28. <if test="id != null">
  29. and t.id = #{id}
  30. </if>
  31. <if test="sum_total_start != null and sum_total_start != '' and sum_total_end != null and sum_total_end != ''">
  32. and v.sum_total between #{sum_total_start} and #{sum_total_end}
  33. </if>
  34. <if test="taskActionTaskType != null and taskActionTaskType!=''">
  35. and n.taskActionTaskType = #{taskActionTaskType}
  36. </if>
  37. <if test="appointmentDate != null">
  38. and t.appointmentDate = #{appointmentDate}
  39. </if>
  40. <if test="subscribebeginTime != null and subscribebeginTime!='' and subscribeendTime != null and subscribeendTime!=''">
  41. and t.appointmentDate between #{subscribebeginTime} and #{subscribeendTime}
  42. </if>
  43. <if test="businessBelonging != null and businessBelonging != ''">
  44. and t.businessBelonging = #{businessBelonging}
  45. </if>
  46. <if test="taskName != null and taskName != ''">
  47. and t.taskName = #{taskName}
  48. </if>
  49. <if test="patientId != null and patientId != ''">
  50. and t.patientId = #{patientId}
  51. </if>
  52. <if test="taskTheme != null and taskTheme != ''">
  53. and t.taskTheme = #{taskTheme}
  54. </if>
  55. <if test="taskFollower != null and taskFollower != ''">
  56. and t.taskFollower = #{taskFollower}
  57. </if>
  58. <if test="storeId != null and storeId != ''">
  59. and t.storeId in (
  60. WITH RECURSIVE subordinates AS (
  61. SELECT dept_id
  62. FROM sys_dept
  63. WHERE parent_id = #{storeId} or dept_id = #{storeId}
  64. UNION ALL
  65. SELECT sd.dept_id
  66. FROM sys_dept sd
  67. INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
  68. )
  69. SELECT DISTINCT dept_id
  70. FROM subordinates
  71. UNION
  72. SELECT #{storeId} AS dept_id
  73. )
  74. </if>
  75. <if test="templeName != null and templeName != ''">
  76. and t.templeName = #{templeName}
  77. </if>
  78. <if test="planId != null and planId != ''">
  79. and t.planId = #{planId}
  80. </if>
  81. <if test="drugsLinkId != null and drugsLinkId != ''">
  82. and t.drugsLinkId = #{drugsLinkId}
  83. </if>
  84. <if test="patientName != null and patientName != ''">
  85. and t.patientName = #{patientName}
  86. </if>
  87. <if test="mdmCode != null and mdmCode != '' ">
  88. and t.mdmCode = #{mdmCode}
  89. </if>
  90. <if test="disease != null and disease != '' ">
  91. AND MATCH(a.dl_names) AGAINST(#{disease} IN BOOLEAN MODE)
  92. </if>
  93. <if test="taskStatus != null and taskStatus != ''">
  94. and t.taskStatus = #{taskStatus}
  95. </if>
  96. <if test="query != null and query != ''">
  97. AND (t.patientName LIKE CONCAT('%', #{query}, '%') OR t.patientId =#{query})
  98. </if>
  99. <if test="product != null and product != ''">
  100. AND (t.genericName LIKE CONCAT('%', #{product}, '%') OR t.productName LIKE CONCAT('%', #{product}, '%') OR t.mdmCode LIKE CONCAT('%', #{product}, '%'))
  101. </if>
  102. and t.taskStatus != '未下发'
  103. <!-- 省略其他字段条件... -->
  104. </select>
  105. <select id="selectFollowTasks" parameterType="pd" resultType="pd">
  106. SELECT
  107. t.*,
  108. n.useForm,
  109. n.followUpSubject,
  110. n.taskMaterial,
  111. n.taskActionTaskType,
  112. v.sum_total - DATEDIFF(CURRENT_DATE(), v.sum_total_update_time) AS adjusted_sum_total,
  113. v.dValueCode,
  114. a.dl
  115. FROM
  116. s_gxhpz_follow_task t
  117. LEFT JOIN
  118. s_gxhpz_follow_task_node n ON t.taskId = n.taskId
  119. LEFT JOIN
  120. s_dtp_ysfw_archive_management a ON t.patientId = a.id
  121. LEFT JOIN
  122. (
  123. SELECT * FROM (
  124. SELECT
  125. *,
  126. ROW_NUMBER() OVER (
  127. PARTITION BY storeId, patientId, mdmCode
  128. ORDER BY sum_total_update_time DESC
  129. ) as rn
  130. FROM s_gxhpz_patient_d_value
  131. ) ranked_values
  132. WHERE rn = 1
  133. ) v ON CONVERT(t.storeId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.storeId USING utf8mb4) COLLATE utf8mb4_unicode_ci
  134. AND CONVERT(t.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci
  135. AND CONVERT(t.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci
  136. where 1 = 1
  137. <if test="id != null">
  138. and t.id = #{id}
  139. </if>
  140. <if test="sum_total_start != null and sum_total_start != '' and sum_total_end != null and sum_total_end != ''">
  141. and v.sum_total between #{sum_total_start} and #{sum_total_end}
  142. </if>
  143. <if test="taskActionTaskType != null and taskActionTaskType!=''">
  144. and n.taskActionTaskType = #{taskActionTaskType}
  145. </if>
  146. <if test="appointmentDate != null">
  147. and t.appointmentDate = #{appointmentDate}
  148. </if>
  149. <if test="subscribebeginTime != null and subscribebeginTime!='' and subscribeendTime != null and subscribeendTime!=''">
  150. and t.appointmentDate between #{subscribebeginTime} and #{subscribeendTime}
  151. </if>
  152. <if test="businessBelonging != null and businessBelonging != ''">
  153. and t.businessBelonging = #{businessBelonging}
  154. </if>
  155. <if test="taskName != null and taskName != ''">
  156. and t.taskName = #{taskName}
  157. </if>
  158. <if test="patientId != null and patientId != ''">
  159. and t.patientId = #{patientId}
  160. </if>
  161. <if test="taskTheme != null and taskTheme != ''">
  162. and t.taskTheme = #{taskTheme}
  163. </if>
  164. <if test="taskFollower != null and taskFollower != ''">
  165. and t.taskFollower = #{taskFollower}
  166. </if>
  167. <if test="storeId != null and storeId != ''">
  168. and t.storeId in (
  169. WITH RECURSIVE subordinates AS (
  170. SELECT dept_id
  171. FROM sys_dept
  172. WHERE parent_id = #{storeId} or dept_id = #{storeId}
  173. UNION ALL
  174. SELECT sd.dept_id
  175. FROM sys_dept sd
  176. INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
  177. )
  178. SELECT DISTINCT dept_id
  179. FROM subordinates
  180. UNION
  181. SELECT #{storeId} AS dept_id
  182. )
  183. </if>
  184. <if test="templeName != null and templeName != ''">
  185. and t.templeName = #{templeName}
  186. </if>
  187. <if test="planId != null and planId != ''">
  188. and t.planId = #{planId}
  189. </if>
  190. <if test="drugsLinkId != null and drugsLinkId != ''">
  191. and t.drugsLinkId = #{drugsLinkId}
  192. </if>
  193. <if test="patientName != null and patientName != ''">
  194. and t.patientName = #{patientName}
  195. </if>
  196. <if test="mdmCode != null and mdmCode != '' ">
  197. and t.mdmCode = #{mdmCode}
  198. </if>
  199. <if test="disease != null and disease != '' ">
  200. AND MATCH(a.dl_names) AGAINST(#{disease} IN BOOLEAN MODE)
  201. </if>
  202. <if test="taskStatus != null and taskStatus != ''">
  203. and t.taskStatus = #{taskStatus}
  204. </if>
  205. <if test="query != null and query != ''">
  206. AND (t.patientName LIKE CONCAT('%', #{query}, '%') OR t.patientId =#{query})
  207. </if>
  208. <if test="product != null and product != ''">
  209. AND (t.genericName LIKE CONCAT('%', #{product}, '%') OR t.productName LIKE CONCAT('%', #{product}, '%') OR t.mdmCode LIKE CONCAT('%', #{product}, '%'))
  210. </if>
  211. and t.taskStatus != '未下发'
  212. <!-- 省略其他字段条件... -->
  213. </select>
  214. <!-- 根据ID查询单个任务 -->
  215. <select id="selectOneById" parameterType="pd" resultType="pd">
  216. select t.*,
  217. mr.id as mrId,
  218. mr.combined_medication_adverse_reaction AS combinedMedicationAdverseReaction,
  219. mr.combined_medication_other_adverse_reactions AS combinedMedicationOtherAdverseReactions,
  220. mr.combined_medication_other_adverse_reactions_image AS combinedMedicationOtherAdverseReactionsImage,
  221. mr.combined_medication_other_adverse_reactions_handling AS combinedMedicationOtherAdverseReactionsHandling,
  222. mr.is_review AS isReview,
  223. mr.imaging_insurance_type AS imagingInsuranceType,
  224. mr.ct_check AS ctCheck,
  225. mr.ct_text AS ctText,
  226. mr.ultrasound_check AS ultrasoundCheck,
  227. mr.ultrasound_text AS ultrasoundText,
  228. mr.mri_check AS mriCheck,
  229. mr.mri_text AS mriText,
  230. mr.other_imaging_examinations AS otherImagingExaminations,
  231. mr.imaging_examinations_image AS imagingExaminationsImage,
  232. mr.tumor_marker_check AS tumorMarkerCheck,
  233. mr.cea AS cea,
  234. mr.afp AS afp,
  235. mr.ca_199 AS ca199,
  236. mr.ca125 AS ca125,
  237. mr.ca153 AS ca153,
  238. mr.hcg AS hcg,
  239. mr.nse AS nse,
  240. mr.cyfra21_1 AS cyfra211,
  241. mr.tg AS tg,
  242. mr.psa AS psa,
  243. mr.tumor_marker_image AS tumorMarkerImage,
  244. mr.lab_test_indicators AS labTestIndicators,
  245. mr.lab_test_indicators_image AS labTestIndicatorsImage,
  246. mr.treatment_type AS treatmentType,
  247. mr.pre_medication_plan AS preMedicationPlan,
  248. mr.current_treatment_plan AS currentTreatmentPlan,
  249. mr.post_progression_treatment_plan AS postProgressionTreatmentPlan,
  250. mr.has_medication_indications AS hasMedicationIndications,
  251. mr.drug_effectiveness AS drugEffectiveness,
  252. mr.clinical_interaction AS clinicalInteraction,
  253. mr.clinical_interaction_description AS clinicalInteractionDescription,
  254. mr.unnecessary_repeated_medication AS unnecessaryRepeatedMedication,
  255. mr.repeated_medication_first_use_date AS repeatedMedicationFirstUseDate,
  256. mr.unnecessary_repeated_medication_description AS unnecessaryRepeatedMedicationDescription,
  257. mr.medication_error AS medicationError,
  258. mr.medication_error_time AS medicationErrorTime,
  259. mr.medication_error_description AS medicationErrorDescription,
  260. mr.medication_record AS medicationRecord,
  261. mr.combined_medication_record AS combinedMedicationRecord,
  262. mr.pain_nrs_score AS painNrsScore,
  263. mr.physical_condition_score AS physicalConditionScore,
  264. mr.is_consultation AS isConsultation,
  265. mr.consultation_type AS consultationType,
  266. mr.specific_question AS specificQuestion,
  267. mr.pharmacist_response AS pharmacistResponse,
  268. mr.patient_condition_assessment AS patientConditionAssessment,
  269. mr.project_description AS projectDescription,
  270. p.name,
  271. p.dateBirth,
  272. p.age,
  273. p.gender,
  274. p.realNameStatus,
  275. p.id as patientId,
  276. p.phoneNumber,
  277. p.address,p.idCardImg,
  278. p.documentNumber,
  279. p.documentType,
  280. p.contactPhone,
  281. p.contactName,
  282. p.addr,
  283. p.dl,
  284. n.useForm ,
  285. n.templateId ,
  286. n.followUpSubject,
  287. n.taskMaterial,
  288. n.taskValidity,
  289. DATE_FORMAT(t.appointmentDate, '%Y-%m-%d %H:%i:%s') AS appointmentDate1,
  290. DATE_FORMAT(t.next_follow_time, '%Y-%m-%d %H:%i:%s') AS next_follow_time2,
  291. DATE_FORMAT(t.timeFirstDiagnosis, '%Y-%m-%d') AS timeFirstDiagnosis2,
  292. DATE_FORMAT(p.timeFirstDiagnosis, '%Y-%m-%d %H:%i:%s') AS FirstDiagnosis
  293. from s_gxhpz_follow_task t
  294. left join s_gxhpz_follow_up_records mr on t.id = mr.taskId
  295. left join s_dtp_ysfw_archive_management p on t.patientId = p.id
  296. left join s_gxhpz_follow_task_node n on t.taskId = n.taskId
  297. where t.id = #{id}
  298. </select>
  299. <!-- 根据ID查询单个任务 -->
  300. <select id="selectOneBytt" parameterType="pd" resultType="pd">
  301. select * from s_gxhpz_follow_task_node where taskId = #{taskId} and templateId= #{templateId}
  302. </select>
  303. <!-- 停止任务 -->
  304. <update id="stopFollowTask" parameterType="pd">
  305. update s_gxhpz_follow_task
  306. <set>
  307. <if test="taskStatus != null">
  308. taskStatus = #{taskStatus},
  309. </if>
  310. <if test="updatedAt != null and updatedAt != ''">
  311. updatedAt = #{updatedAt},
  312. </if>
  313. <if test="operator != null and operator != ''">
  314. operator = #{operator},
  315. </if>
  316. </set>
  317. where planId = #{planId}
  318. </update>
  319. <!-- 关闭任务 -->
  320. <update id="closeTask" parameterType="pd">
  321. update s_gxhpz_follow_task
  322. <set>
  323. <if test="taskStatus != null">
  324. taskStatus = #{taskStatus},
  325. </if>
  326. <if test="updatedAt != null and updatedAt != ''">
  327. updatedAt = #{updatedAt},
  328. </if>
  329. <if test="operator != null and operator != ''">
  330. operator = #{operator},
  331. </if>
  332. </set>
  333. where id = #{id}
  334. </update>
  335. <!-- 插入新任务 -->
  336. <insert id="insertFollowTask" parameterType="pd">
  337. insert into s_gxhpz_follow_task
  338. <trim prefix="(" suffix=")" suffixOverrides=",">
  339. <if test="templeName != null and templeName != ''">
  340. templeName,
  341. </if>
  342. <if test="appointmentDate != null">
  343. appointmentDate,
  344. </if>
  345. <if test="businessBelonging != null and businessBelonging != ''">
  346. businessBelonging,
  347. </if>
  348. <if test="taskName != null and taskName != ''">
  349. taskName,
  350. </if>
  351. <if test="taskTheme != null and taskTheme != ''">
  352. taskTheme,
  353. </if>
  354. <if test="planId != null and planId != ''">
  355. planId,
  356. </if>
  357. <if test="taskId != null and taskId != ''">
  358. taskId,
  359. </if>
  360. <if test="patientId != null and patientId != ''">
  361. patientId,
  362. </if>
  363. <if test="patientName != null and patientName != ''">
  364. patientName,
  365. </if>
  366. <if test="gender != null">
  367. gender,
  368. </if>
  369. <if test="age != null">
  370. age,
  371. </if>
  372. <!-- 省略其他字段... -->
  373. <!-- 新增字段 -->
  374. <if test="followUpSummary != null and followUpSummary != ''">
  375. followUpSummary,
  376. </if>
  377. <if test="followUpSummaryid != null and followUpSummaryid != ''">
  378. followUpSummaryid,
  379. </if>
  380. <if test="disease != null and disease != ''">
  381. disease,
  382. </if>
  383. <if test="storeName != null and storeName != ''">
  384. storeName,
  385. </if>
  386. <if test="storeId != null">
  387. storeId,
  388. </if>
  389. <if test="drugsLinkId != null and drugsLinkId != ''">
  390. drugsLinkId,
  391. </if>
  392. <if test="nodeId != null and nodeId != ''">
  393. nodeId,
  394. </if>
  395. <if test="genericName != null and genericName != ''">
  396. genericName,
  397. </if>
  398. <if test="productName != null and productName != ''">
  399. productName,
  400. </if>
  401. <if test="mdmCode != null and mdmCode != ''">
  402. mdmCode,
  403. </if>
  404. <if test="taskFollower != null and taskFollower != ''">
  405. taskFollower,
  406. </if>
  407. <if test="returnMethod != null and returnMethod != ''">
  408. returnMethod,
  409. </if>
  410. <if test="iscoordinate != null and iscoordinate != ''">
  411. iscoordinate,
  412. </if>
  413. <if test="reasons_uncooperative != null and reasons_uncooperative != ''">
  414. reasons_uncooperative,
  415. </if>
  416. <if test="InterviewRecord != null and InterviewRecord != ''">
  417. InterviewRecord,
  418. </if>
  419. <if test="timeFirstDiagnosis != null and timeFirstDiagnosis != ''">
  420. timeFirstDiagnosis,
  421. </if>
  422. <if test="permanentStopTime != null">
  423. permanentStopTime,
  424. </if>
  425. <if test="returnObject != null and returnObject != ''">
  426. returnObject,
  427. </if>
  428. <if test="returnImgUrl != null and returnImgUrl != ''">
  429. returnImgUrl,
  430. </if>
  431. <if test="medicationStatus != null and medicationStatus != ''">
  432. medicationStatus,
  433. </if>
  434. <if test="stoped != null">
  435. stoped,
  436. </if>
  437. <if test="charitable != null and charitable != ''">
  438. charitable,
  439. </if>
  440. <if test="perpetual_stopdrug_cause != null and perpetual_stopdrug_cause != ''">
  441. perpetual_stopdrug_cause,
  442. </if>
  443. <if test="planningStrategy != null and planningStrategy != ''">
  444. planningStrategy,
  445. </if>
  446. <if test="other_channels != null and other_channels != ''">
  447. other_channels,
  448. </if>
  449. <if test="delay_purchase_doctor != null and delay_purchase_doctor != ''">
  450. delay_purchase_doctor,
  451. </if>
  452. <if test="delayed_purchase_drugs != null and delayed_purchase_drugs != ''">
  453. delayed_purchase_drugs,
  454. </if>
  455. <if test="is_adverse_reaction != null and is_adverse_reaction != ''">
  456. is_adverse_reaction,
  457. </if>
  458. <if test="adverse_reaction_time != null">
  459. adverse_reaction_time,
  460. </if>
  461. <if test="good_response_symptom_id != null and good_response_symptom_id != ''">
  462. good_response_symptom_id,
  463. </if>
  464. <if test="tar != null and tar != ''">
  465. tar,
  466. </if>
  467. <if test="nutrition_evaluation_id != null and nutrition_evaluation_id != ''">
  468. nutrition_evaluation_id,
  469. </if>
  470. <if test="medication_record_id != null and medication_record_id != ''">
  471. medication_record_id,
  472. </if>
  473. <if test="other != null and other != ''">
  474. other,
  475. </if>
  476. <if test="actualFollowUpTime != null">
  477. actualFollowUpTime,
  478. </if>
  479. <if test="callConnectedCount != null">
  480. callConnectedCount,
  481. </if>
  482. <if test="nextCallTime != null">
  483. nextCallTime,
  484. </if>
  485. <if test="lastOutboundFlag != null and lastOutboundFlag != ''">
  486. lastOutboundFlag,
  487. </if>
  488. <if test="outboundCallCount != null">
  489. outboundCallCount,
  490. </if>
  491. <if test="nextOutboundCallCount != null">
  492. nextOutboundCallCount,
  493. </if>
  494. <if test="taskStatus != null and taskStatus != ''">
  495. taskStatus,
  496. </if>
  497. <if test="completionTime != null">
  498. completionTime,
  499. </if>
  500. <if test="lastOutboundStatus != null and lastOutboundStatus != ''">
  501. lastOutboundStatus,
  502. </if>
  503. <if test="operator != null and operator != ''">
  504. operator,
  505. </if>
  506. <if test="interval_this_time != null">
  507. interval_this_time,
  508. </if>
  509. <if test="next_taskTheme != null and next_taskTheme != ''">
  510. next_taskTheme,
  511. </if>
  512. <if test="next_follow_time != null">
  513. next_follow_time,
  514. </if>
  515. <if test="createdAt != null">
  516. createdAt,
  517. </if>
  518. </trim>
  519. values
  520. <trim prefix="(" suffix=")" suffixOverrides=",">
  521. <!-- 基础字段 -->
  522. <if test="templeName != null and templeName != ''">
  523. #{templeName},
  524. </if>
  525. <if test="appointmentDate != null">
  526. #{appointmentDate},
  527. </if>
  528. <if test="businessBelonging != null and businessBelonging != ''">
  529. #{businessBelonging},
  530. </if>
  531. <if test="taskName != null and taskName != ''">
  532. #{taskName},
  533. </if>
  534. <if test="taskTheme != null and taskTheme != ''">
  535. #{taskTheme},
  536. </if>
  537. <if test="planId != null and planId != ''">
  538. #{planId},
  539. </if>
  540. <if test="taskId != null and taskId != ''">
  541. #{taskId},
  542. </if>
  543. <if test="patientId != null and patientId != ''">
  544. #{patientId},
  545. </if>
  546. <if test="patientName != null and patientName != ''">
  547. #{patientName},
  548. </if>
  549. <if test="gender != null">
  550. #{gender},
  551. </if>
  552. <if test="age != null">
  553. #{age},
  554. </if>
  555. <!-- 新增字段 -->
  556. <if test="followUpSummary != null and followUpSummary != ''">
  557. #{followUpSummary},
  558. </if>
  559. <if test="followUpSummaryid != null and followUpSummaryid != ''">
  560. #{followUpSummaryid},
  561. </if>
  562. <if test="disease != null and disease != ''">
  563. #{disease},
  564. </if>
  565. <if test="storeName != null and storeName != ''">
  566. #{storeName},
  567. </if>
  568. <if test="storeId != null">
  569. #{storeId},
  570. </if>
  571. <if test="drugsLinkId != null and drugsLinkId != ''">
  572. #{drugsLinkId},
  573. </if>
  574. <if test="nodeId != null and nodeId != ''">
  575. #{nodeId},
  576. </if>
  577. <if test="genericName != null and genericName != ''">
  578. #{genericName},
  579. </if>
  580. <if test="productName != null and productName != ''">
  581. #{productName},
  582. </if>
  583. <if test="mdmCode != null and mdmCode != ''">
  584. #{mdmCode},
  585. </if>
  586. <if test="taskFollower != null and taskFollower != ''">
  587. #{taskFollower},
  588. </if>
  589. <if test="returnMethod != null and returnMethod != ''">
  590. #{returnMethod},
  591. </if>
  592. <if test="iscoordinate != null and iscoordinate != ''">
  593. #{iscoordinate},
  594. </if>
  595. <if test="reasons_uncooperative != null and reasons_uncooperative != ''">
  596. #{reasons_uncooperative},
  597. </if>
  598. <if test="InterviewRecord != null and InterviewRecord != ''">
  599. #{InterviewRecord},
  600. </if>
  601. <if test="timeFirstDiagnosis != null and timeFirstDiagnosis != ''">
  602. #{timeFirstDiagnosis},
  603. </if>
  604. <if test="permanentStopTime != null">
  605. #{permanentStopTime},
  606. </if>
  607. <if test="returnObject != null and returnObject != ''">
  608. #{returnObject},
  609. </if>
  610. <if test="returnImgUrl != null and returnImgUrl != ''">
  611. #{returnImgUrl},
  612. </if>
  613. <if test="medicationStatus != null and medicationStatus != ''">
  614. #{medicationStatus},
  615. </if>
  616. <if test="stoped != null">
  617. #{stoped},
  618. </if>
  619. <if test="charitable != null and charitable != ''">
  620. #{charitable},
  621. </if>
  622. <if test="perpetual_stopdrug_cause != null and perpetual_stopdrug_cause != ''">
  623. #{perpetual_stopdrug_cause},
  624. </if>
  625. <if test="planningStrategy != null and planningStrategy != ''">
  626. #{planningStrategy},
  627. </if>
  628. <if test="other_channels != null and other_channels != ''">
  629. #{other_channels},
  630. </if>
  631. <if test="delay_purchase_doctor != null and delay_purchase_doctor != ''">
  632. #{delay_purchase_doctor},
  633. </if>
  634. <if test="delayed_purchase_drugs != null and delayed_purchase_drugs != ''">
  635. #{delayed_purchase_drugs},
  636. </if>
  637. <if test="is_adverse_reaction != null and is_adverse_reaction != ''">
  638. #{is_adverse_reaction},
  639. </if>
  640. <if test="adverse_reaction_time != null">
  641. #{adverse_reaction_time},
  642. </if>
  643. <if test="good_response_symptom_id != null and good_response_symptom_id != ''">
  644. #{good_response_symptom_id},
  645. </if>
  646. <if test="tar != null and tar != ''">
  647. #{tar},
  648. </if>
  649. <if test="nutrition_evaluation_id != null and nutrition_evaluation_id != ''">
  650. #{nutrition_evaluation_id},
  651. </if>
  652. <if test="medication_record_id != null and medication_record_id != ''">
  653. #{medication_record_id},
  654. </if>
  655. <if test="other != null and other != ''">
  656. #{other},
  657. </if>
  658. <if test="actualFollowUpTime != null">
  659. #{actualFollowUpTime},
  660. </if>
  661. <if test="callConnectedCount != null">
  662. #{callConnectedCount},
  663. </if>
  664. <if test="nextCallTime != null">
  665. #{nextCallTime},
  666. </if>
  667. <if test="lastOutboundFlag != null and lastOutboundFlag != ''">
  668. #{lastOutboundFlag},
  669. </if>
  670. <if test="outboundCallCount != null">
  671. #{outboundCallCount},
  672. </if>
  673. <if test="nextOutboundCallCount != null">
  674. #{nextOutboundCallCount},
  675. </if>
  676. <if test="taskStatus != null and taskStatus != ''">
  677. #{taskStatus},
  678. </if>
  679. <if test="completionTime != null">
  680. #{completionTime},
  681. </if>
  682. <if test="lastOutboundStatus != null and lastOutboundStatus != ''">
  683. #{lastOutboundStatus},
  684. </if>
  685. <if test="operator != null and operator != ''">
  686. #{operator},
  687. </if>
  688. <if test="interval_this_time != null">
  689. #{interval_this_time},
  690. </if>
  691. <if test="next_taskTheme != null and next_taskTheme != ''">
  692. #{next_taskTheme},
  693. </if>
  694. <if test="next_follow_time != null">
  695. #{next_follow_time},
  696. </if>
  697. <if test="createdAt != null">
  698. #{createdAt},
  699. </if>
  700. </trim>
  701. </insert>
  702. <!-- 更新任务 -->
  703. <update id="updateFollowTask" parameterType="pd">
  704. update s_gxhpz_follow_task
  705. <set>
  706. <if test="templeName != null and templeName != ''">
  707. templeName = #{templeName},
  708. </if>
  709. <if test="appointmentDate != null">
  710. appointmentDate = #{appointmentDate},
  711. </if>
  712. <if test="businessBelonging != null and businessBelonging != ''">
  713. businessBelonging = #{businessBelonging},
  714. </if>
  715. <if test="taskName != null and taskName != ''">
  716. taskName = #{taskName},
  717. </if>
  718. <if test="taskTheme != null and taskTheme != ''">
  719. taskTheme = #{taskTheme},
  720. </if>
  721. <if test="planId != null and planId != ''">
  722. planId = #{planId},
  723. </if>
  724. <if test="taskId != null and taskId != ''">
  725. taskId = #{taskId},
  726. </if>
  727. <if test="nodeId != null and nodeId != ''">
  728. nodeId = #{nodeId},
  729. </if>
  730. <if test="patientId != null and patientId != ''">
  731. patientId = #{patientId},
  732. </if>
  733. <if test="patientName != null and patientName != ''">
  734. patientName = #{patientName},
  735. </if>
  736. <if test="gender != null">
  737. gender = #{gender},
  738. </if>
  739. <if test="age != null">
  740. age = #{age},
  741. </if>
  742. <!-- 省略其他字段... -->
  743. <!-- 新增字段 -->
  744. <if test="followUpSummary != null and followUpSummary != ''">
  745. followUpSummary = #{followUpSummary},
  746. </if>
  747. <if test="followUpSummaryid != null and followUpSummaryid != ''">
  748. followUpSummaryid = #{followUpSummaryid},
  749. </if>
  750. <if test="disease != null and disease != ''">
  751. disease = #{disease},
  752. </if>
  753. <if test="storeName != null and storeName != ''">
  754. storeName = #{storeName},
  755. </if>
  756. <if test="storeId != null">
  757. storeId = #{storeId},
  758. </if>
  759. <if test="drugsLinkId != null and drugsLinkId != ''">
  760. drugsLinkId = #{drugsLinkId},
  761. </if>
  762. <if test="genericName != null and genericName != ''">
  763. genericName = #{genericName},
  764. </if>
  765. <if test="productName != null and productName != ''">
  766. productName = #{productName},
  767. </if>
  768. <if test="mdmCode != null and mdmCode != ''">
  769. mdmCode = #{mdmCode},
  770. </if>
  771. <if test="taskFollower != null and taskFollower != ''">
  772. taskFollower = #{taskFollower},
  773. </if>
  774. <if test="returnMethod != null and returnMethod != ''">
  775. returnMethod = #{returnMethod},
  776. </if>
  777. <if test="iscoordinate != null and iscoordinate != ''">
  778. iscoordinate = #{iscoordinate},
  779. </if>
  780. <if test="reasons_uncooperative != null and reasons_uncooperative != ''">
  781. reasons_uncooperative = #{reasons_uncooperative},
  782. </if>
  783. <if test="InterviewRecord != null and InterviewRecord != ''">
  784. InterviewRecord = #{InterviewRecord},
  785. </if>
  786. <if test="timeFirstDiagnosis != null and timeFirstDiagnosis != ''">
  787. timeFirstDiagnosis = #{timeFirstDiagnosis},
  788. </if>
  789. <if test="permanentStopTime != null and permanentStopTime != ''">
  790. permanentStopTime = #{permanentStopTime},
  791. </if>
  792. <if test="returnObject != null and returnObject != ''">
  793. returnObject = #{returnObject},
  794. </if>
  795. <if test="returnImgUrl != null and returnImgUrl != ''">
  796. returnImgUrl = #{returnImgUrl},
  797. </if>
  798. <if test="medicationStatus != null and medicationStatus != ''">
  799. medicationStatus = #{medicationStatus},
  800. </if>
  801. <if test="stoped != null">
  802. stoped = #{stoped},
  803. </if>
  804. <if test="charitable != null and charitable != ''">
  805. charitable = #{charitable},
  806. </if>
  807. <if test="perpetual_stopdrug_cause != null and perpetual_stopdrug_cause != ''">
  808. perpetual_stopdrug_cause = #{perpetual_stopdrug_cause},
  809. </if>
  810. <if test="planningStrategy != null and planningStrategy != ''">
  811. planningStrategy = #{planningStrategy},
  812. </if>
  813. <if test="other_channels != null and other_channels != ''">
  814. other_channels = #{other_channels},
  815. </if>
  816. <if test="delay_purchase_doctor != null and delay_purchase_doctor != ''">
  817. delay_purchase_doctor = #{delay_purchase_doctor},
  818. </if>
  819. <if test="delayed_purchase_drugs != null and delayed_purchase_drugs != ''">
  820. delayed_purchase_drugs = #{delayed_purchase_drugs},
  821. </if>
  822. <if test="is_adverse_reaction != null and is_adverse_reaction != ''">
  823. is_adverse_reaction = #{is_adverse_reaction},
  824. </if>
  825. <if test="adverse_reaction_time != null and adverse_reaction_time != ''">
  826. adverse_reaction_time = #{adverse_reaction_time},
  827. </if>
  828. <if test="good_response_symptom_id != null and good_response_symptom_id != ''">
  829. good_response_symptom_id = #{good_response_symptom_id},
  830. </if>
  831. <if test="tar != null and tar != ''">
  832. tar = #{tar},
  833. </if>
  834. <if test="nutrition_evaluation_id != null and nutrition_evaluation_id != ''">
  835. nutrition_evaluation_id = #{nutrition_evaluation_id},
  836. </if>
  837. <if test="medication_record_id != null and medication_record_id != ''">
  838. medication_record_id = #{medication_record_id},
  839. </if>
  840. <if test="other != null and other != ''">
  841. other = #{other},
  842. </if>
  843. <if test="actualFollowUpTime != null">
  844. actualFollowUpTime = #{actualFollowUpTime},
  845. </if>
  846. <if test="interval_this_time != null and interval_this_time != ''">
  847. interval_this_time = #{interval_this_time},
  848. </if>
  849. <if test="next_taskTheme != null and next_taskTheme != ''">
  850. next_taskTheme = #{next_taskTheme},
  851. </if>
  852. <if test="next_follow_time != null and next_follow_time != ''">
  853. next_follow_time = #{next_follow_time},
  854. </if>
  855. <if test="callConnectedCount != null">
  856. callConnectedCount = #{callConnectedCount},
  857. </if>
  858. <if test="nextCallTime != null">
  859. nextCallTime = #{nextCallTime},
  860. </if>
  861. <if test="lastOutboundFlag != null and lastOutboundFlag != ''">
  862. lastOutboundFlag = #{lastOutboundFlag},
  863. </if>
  864. <if test="outboundCallCount != null">
  865. outboundCallCount = #{outboundCallCount},
  866. </if>
  867. <if test="nextOutboundCallCount != null">
  868. nextOutboundCallCount = #{nextOutboundCallCount},
  869. </if>
  870. <if test="taskStatus != null and taskStatus != ''">
  871. taskStatus = #{taskStatus},
  872. </if>
  873. <if test="completionTime != null">
  874. completionTime = #{completionTime},
  875. </if>
  876. <if test="lastOutboundStatus != null and lastOutboundStatus != ''">
  877. lastOutboundStatus = #{lastOutboundStatus},
  878. </if>
  879. <if test="updatedAt != null">
  880. updatedAt = #{updatedAt},
  881. </if>
  882. <if test="operator != null and operator != ''">
  883. operator= #{operator},
  884. </if>
  885. </set>
  886. where id = #{id}
  887. </update>
  888. <!-- 更新任务 -->
  889. <update id="updateFollowTaskAppointmentDateByTaskId" parameterType="pd">
  890. update s_gxhpz_follow_task
  891. <set>
  892. <if test="appointmentDate != null">
  893. appointmentDate = #{appointmentDate},
  894. </if>
  895. </set>
  896. where taskId = #{taskId}
  897. </update>
  898. <!-- 修改处方状态 -->
  899. <update id="updateCFBStatus" parameterType="pd">
  900. update s_dtp_prescription_registration
  901. <set>
  902. <if test="status != null">
  903. status = #{status},
  904. </if>
  905. </set>
  906. where drugsLinkId = #{drugsLinkId}
  907. </update>
  908. <!-- 删除任务 -->
  909. <delete id="deleteFollowTasksByIds" parameterType="java.util.List">
  910. <if test="list != null and list.size() > 0">
  911. delete from s_gxhpz_follow_task
  912. where id in
  913. <foreach item="id" index="index" collection="list" open="(" separator="," close=")">
  914. #{id}
  915. </foreach>
  916. </if>
  917. </delete>
  918. <!-- 更据drugsLinkId删除任务 -->
  919. <delete id="deleteTaskByDrugsLinkId" parameterType="pd">
  920. delete from s_gxhpz_follow_task where drugsLinkId =#{drugsLinkId}
  921. </delete>
  922. <!-- 更据计划planId 任务taskId 删除job任务 -->
  923. <delete id="deleteSysJobByPlanId" parameterType="pd">
  924. delete from sys_job where plan_id =#{plan_id}
  925. </delete>
  926. <!--查询定时任务-->
  927. <select id="getJobByTaskId" parameterType="pd" resultType="pd">
  928. select * from sys_job where task_id = #{taskId} and actions = #{actions} ORDER BY create_time DESC
  929. LIMIT 1;
  930. </select>
  931. <!--查询定时任务-->
  932. <select id="getJobByCreateId" parameterType="pd" resultType="pd">
  933. select * from sys_job where create_id = #{createId}
  934. </select>
  935. <!--查询模版节点配置的任务的有效期天数-->
  936. <select id="getNodeConfigByNodeId" parameterType="pd" resultType="pd">
  937. select * from s_dtp_yypz_nodeconfig where id = #{nodeId}
  938. </select>
  939. <!--根据患者id和药查询计划-->
  940. <select id="getPlanByMdmCode" parameterType="pd" resultType="pd">
  941. select * from s_gxhpz_follow_plan where mdmCode = #{mdmCode} and storeId = #{storeId} and patientId= #{patientId}
  942. </select>
  943. <!--根据计划id查询下面的所有任务-->
  944. <select id="getTaskByPlanId" parameterType="pd" resultType="pd">
  945. select * from s_gxhpz_follow_task where planId = #{planId} and storeId = #{storeId} and patientId= #{patientId}
  946. </select>
  947. <!--关闭任务-->
  948. <update id="updateJobByTaskId" parameterType="SysJob">
  949. update sys_job
  950. <set>
  951. <if test="status !=null">status = #{status},</if>
  952. <if test="remark != null and remark != ''">remark = #{remark},</if>
  953. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  954. update_time = sysdate(),
  955. </set>
  956. where task_id = #{taskId} and actions = #{actions}
  957. </update>
  958. <!--关闭患者当前所有计划-->
  959. <update id="closePatientCurrentPlan" parameterType="SysJob">
  960. update s_gxhpz_follow_plan
  961. <set>
  962. <if test="status !=null">status = #{status},</if>
  963. <if test="updateBy != null and updateBy != ''">updatedBy = #{updateBy},</if>
  964. updatedTime = sysdate(),
  965. </set>
  966. where patientId= #{patientId} and storeId= #{storeId}
  967. </update>
  968. <!--关闭患者当前所有计划-->
  969. <update id="closePatientCurrentTask" parameterType="SysJob">
  970. update s_gxhpz_follow_task
  971. <set>
  972. <if test="taskStatus !=null">taskStatus = #{taskStatus},</if>
  973. <if test="operator != null and operator != ''">operator = #{operator},</if>
  974. updatedAt = sysdate(),
  975. </set>
  976. where patientId= #{patientId} and storeId= #{storeId}
  977. </update>
  978. <!--关闭计划更据类型z-->
  979. <update id="closeByPlanTypePlan" parameterType="SysJob">
  980. update s_gxhpz_follow_plan
  981. <set>
  982. <if test="status !=null">status = #{status},</if>
  983. <if test="updateBy != null and updateBy != ''">updatedBy = #{updateBy},</if>
  984. updatedTime = sysdate(),
  985. </set>
  986. where patientId= #{patientId} and businessBelonging= #{businessBelonging} and storeId= #{storeId}
  987. </update>
  988. <!--关闭任务根类型z-->
  989. <update id="closeTaskByTypePlan" parameterType="SysJob">
  990. update s_gxhpz_follow_task
  991. <set>
  992. <if test="taskStatus !=null">taskStatus = #{taskStatus},</if>
  993. <if test="operator != null and operator != ''">operator = #{operator},</if>
  994. updatedAt = sysdate(),
  995. </set>
  996. where patientId= #{patientId} and businessBelonging= #{businessBelonging} and storeId= #{storeId}
  997. </update>
  998. <!--关闭计划根据药z-->
  999. <update id="closePLanCurrentDrugsPlan" parameterType="SysJob">
  1000. update s_gxhpz_follow_plan
  1001. <set>
  1002. <if test="status !=null">status = #{status},</if>
  1003. <if test="updateBy != null and updateBy != ''">updatedBy = #{updateBy},</if>
  1004. updatedTime = sysdate(),
  1005. </set>
  1006. where mdmCode = #{mdmCode} and patientId= #{patientId} and storeId= #{storeId}
  1007. </update>
  1008. <!--关闭任务根据药z-->
  1009. <update id="closeTaskCurrentDrugsPlan" parameterType="SysJob">
  1010. update s_gxhpz_follow_task
  1011. <set>
  1012. <if test="taskStatus !=null">taskStatus = #{taskStatus},</if>
  1013. <if test="operator != null and operator != ''">operator = #{operator},</if>
  1014. updatedAt = sysdate(),
  1015. </set>
  1016. where mdmCode = #{mdmCode} and patientId= #{patientId} and storeId= #{storeId}
  1017. </update>
  1018. <!--关闭定时任务表的计划根据指定药查询出来的计划z-->
  1019. <update id="updateJobByDrugsClosePlanId" parameterType="SysJob">
  1020. update sys_job
  1021. <set>
  1022. <if test="status !=null">status = #{status},</if>
  1023. <if test="remark != null and remark != ''">remark = #{remark},</if>
  1024. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  1025. update_time = sysdate(),
  1026. </set>
  1027. where plan_id = #{planId}
  1028. </update>
  1029. <!--关闭定时任务计划-->
  1030. <update id="updateJobByPlanId" parameterType="SysJob">
  1031. update sys_job
  1032. <set>
  1033. <if test="status !=null">status = #{status},</if>
  1034. <if test="remark != null and remark != ''">remark = #{remark},</if>
  1035. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  1036. update_time = sysdate(),
  1037. </set>
  1038. where plan_id = #{planId}
  1039. </update>
  1040. <!--关闭定时任务计划-->
  1041. <update id="updateJobByRestartPlan" parameterType="SysJob">
  1042. update sys_job
  1043. <set>
  1044. <if test="status !=null">status = #{status},</if>
  1045. <if test="remark != null and remark != ''">remark = #{remark},</if>
  1046. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  1047. update_time = sysdate(),
  1048. </set>
  1049. where plan_id = #{planId} and actions = #{actions} and store_id = #{storeId}
  1050. </update>
  1051. <!--关闭该患者的所有定时任务-->
  1052. <update id="updateJobByPatientId" parameterType="SysJob">
  1053. update sys_job
  1054. <set>
  1055. <if test="status !=null">status = #{status},</if>
  1056. <if test="remark != null and remark != ''">remark = #{remark},</if>
  1057. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  1058. update_time = sysdate(),
  1059. </set>
  1060. where store_id = #{storeId} and patient_id = #{patientId}
  1061. </update>
  1062. <!-- 关闭该患者的所有计划 -->
  1063. <update id="closeFollowPlanByPatientId" parameterType="pd">
  1064. update s_gxhpz_follow_plan
  1065. <set>
  1066. <if test="status != null">
  1067. status = #{status},
  1068. </if>
  1069. <if test="updatedBy != null and updatedBy != ''">
  1070. updatedBy = #{updatedBy},
  1071. </if>
  1072. <if test="updatedTime != null and updatedTime != ''">
  1073. updatedTime = #{updatedTime},
  1074. </if>
  1075. </set>
  1076. where storeId = #{storeId} and patientId = #{patientId}
  1077. </update>
  1078. <!-- 关闭该患者的所有任务 -->
  1079. <update id="stopFollowTaskByPatientId" parameterType="pd">
  1080. update s_gxhpz_follow_task
  1081. <set>
  1082. <if test="taskStatus != null">
  1083. taskStatus = #{taskStatus},
  1084. </if>
  1085. <if test="updatedAt != null and updatedAt != ''">
  1086. updatedAt = #{updatedAt},
  1087. </if>
  1088. <if test="operator != null and operator != ''">
  1089. operator = #{operator},
  1090. </if>
  1091. </set>
  1092. where storeId = #{storeId} and patientId = #{patientId}
  1093. </update>
  1094. <!-- 关闭任务taskid -->
  1095. <update id="closeTaskByTaskId" parameterType="pd">
  1096. update s_gxhpz_follow_task
  1097. <set>
  1098. <if test="taskStatus != null">
  1099. taskStatus = #{taskStatus},
  1100. </if>
  1101. <if test="updatedAt != null and updatedAt != ''">
  1102. updatedAt = #{updatedAt},
  1103. </if>
  1104. <if test="operator != null and operator != ''">
  1105. operator = #{operator},
  1106. </if>
  1107. </set>
  1108. where storeId = #{storeId} and patientId = #{patientId} and taskId=#{taskId}
  1109. </update>
  1110. <!-- 开启生成的任务 -->
  1111. <update id="openTaskByTaskId" parameterType="pd">
  1112. update s_gxhpz_follow_task
  1113. <set>
  1114. <if test="taskStatus != null">
  1115. taskStatus = #{taskStatus},
  1116. </if>
  1117. <if test="updatedAt != null and updatedAt != ''">
  1118. updatedAt = #{updatedAt},
  1119. </if>
  1120. <if test="operator != null and operator != ''">
  1121. operator = #{operator},
  1122. </if>
  1123. <if test="appointmentDate != null and appointmentDate != ''">
  1124. appointmentDate = #{appointmentDate},
  1125. </if>
  1126. </set>
  1127. where storeId = #{storeId} and patientId = #{patientId} and taskId=#{taskId}
  1128. </update>
  1129. <!-- 激活创建的计划 -->
  1130. <update id="openPlanByPlanId" parameterType="pd">
  1131. update s_gxhpz_follow_plan
  1132. <set>
  1133. <if test="status != null">
  1134. status = #{status},
  1135. </if>
  1136. <if test="updatedTime != null and updatedTime != ''">
  1137. updatedTime = #{updatedTime},
  1138. </if>
  1139. <if test="updatedBy != null and updatedBy != ''">
  1140. updatedBy = #{updatedBy},
  1141. </if>
  1142. </set>
  1143. where storeId = #{storeId} and patientId = #{patientId} and planId=#{planId}
  1144. </update>
  1145. <!-- 更新job表的任务执行次数和更换taskID -->
  1146. <update id="updateJobStatusByTaskId" parameterType="pd">
  1147. update sys_job
  1148. <set>
  1149. <if test="status != null">
  1150. status = #{status},
  1151. </if>
  1152. <if test="taskId != null and taskId != ''">
  1153. task_id = #{taskId},
  1154. </if>
  1155. <if test="currentExecutionCount != null">
  1156. currentExecutionCount = #{currentExecutionCount},
  1157. </if>
  1158. <if test="remainingExecutions != null">
  1159. remainingExecutions = #{remainingExecutions},
  1160. </if>
  1161. <if test="updateTime != null and updateTime != ''">
  1162. update_time = #{updateTime},
  1163. </if>
  1164. <if test="remark != null and remark != ''">
  1165. remark = #{remark},
  1166. </if>
  1167. <if test="updateBy != null and updateBy != ''">
  1168. update_by = #{updateBy},
  1169. </if>
  1170. </set>
  1171. where store_id = #{storeId} and patient_id = #{patientId} create_id=#{createId}
  1172. </update>
  1173. <!-- 查询任务 -->
  1174. <select id="findTaskFollowerList" parameterType="pd" resultType="pd">
  1175. SELECT * FROM
  1176. s_dtp_review_pharmacists where 1 = 1
  1177. <if test="position != null and position != ''">
  1178. and position = #{position}
  1179. </if>
  1180. <if test="storeId != null and storeId != '' ">
  1181. and storeId in (
  1182. WITH RECURSIVE subordinates AS (
  1183. SELECT dept_id
  1184. FROM sys_dept
  1185. WHERE parent_id = #{storeId} or dept_id = #{storeId}
  1186. UNION ALL
  1187. SELECT sd.dept_id
  1188. FROM sys_dept sd
  1189. INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
  1190. )
  1191. SELECT DISTINCT dept_id
  1192. FROM subordinates
  1193. UNION
  1194. SELECT #{storeId} AS dept_id
  1195. )
  1196. </if>
  1197. <if test="status != null and status != ''">
  1198. and status = #{status}
  1199. </if>
  1200. </select>
  1201. <select id="findTaskStoreList" parameterType="pd" resultType="pd">
  1202. SELECT dept_id AS id, dept_name FROM sys_dept
  1203. WHERE del_flag = '0'
  1204. <if test="storeId != null and storeId != ''">
  1205. AND (
  1206. dept_id = #{storeId}
  1207. OR FIND_IN_SET(#{storeId}, ancestors) > 0
  1208. )
  1209. </if>
  1210. <if test="status != null and status != ''">
  1211. AND status = #{status}
  1212. </if>
  1213. </select>
  1214. <!-- 最近已完成随访距今天数 -->
  1215. <select id="selectRecentlyCompletedFollowUpDays" parameterType="pd" resultType="int">
  1216. SELECT DATEDIFF(CURDATE(), completionTime) AS days
  1217. FROM s_gxhpz_follow_task
  1218. WHERE taskStatus = '已完成' <!-- 完成状态 -->
  1219. AND patientId = #{patientId}
  1220. ORDER BY completionTime DESC
  1221. LIMIT 1;
  1222. </select>
  1223. <!-- 最近待执行随访距今天数 -->
  1224. <select id="selectRecentlyPendingFollowUpDays" parameterType="pd" resultType="int">
  1225. SELECT DATEDIFF(CURDATE(), appointmentDate) AS days
  1226. FROM s_gxhpz_follow_task
  1227. WHERE taskStatus IN ('待执行', '未下发') <!-- 待执行或未下发状态 -->
  1228. AND patientId = #{patientId}
  1229. ORDER BY appointmentDate ASC
  1230. LIMIT 1;
  1231. </select>
  1232. <!-- 最近订单距今天数 -->
  1233. <select id="selectRecentlyOrderDays" parameterType="pd" resultType="int">
  1234. SELECT DATEDIFF(CURDATE(), registrationDate) AS days
  1235. FROM s_dtp_prescription_registration
  1236. WHERE status = 1 <!-- 订单完成状态 -->
  1237. AND patientId = #{patientId}
  1238. ORDER BY registrationDate DESC
  1239. LIMIT 1;
  1240. </select>
  1241. <!-- 触达手机号 -->
  1242. <select id="getPhoneNumberByPatientId" parameterType="pd" resultType="pd">
  1243. SELECT * FROM s_dtp_ysfw_archive_management WHERE id = #{patientId}
  1244. </select>
  1245. <!-- 用药状态 -->
  1246. <select id="getMedicationStatus" parameterType="pd" resultType="pd">
  1247. SELECT * FROM s_gxhpz_follow_task
  1248. WHERE 1 = 1 <!-- 订单完成状态 -->
  1249. AND patientId = #{patientId}
  1250. AND taskId = #{taskId}
  1251. </select>
  1252. <!-- 业务归属 -->
  1253. <select id="getMedicationBusinessBelonging" parameterType="pd" resultType="pd">
  1254. SELECT * FROM s_gxhpz_follow_task WHERE 1 = 1
  1255. <if test="businessBelong !=null and businessBelong != ''">
  1256. AND businessBelonging = #{businessBelonging}
  1257. </if>
  1258. <if test="medicationStatus !=null and medicationStatus != ''">
  1259. AND medicationStatus = #{medicationStatus}
  1260. </if>
  1261. <if test="stoped !=null and stoped != ''">
  1262. AND stoped = #{stoped}
  1263. </if>
  1264. AND patientId = #{patientId}
  1265. AND taskId = #{taskId}
  1266. </select>
  1267. <!-- 查询任务数第几次任务 -->
  1268. <select id="getCountTask" parameterType="pd" resultType="int">
  1269. SELECT count(1) FROM s_gxhpz_follow_task WHERE 1 = 1
  1270. <if test="businessBelong !=null and businessBelong != ''">
  1271. AND businessBelonging = #{businessBelonging}
  1272. </if>
  1273. <if test="taskStatus !=null and taskStatus != ''">
  1274. AND taskStatus = #{taskStatus}
  1275. </if>
  1276. AND patientId = #{patientId}
  1277. AND storeId = #{storeId}
  1278. </select>
  1279. <!-- 查询自由模版 -->
  1280. <select id="createPlanToGetTemplate" parameterType="pd" resultType="pd">
  1281. SELECT t.*,d.id as nodeId ,d.activateNodeRule ,d.useForm as model FROM s_dtp_yypz_follow_up_sop t left join s_dtp_yypz_nodeconfig d on t.templateId = d.templateId WHERE 1 = 1
  1282. <if test="query !=null and query != ''">
  1283. AND (t.templateName LIKE CONCAT('%', #{query}, '%') OR t.templateId =#{query})
  1284. </if>
  1285. <if test="model !=null and model != ''">
  1286. AND d.activateNodeRule = #{model}
  1287. </if>
  1288. <if test="drug !=null and drug != ''">
  1289. AND t.drug is not null
  1290. </if>
  1291. <if test="drug_yes !=null and drug_yes != ''">
  1292. AND t.drug is null
  1293. </if>
  1294. <if test="status !=null">
  1295. AND t.status = #{status}
  1296. </if>
  1297. AND t.storeId in (
  1298. WITH RECURSIVE subordinates AS (
  1299. SELECT dept_id
  1300. FROM sys_dept
  1301. WHERE parent_id = #{storeId} or dept_id = #{storeId}
  1302. UNION ALL
  1303. SELECT sd.dept_id
  1304. FROM sys_dept sd
  1305. INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
  1306. )
  1307. SELECT DISTINCT dept_id
  1308. FROM subordinates
  1309. UNION
  1310. SELECT #{storeId} AS dept_id
  1311. )
  1312. </select>
  1313. <select id="getSendInfoByPM" parameterType="pd" resultType="pd">
  1314. SELECT
  1315. temp.*
  1316. FROM (
  1317. SELECT
  1318. s.dept_name,
  1319. p.name,
  1320. p.phoneNumber,
  1321. p.id AS patientId,
  1322. d.mdmCode,
  1323. d.storeId,
  1324. d.productName,
  1325. d.sum_total - DATEDIFF(CURRENT_DATE(), d.sum_total_update_time) AS adjusted_sum_total,
  1326. ROW_NUMBER() OVER (PARTITION BY p.id ORDER BY d.sum_total_update_time DESC) AS rn
  1327. FROM s_dtp_ysfw_archive_management p
  1328. LEFT JOIN sys_dept s ON p.storeId = s.dept_id
  1329. LEFT JOIN s_gxhpz_patient_d_value d ON p.id = d.patientId
  1330. WHERE 1 = 1
  1331. <if test="patientId != null and patientId != ''">
  1332. AND p.id = #{patientId}
  1333. </if>
  1334. <if test="mdmCode != null and mdmCode != ''">
  1335. AND d.mdmCode = #{mdmCode}
  1336. </if>
  1337. ) temp
  1338. WHERE temp.rn = 1
  1339. </select>
  1340. <!--查询模版节点配置的任务的有效期天数-->
  1341. <select id="getTaskByTaskId" parameterType="pd" resultType="pd">
  1342. select * from s_gxhpz_follow_task where taskId = #{taskId}
  1343. </select>
  1344. </mapper>