123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="followTaskMapper">
- <!-- 查询任务 -->
- <select id="selectFollowTasks111" parameterType="pd" resultType="pd">
- SELECT
- t.*,
- n.useForm,
- n.followUpSubject,
- n.taskMaterial,
- n.taskActionTaskType,
- v.sum_total - DATEDIFF(CURRENT_DATE(), sum_total_update_time) AS adjusted_sum_total,
- v.dValueCode,
- a.dl
- FROM
- s_gxhpz_follow_task t
- LEFT JOIN
- s_gxhpz_follow_task_node n ON t.taskId = n.taskId
- LEFT JOIN
- s_dtp_ysfw_archive_management a ON t.patientId = a.id
- LEFT JOIN
- 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
- AND CONVERT(t.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci
- AND CONVERT(t.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci
- where 1 = 1
- <if test="id != null">
- and t.id = #{id}
- </if>
- <if test="sum_total_start != null and sum_total_start != '' and sum_total_end != null and sum_total_end != ''">
- and v.sum_total between #{sum_total_start} and #{sum_total_end}
- </if>
- <if test="taskActionTaskType != null and taskActionTaskType!=''">
- and n.taskActionTaskType = #{taskActionTaskType}
- </if>
- <if test="appointmentDate != null">
- and t.appointmentDate = #{appointmentDate}
- </if>
- <if test="subscribebeginTime != null and subscribebeginTime!='' and subscribeendTime != null and subscribeendTime!=''">
- and t.appointmentDate between #{subscribebeginTime} and #{subscribeendTime}
- </if>
- <if test="businessBelonging != null and businessBelonging != ''">
- and t.businessBelonging = #{businessBelonging}
- </if>
- <if test="taskName != null and taskName != ''">
- and t.taskName = #{taskName}
- </if>
- <if test="patientId != null and patientId != ''">
- and t.patientId = #{patientId}
- </if>
- <if test="taskTheme != null and taskTheme != ''">
- and t.taskTheme = #{taskTheme}
- </if>
- <if test="taskFollower != null and taskFollower != ''">
- and t.taskFollower = #{taskFollower}
- </if>
- <if test="storeId != null and storeId != ''">
- and t.storeId in (
- WITH RECURSIVE subordinates AS (
- SELECT dept_id
- FROM sys_dept
- WHERE parent_id = #{storeId} or dept_id = #{storeId}
- UNION ALL
- SELECT sd.dept_id
- FROM sys_dept sd
- INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
- )
- SELECT DISTINCT dept_id
- FROM subordinates
- UNION
- SELECT #{storeId} AS dept_id
- )
- </if>
- <if test="templeName != null and templeName != ''">
- and t.templeName = #{templeName}
- </if>
- <if test="planId != null and planId != ''">
- and t.planId = #{planId}
- </if>
- <if test="drugsLinkId != null and drugsLinkId != ''">
- and t.drugsLinkId = #{drugsLinkId}
- </if>
- <if test="patientName != null and patientName != ''">
- and t.patientName = #{patientName}
- </if>
- <if test="mdmCode != null and mdmCode != '' ">
- and t.mdmCode = #{mdmCode}
- </if>
- <if test="disease != null and disease != '' ">
- AND MATCH(a.dl_names) AGAINST(#{disease} IN BOOLEAN MODE)
- </if>
- <if test="taskStatus != null and taskStatus != ''">
- and t.taskStatus = #{taskStatus}
- </if>
- <if test="query != null and query != ''">
- AND (t.patientName LIKE CONCAT('%', #{query}, '%') OR t.patientId =#{query})
- </if>
- <if test="product != null and product != ''">
- AND (t.genericName LIKE CONCAT('%', #{product}, '%') OR t.productName LIKE CONCAT('%', #{product}, '%') OR t.mdmCode LIKE CONCAT('%', #{product}, '%'))
- </if>
- and t.taskStatus != '未下发'
- <!-- 省略其他字段条件... -->
- </select>
- <select id="selectFollowTasks" parameterType="pd" resultType="pd">
- SELECT
- t.*,
- n.useForm,
- n.followUpSubject,
- n.taskMaterial,
- n.taskActionTaskType,
- v.sum_total - DATEDIFF(CURRENT_DATE(), v.sum_total_update_time) AS adjusted_sum_total,
- v.dValueCode,
- a.dl
- FROM
- s_gxhpz_follow_task t
- LEFT JOIN
- s_gxhpz_follow_task_node n ON t.taskId = n.taskId
- LEFT JOIN
- s_dtp_ysfw_archive_management a ON t.patientId = a.id
- LEFT JOIN
- (
- SELECT * FROM (
- SELECT
- *,
- ROW_NUMBER() OVER (
- PARTITION BY storeId, patientId, mdmCode
- ORDER BY sum_total_update_time DESC
- ) as rn
- FROM s_gxhpz_patient_d_value
- ) ranked_values
- WHERE rn = 1
- ) v ON CONVERT(t.storeId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.storeId USING utf8mb4) COLLATE utf8mb4_unicode_ci
- AND CONVERT(t.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.patientId USING utf8mb4) COLLATE utf8mb4_unicode_ci
- AND CONVERT(t.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci = CONVERT(v.mdmCode USING utf8mb4) COLLATE utf8mb4_unicode_ci
- where 1 = 1
- <if test="id != null">
- and t.id = #{id}
- </if>
- <if test="sum_total_start != null and sum_total_start != '' and sum_total_end != null and sum_total_end != ''">
- and v.sum_total between #{sum_total_start} and #{sum_total_end}
- </if>
- <if test="taskActionTaskType != null and taskActionTaskType!=''">
- and n.taskActionTaskType = #{taskActionTaskType}
- </if>
- <if test="appointmentDate != null">
- and t.appointmentDate = #{appointmentDate}
- </if>
- <if test="subscribebeginTime != null and subscribebeginTime!='' and subscribeendTime != null and subscribeendTime!=''">
- and t.appointmentDate between #{subscribebeginTime} and #{subscribeendTime}
- </if>
- <if test="businessBelonging != null and businessBelonging != ''">
- and t.businessBelonging = #{businessBelonging}
- </if>
- <if test="taskName != null and taskName != ''">
- and t.taskName = #{taskName}
- </if>
- <if test="patientId != null and patientId != ''">
- and t.patientId = #{patientId}
- </if>
- <if test="taskTheme != null and taskTheme != ''">
- and t.taskTheme = #{taskTheme}
- </if>
- <if test="taskFollower != null and taskFollower != ''">
- and t.taskFollower = #{taskFollower}
- </if>
- <if test="storeId != null and storeId != ''">
- and t.storeId in (
- WITH RECURSIVE subordinates AS (
- SELECT dept_id
- FROM sys_dept
- WHERE parent_id = #{storeId} or dept_id = #{storeId}
- UNION ALL
- SELECT sd.dept_id
- FROM sys_dept sd
- INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
- )
- SELECT DISTINCT dept_id
- FROM subordinates
- UNION
- SELECT #{storeId} AS dept_id
- )
- </if>
- <if test="templeName != null and templeName != ''">
- and t.templeName = #{templeName}
- </if>
- <if test="planId != null and planId != ''">
- and t.planId = #{planId}
- </if>
- <if test="drugsLinkId != null and drugsLinkId != ''">
- and t.drugsLinkId = #{drugsLinkId}
- </if>
- <if test="patientName != null and patientName != ''">
- and t.patientName = #{patientName}
- </if>
- <if test="mdmCode != null and mdmCode != '' ">
- and t.mdmCode = #{mdmCode}
- </if>
- <if test="disease != null and disease != '' ">
- AND MATCH(a.dl_names) AGAINST(#{disease} IN BOOLEAN MODE)
- </if>
- <if test="taskStatus != null and taskStatus != ''">
- and t.taskStatus = #{taskStatus}
- </if>
- <if test="query != null and query != ''">
- AND (t.patientName LIKE CONCAT('%', #{query}, '%') OR t.patientId =#{query})
- </if>
- <if test="product != null and product != ''">
- AND (t.genericName LIKE CONCAT('%', #{product}, '%') OR t.productName LIKE CONCAT('%', #{product}, '%') OR t.mdmCode LIKE CONCAT('%', #{product}, '%'))
- </if>
- and t.taskStatus != '未下发'
- <!-- 省略其他字段条件... -->
- </select>
- <!-- 根据ID查询单个任务 -->
- <select id="selectOneById" parameterType="pd" resultType="pd">
- select t.*,
- mr.id as mrId,
- mr.combined_medication_adverse_reaction AS combinedMedicationAdverseReaction,
- mr.combined_medication_other_adverse_reactions AS combinedMedicationOtherAdverseReactions,
- mr.combined_medication_other_adverse_reactions_image AS combinedMedicationOtherAdverseReactionsImage,
- mr.combined_medication_other_adverse_reactions_handling AS combinedMedicationOtherAdverseReactionsHandling,
- mr.is_review AS isReview,
- mr.imaging_insurance_type AS imagingInsuranceType,
- mr.ct_check AS ctCheck,
- mr.ct_text AS ctText,
- mr.ultrasound_check AS ultrasoundCheck,
- mr.ultrasound_text AS ultrasoundText,
- mr.mri_check AS mriCheck,
- mr.mri_text AS mriText,
- mr.other_imaging_examinations AS otherImagingExaminations,
- mr.imaging_examinations_image AS imagingExaminationsImage,
- mr.tumor_marker_check AS tumorMarkerCheck,
- mr.cea AS cea,
- mr.afp AS afp,
- mr.ca_199 AS ca199,
- mr.ca125 AS ca125,
- mr.ca153 AS ca153,
- mr.hcg AS hcg,
- mr.nse AS nse,
- mr.cyfra21_1 AS cyfra211,
- mr.tg AS tg,
- mr.psa AS psa,
- mr.tumor_marker_image AS tumorMarkerImage,
- mr.lab_test_indicators AS labTestIndicators,
- mr.lab_test_indicators_image AS labTestIndicatorsImage,
- mr.treatment_type AS treatmentType,
- mr.pre_medication_plan AS preMedicationPlan,
- mr.current_treatment_plan AS currentTreatmentPlan,
- mr.post_progression_treatment_plan AS postProgressionTreatmentPlan,
- mr.has_medication_indications AS hasMedicationIndications,
- mr.drug_effectiveness AS drugEffectiveness,
- mr.clinical_interaction AS clinicalInteraction,
- mr.clinical_interaction_description AS clinicalInteractionDescription,
- mr.unnecessary_repeated_medication AS unnecessaryRepeatedMedication,
- mr.repeated_medication_first_use_date AS repeatedMedicationFirstUseDate,
- mr.unnecessary_repeated_medication_description AS unnecessaryRepeatedMedicationDescription,
- mr.medication_error AS medicationError,
- mr.medication_error_time AS medicationErrorTime,
- mr.medication_error_description AS medicationErrorDescription,
- mr.medication_record AS medicationRecord,
- mr.combined_medication_record AS combinedMedicationRecord,
- mr.pain_nrs_score AS painNrsScore,
- mr.physical_condition_score AS physicalConditionScore,
- mr.is_consultation AS isConsultation,
- mr.consultation_type AS consultationType,
- mr.specific_question AS specificQuestion,
- mr.pharmacist_response AS pharmacistResponse,
- mr.patient_condition_assessment AS patientConditionAssessment,
- mr.project_description AS projectDescription,
- p.name,
- p.dateBirth,
- p.age,
- p.gender,
- p.realNameStatus,
- p.id as patientId,
- p.phoneNumber,
- p.address,p.idCardImg,
- p.documentNumber,
- p.documentType,
- p.contactPhone,
- p.contactName,
- p.addr,
- p.dl,
- n.useForm ,
- n.templateId ,
- n.followUpSubject,
- n.taskMaterial,
- n.taskValidity,
- DATE_FORMAT(t.appointmentDate, '%Y-%m-%d %H:%i:%s') AS appointmentDate1,
- DATE_FORMAT(t.next_follow_time, '%Y-%m-%d %H:%i:%s') AS next_follow_time2,
- DATE_FORMAT(t.timeFirstDiagnosis, '%Y-%m-%d') AS timeFirstDiagnosis2,
- DATE_FORMAT(p.timeFirstDiagnosis, '%Y-%m-%d %H:%i:%s') AS FirstDiagnosis
- from s_gxhpz_follow_task t
- left join s_gxhpz_follow_up_records mr on t.id = mr.taskId
- left join s_dtp_ysfw_archive_management p on t.patientId = p.id
- left join s_gxhpz_follow_task_node n on t.taskId = n.taskId
- where t.id = #{id}
- </select>
- <!-- 根据ID查询单个任务 -->
- <select id="selectOneBytt" parameterType="pd" resultType="pd">
- select * from s_gxhpz_follow_task_node where taskId = #{taskId} and templateId= #{templateId}
- </select>
- <!-- 停止任务 -->
- <update id="stopFollowTask" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus != null">
- taskStatus = #{taskStatus},
- </if>
- <if test="updatedAt != null and updatedAt != ''">
- updatedAt = #{updatedAt},
- </if>
- <if test="operator != null and operator != ''">
- operator = #{operator},
- </if>
- </set>
- where planId = #{planId}
- </update>
- <!-- 关闭任务 -->
- <update id="closeTask" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus != null">
- taskStatus = #{taskStatus},
- </if>
- <if test="updatedAt != null and updatedAt != ''">
- updatedAt = #{updatedAt},
- </if>
- <if test="operator != null and operator != ''">
- operator = #{operator},
- </if>
- </set>
- where id = #{id}
- </update>
- <!-- 插入新任务 -->
- <insert id="insertFollowTask" parameterType="pd">
- insert into s_gxhpz_follow_task
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="templeName != null and templeName != ''">
- templeName,
- </if>
- <if test="appointmentDate != null">
- appointmentDate,
- </if>
- <if test="businessBelonging != null and businessBelonging != ''">
- businessBelonging,
- </if>
- <if test="taskName != null and taskName != ''">
- taskName,
- </if>
- <if test="taskTheme != null and taskTheme != ''">
- taskTheme,
- </if>
- <if test="planId != null and planId != ''">
- planId,
- </if>
- <if test="taskId != null and taskId != ''">
- taskId,
- </if>
- <if test="patientId != null and patientId != ''">
- patientId,
- </if>
- <if test="patientName != null and patientName != ''">
- patientName,
- </if>
- <if test="gender != null">
- gender,
- </if>
- <if test="age != null">
- age,
- </if>
- <!-- 省略其他字段... -->
- <!-- 新增字段 -->
- <if test="followUpSummary != null and followUpSummary != ''">
- followUpSummary,
- </if>
- <if test="followUpSummaryid != null and followUpSummaryid != ''">
- followUpSummaryid,
- </if>
- <if test="disease != null and disease != ''">
- disease,
- </if>
- <if test="storeName != null and storeName != ''">
- storeName,
- </if>
- <if test="storeId != null">
- storeId,
- </if>
- <if test="drugsLinkId != null and drugsLinkId != ''">
- drugsLinkId,
- </if>
- <if test="nodeId != null and nodeId != ''">
- nodeId,
- </if>
- <if test="genericName != null and genericName != ''">
- genericName,
- </if>
- <if test="productName != null and productName != ''">
- productName,
- </if>
- <if test="mdmCode != null and mdmCode != ''">
- mdmCode,
- </if>
- <if test="taskFollower != null and taskFollower != ''">
- taskFollower,
- </if>
- <if test="returnMethod != null and returnMethod != ''">
- returnMethod,
- </if>
- <if test="iscoordinate != null and iscoordinate != ''">
- iscoordinate,
- </if>
- <if test="reasons_uncooperative != null and reasons_uncooperative != ''">
- reasons_uncooperative,
- </if>
- <if test="InterviewRecord != null and InterviewRecord != ''">
- InterviewRecord,
- </if>
- <if test="timeFirstDiagnosis != null and timeFirstDiagnosis != ''">
- timeFirstDiagnosis,
- </if>
- <if test="permanentStopTime != null">
- permanentStopTime,
- </if>
- <if test="returnObject != null and returnObject != ''">
- returnObject,
- </if>
- <if test="returnImgUrl != null and returnImgUrl != ''">
- returnImgUrl,
- </if>
- <if test="medicationStatus != null and medicationStatus != ''">
- medicationStatus,
- </if>
- <if test="stoped != null">
- stoped,
- </if>
- <if test="charitable != null and charitable != ''">
- charitable,
- </if>
- <if test="perpetual_stopdrug_cause != null and perpetual_stopdrug_cause != ''">
- perpetual_stopdrug_cause,
- </if>
- <if test="planningStrategy != null and planningStrategy != ''">
- planningStrategy,
- </if>
- <if test="other_channels != null and other_channels != ''">
- other_channels,
- </if>
- <if test="delay_purchase_doctor != null and delay_purchase_doctor != ''">
- delay_purchase_doctor,
- </if>
- <if test="delayed_purchase_drugs != null and delayed_purchase_drugs != ''">
- delayed_purchase_drugs,
- </if>
- <if test="is_adverse_reaction != null and is_adverse_reaction != ''">
- is_adverse_reaction,
- </if>
- <if test="adverse_reaction_time != null">
- adverse_reaction_time,
- </if>
- <if test="good_response_symptom_id != null and good_response_symptom_id != ''">
- good_response_symptom_id,
- </if>
- <if test="tar != null and tar != ''">
- tar,
- </if>
- <if test="nutrition_evaluation_id != null and nutrition_evaluation_id != ''">
- nutrition_evaluation_id,
- </if>
- <if test="medication_record_id != null and medication_record_id != ''">
- medication_record_id,
- </if>
- <if test="other != null and other != ''">
- other,
- </if>
- <if test="actualFollowUpTime != null">
- actualFollowUpTime,
- </if>
- <if test="callConnectedCount != null">
- callConnectedCount,
- </if>
- <if test="nextCallTime != null">
- nextCallTime,
- </if>
- <if test="lastOutboundFlag != null and lastOutboundFlag != ''">
- lastOutboundFlag,
- </if>
- <if test="outboundCallCount != null">
- outboundCallCount,
- </if>
- <if test="nextOutboundCallCount != null">
- nextOutboundCallCount,
- </if>
- <if test="taskStatus != null and taskStatus != ''">
- taskStatus,
- </if>
- <if test="completionTime != null">
- completionTime,
- </if>
- <if test="lastOutboundStatus != null and lastOutboundStatus != ''">
- lastOutboundStatus,
- </if>
- <if test="operator != null and operator != ''">
- operator,
- </if>
- <if test="interval_this_time != null">
- interval_this_time,
- </if>
- <if test="next_taskTheme != null and next_taskTheme != ''">
- next_taskTheme,
- </if>
- <if test="next_follow_time != null">
- next_follow_time,
- </if>
- <if test="createdAt != null">
- createdAt,
- </if>
- </trim>
- values
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <!-- 基础字段 -->
- <if test="templeName != null and templeName != ''">
- #{templeName},
- </if>
- <if test="appointmentDate != null">
- #{appointmentDate},
- </if>
- <if test="businessBelonging != null and businessBelonging != ''">
- #{businessBelonging},
- </if>
- <if test="taskName != null and taskName != ''">
- #{taskName},
- </if>
- <if test="taskTheme != null and taskTheme != ''">
- #{taskTheme},
- </if>
- <if test="planId != null and planId != ''">
- #{planId},
- </if>
- <if test="taskId != null and taskId != ''">
- #{taskId},
- </if>
- <if test="patientId != null and patientId != ''">
- #{patientId},
- </if>
- <if test="patientName != null and patientName != ''">
- #{patientName},
- </if>
- <if test="gender != null">
- #{gender},
- </if>
- <if test="age != null">
- #{age},
- </if>
- <!-- 新增字段 -->
- <if test="followUpSummary != null and followUpSummary != ''">
- #{followUpSummary},
- </if>
- <if test="followUpSummaryid != null and followUpSummaryid != ''">
- #{followUpSummaryid},
- </if>
- <if test="disease != null and disease != ''">
- #{disease},
- </if>
- <if test="storeName != null and storeName != ''">
- #{storeName},
- </if>
- <if test="storeId != null">
- #{storeId},
- </if>
- <if test="drugsLinkId != null and drugsLinkId != ''">
- #{drugsLinkId},
- </if>
- <if test="nodeId != null and nodeId != ''">
- #{nodeId},
- </if>
- <if test="genericName != null and genericName != ''">
- #{genericName},
- </if>
- <if test="productName != null and productName != ''">
- #{productName},
- </if>
- <if test="mdmCode != null and mdmCode != ''">
- #{mdmCode},
- </if>
- <if test="taskFollower != null and taskFollower != ''">
- #{taskFollower},
- </if>
- <if test="returnMethod != null and returnMethod != ''">
- #{returnMethod},
- </if>
- <if test="iscoordinate != null and iscoordinate != ''">
- #{iscoordinate},
- </if>
- <if test="reasons_uncooperative != null and reasons_uncooperative != ''">
- #{reasons_uncooperative},
- </if>
- <if test="InterviewRecord != null and InterviewRecord != ''">
- #{InterviewRecord},
- </if>
- <if test="timeFirstDiagnosis != null and timeFirstDiagnosis != ''">
- #{timeFirstDiagnosis},
- </if>
- <if test="permanentStopTime != null">
- #{permanentStopTime},
- </if>
- <if test="returnObject != null and returnObject != ''">
- #{returnObject},
- </if>
- <if test="returnImgUrl != null and returnImgUrl != ''">
- #{returnImgUrl},
- </if>
- <if test="medicationStatus != null and medicationStatus != ''">
- #{medicationStatus},
- </if>
- <if test="stoped != null">
- #{stoped},
- </if>
- <if test="charitable != null and charitable != ''">
- #{charitable},
- </if>
- <if test="perpetual_stopdrug_cause != null and perpetual_stopdrug_cause != ''">
- #{perpetual_stopdrug_cause},
- </if>
- <if test="planningStrategy != null and planningStrategy != ''">
- #{planningStrategy},
- </if>
- <if test="other_channels != null and other_channels != ''">
- #{other_channels},
- </if>
- <if test="delay_purchase_doctor != null and delay_purchase_doctor != ''">
- #{delay_purchase_doctor},
- </if>
- <if test="delayed_purchase_drugs != null and delayed_purchase_drugs != ''">
- #{delayed_purchase_drugs},
- </if>
- <if test="is_adverse_reaction != null and is_adverse_reaction != ''">
- #{is_adverse_reaction},
- </if>
- <if test="adverse_reaction_time != null">
- #{adverse_reaction_time},
- </if>
- <if test="good_response_symptom_id != null and good_response_symptom_id != ''">
- #{good_response_symptom_id},
- </if>
- <if test="tar != null and tar != ''">
- #{tar},
- </if>
- <if test="nutrition_evaluation_id != null and nutrition_evaluation_id != ''">
- #{nutrition_evaluation_id},
- </if>
- <if test="medication_record_id != null and medication_record_id != ''">
- #{medication_record_id},
- </if>
- <if test="other != null and other != ''">
- #{other},
- </if>
- <if test="actualFollowUpTime != null">
- #{actualFollowUpTime},
- </if>
- <if test="callConnectedCount != null">
- #{callConnectedCount},
- </if>
- <if test="nextCallTime != null">
- #{nextCallTime},
- </if>
- <if test="lastOutboundFlag != null and lastOutboundFlag != ''">
- #{lastOutboundFlag},
- </if>
- <if test="outboundCallCount != null">
- #{outboundCallCount},
- </if>
- <if test="nextOutboundCallCount != null">
- #{nextOutboundCallCount},
- </if>
- <if test="taskStatus != null and taskStatus != ''">
- #{taskStatus},
- </if>
- <if test="completionTime != null">
- #{completionTime},
- </if>
- <if test="lastOutboundStatus != null and lastOutboundStatus != ''">
- #{lastOutboundStatus},
- </if>
- <if test="operator != null and operator != ''">
- #{operator},
- </if>
- <if test="interval_this_time != null">
- #{interval_this_time},
- </if>
- <if test="next_taskTheme != null and next_taskTheme != ''">
- #{next_taskTheme},
- </if>
- <if test="next_follow_time != null">
- #{next_follow_time},
- </if>
- <if test="createdAt != null">
- #{createdAt},
- </if>
- </trim>
- </insert>
- <!-- 更新任务 -->
- <update id="updateFollowTask" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="templeName != null and templeName != ''">
- templeName = #{templeName},
- </if>
- <if test="appointmentDate != null">
- appointmentDate = #{appointmentDate},
- </if>
- <if test="businessBelonging != null and businessBelonging != ''">
- businessBelonging = #{businessBelonging},
- </if>
- <if test="taskName != null and taskName != ''">
- taskName = #{taskName},
- </if>
- <if test="taskTheme != null and taskTheme != ''">
- taskTheme = #{taskTheme},
- </if>
- <if test="planId != null and planId != ''">
- planId = #{planId},
- </if>
- <if test="taskId != null and taskId != ''">
- taskId = #{taskId},
- </if>
- <if test="nodeId != null and nodeId != ''">
- nodeId = #{nodeId},
- </if>
- <if test="patientId != null and patientId != ''">
- patientId = #{patientId},
- </if>
- <if test="patientName != null and patientName != ''">
- patientName = #{patientName},
- </if>
- <if test="gender != null">
- gender = #{gender},
- </if>
- <if test="age != null">
- age = #{age},
- </if>
- <!-- 省略其他字段... -->
- <!-- 新增字段 -->
- <if test="followUpSummary != null and followUpSummary != ''">
- followUpSummary = #{followUpSummary},
- </if>
- <if test="followUpSummaryid != null and followUpSummaryid != ''">
- followUpSummaryid = #{followUpSummaryid},
- </if>
- <if test="disease != null and disease != ''">
- disease = #{disease},
- </if>
- <if test="storeName != null and storeName != ''">
- storeName = #{storeName},
- </if>
- <if test="storeId != null">
- storeId = #{storeId},
- </if>
- <if test="drugsLinkId != null and drugsLinkId != ''">
- drugsLinkId = #{drugsLinkId},
- </if>
- <if test="genericName != null and genericName != ''">
- genericName = #{genericName},
- </if>
- <if test="productName != null and productName != ''">
- productName = #{productName},
- </if>
- <if test="mdmCode != null and mdmCode != ''">
- mdmCode = #{mdmCode},
- </if>
- <if test="taskFollower != null and taskFollower != ''">
- taskFollower = #{taskFollower},
- </if>
- <if test="returnMethod != null and returnMethod != ''">
- returnMethod = #{returnMethod},
- </if>
- <if test="iscoordinate != null and iscoordinate != ''">
- iscoordinate = #{iscoordinate},
- </if>
- <if test="reasons_uncooperative != null and reasons_uncooperative != ''">
- reasons_uncooperative = #{reasons_uncooperative},
- </if>
- <if test="InterviewRecord != null and InterviewRecord != ''">
- InterviewRecord = #{InterviewRecord},
- </if>
- <if test="timeFirstDiagnosis != null and timeFirstDiagnosis != ''">
- timeFirstDiagnosis = #{timeFirstDiagnosis},
- </if>
- <if test="permanentStopTime != null and permanentStopTime != ''">
- permanentStopTime = #{permanentStopTime},
- </if>
- <if test="returnObject != null and returnObject != ''">
- returnObject = #{returnObject},
- </if>
- <if test="returnImgUrl != null and returnImgUrl != ''">
- returnImgUrl = #{returnImgUrl},
- </if>
- <if test="medicationStatus != null and medicationStatus != ''">
- medicationStatus = #{medicationStatus},
- </if>
- <if test="stoped != null">
- stoped = #{stoped},
- </if>
- <if test="charitable != null and charitable != ''">
- charitable = #{charitable},
- </if>
- <if test="perpetual_stopdrug_cause != null and perpetual_stopdrug_cause != ''">
- perpetual_stopdrug_cause = #{perpetual_stopdrug_cause},
- </if>
- <if test="planningStrategy != null and planningStrategy != ''">
- planningStrategy = #{planningStrategy},
- </if>
- <if test="other_channels != null and other_channels != ''">
- other_channels = #{other_channels},
- </if>
- <if test="delay_purchase_doctor != null and delay_purchase_doctor != ''">
- delay_purchase_doctor = #{delay_purchase_doctor},
- </if>
- <if test="delayed_purchase_drugs != null and delayed_purchase_drugs != ''">
- delayed_purchase_drugs = #{delayed_purchase_drugs},
- </if>
- <if test="is_adverse_reaction != null and is_adverse_reaction != ''">
- is_adverse_reaction = #{is_adverse_reaction},
- </if>
- <if test="adverse_reaction_time != null and adverse_reaction_time != ''">
- adverse_reaction_time = #{adverse_reaction_time},
- </if>
- <if test="good_response_symptom_id != null and good_response_symptom_id != ''">
- good_response_symptom_id = #{good_response_symptom_id},
- </if>
- <if test="tar != null and tar != ''">
- tar = #{tar},
- </if>
- <if test="nutrition_evaluation_id != null and nutrition_evaluation_id != ''">
- nutrition_evaluation_id = #{nutrition_evaluation_id},
- </if>
- <if test="medication_record_id != null and medication_record_id != ''">
- medication_record_id = #{medication_record_id},
- </if>
- <if test="other != null and other != ''">
- other = #{other},
- </if>
- <if test="actualFollowUpTime != null">
- actualFollowUpTime = #{actualFollowUpTime},
- </if>
- <if test="interval_this_time != null and interval_this_time != ''">
- interval_this_time = #{interval_this_time},
- </if>
- <if test="next_taskTheme != null and next_taskTheme != ''">
- next_taskTheme = #{next_taskTheme},
- </if>
- <if test="next_follow_time != null and next_follow_time != ''">
- next_follow_time = #{next_follow_time},
- </if>
- <if test="callConnectedCount != null">
- callConnectedCount = #{callConnectedCount},
- </if>
- <if test="nextCallTime != null">
- nextCallTime = #{nextCallTime},
- </if>
- <if test="lastOutboundFlag != null and lastOutboundFlag != ''">
- lastOutboundFlag = #{lastOutboundFlag},
- </if>
- <if test="outboundCallCount != null">
- outboundCallCount = #{outboundCallCount},
- </if>
- <if test="nextOutboundCallCount != null">
- nextOutboundCallCount = #{nextOutboundCallCount},
- </if>
- <if test="taskStatus != null and taskStatus != ''">
- taskStatus = #{taskStatus},
- </if>
- <if test="completionTime != null">
- completionTime = #{completionTime},
- </if>
- <if test="lastOutboundStatus != null and lastOutboundStatus != ''">
- lastOutboundStatus = #{lastOutboundStatus},
- </if>
- <if test="updatedAt != null">
- updatedAt = #{updatedAt},
- </if>
- <if test="operator != null and operator != ''">
- operator= #{operator},
- </if>
- </set>
- where id = #{id}
- </update>
- <!-- 更新任务 -->
- <update id="updateFollowTaskAppointmentDateByTaskId" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="appointmentDate != null">
- appointmentDate = #{appointmentDate},
- </if>
- </set>
- where taskId = #{taskId}
- </update>
- <!-- 修改处方状态 -->
- <update id="updateCFBStatus" parameterType="pd">
- update s_dtp_prescription_registration
- <set>
- <if test="status != null">
- status = #{status},
- </if>
- </set>
- where drugsLinkId = #{drugsLinkId}
- </update>
- <!-- 删除任务 -->
- <delete id="deleteFollowTasksByIds" parameterType="java.util.List">
- <if test="list != null and list.size() > 0">
- delete from s_gxhpz_follow_task
- where id in
- <foreach item="id" index="index" collection="list" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </delete>
- <!-- 更据drugsLinkId删除任务 -->
- <delete id="deleteTaskByDrugsLinkId" parameterType="pd">
- delete from s_gxhpz_follow_task where drugsLinkId =#{drugsLinkId}
- </delete>
- <!-- 更据计划planId 任务taskId 删除job任务 -->
- <delete id="deleteSysJobByPlanId" parameterType="pd">
- delete from sys_job where plan_id =#{plan_id}
- </delete>
- <!--查询定时任务-->
- <select id="getJobByTaskId" parameterType="pd" resultType="pd">
- select * from sys_job where task_id = #{taskId} and actions = #{actions} ORDER BY create_time DESC
- LIMIT 1;
- </select>
- <!--查询定时任务-->
- <select id="getJobByCreateId" parameterType="pd" resultType="pd">
- select * from sys_job where create_id = #{createId}
- </select>
- <!--查询模版节点配置的任务的有效期天数-->
- <select id="getNodeConfigByNodeId" parameterType="pd" resultType="pd">
- select * from s_dtp_yypz_nodeconfig where id = #{nodeId}
- </select>
- <!--根据患者id和药查询计划-->
- <select id="getPlanByMdmCode" parameterType="pd" resultType="pd">
- select * from s_gxhpz_follow_plan where mdmCode = #{mdmCode} and storeId = #{storeId} and patientId= #{patientId}
- </select>
- <!--根据计划id查询下面的所有任务-->
- <select id="getTaskByPlanId" parameterType="pd" resultType="pd">
- select * from s_gxhpz_follow_task where planId = #{planId} and storeId = #{storeId} and patientId= #{patientId}
- </select>
- <!--关闭任务-->
- <update id="updateJobByTaskId" parameterType="SysJob">
- update sys_job
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="remark != null and remark != ''">remark = #{remark},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate(),
- </set>
- where task_id = #{taskId} and actions = #{actions}
- </update>
- <!--关闭患者当前所有计划-->
- <update id="closePatientCurrentPlan" parameterType="SysJob">
- update s_gxhpz_follow_plan
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="updateBy != null and updateBy != ''">updatedBy = #{updateBy},</if>
- updatedTime = sysdate(),
- </set>
- where patientId= #{patientId} and storeId= #{storeId}
- </update>
- <!--关闭患者当前所有计划-->
- <update id="closePatientCurrentTask" parameterType="SysJob">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus !=null">taskStatus = #{taskStatus},</if>
- <if test="operator != null and operator != ''">operator = #{operator},</if>
- updatedAt = sysdate(),
- </set>
- where patientId= #{patientId} and storeId= #{storeId}
- </update>
- <!--关闭计划更据类型z-->
- <update id="closeByPlanTypePlan" parameterType="SysJob">
- update s_gxhpz_follow_plan
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="updateBy != null and updateBy != ''">updatedBy = #{updateBy},</if>
- updatedTime = sysdate(),
- </set>
- where patientId= #{patientId} and businessBelonging= #{businessBelonging} and storeId= #{storeId}
- </update>
- <!--关闭任务根类型z-->
- <update id="closeTaskByTypePlan" parameterType="SysJob">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus !=null">taskStatus = #{taskStatus},</if>
- <if test="operator != null and operator != ''">operator = #{operator},</if>
- updatedAt = sysdate(),
- </set>
- where patientId= #{patientId} and businessBelonging= #{businessBelonging} and storeId= #{storeId}
- </update>
- <!--关闭计划根据药z-->
- <update id="closePLanCurrentDrugsPlan" parameterType="SysJob">
- update s_gxhpz_follow_plan
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="updateBy != null and updateBy != ''">updatedBy = #{updateBy},</if>
- updatedTime = sysdate(),
- </set>
- where mdmCode = #{mdmCode} and patientId= #{patientId} and storeId= #{storeId}
- </update>
- <!--关闭任务根据药z-->
- <update id="closeTaskCurrentDrugsPlan" parameterType="SysJob">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus !=null">taskStatus = #{taskStatus},</if>
- <if test="operator != null and operator != ''">operator = #{operator},</if>
- updatedAt = sysdate(),
- </set>
- where mdmCode = #{mdmCode} and patientId= #{patientId} and storeId= #{storeId}
- </update>
- <!--关闭定时任务表的计划根据指定药查询出来的计划z-->
- <update id="updateJobByDrugsClosePlanId" parameterType="SysJob">
- update sys_job
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="remark != null and remark != ''">remark = #{remark},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate(),
- </set>
- where plan_id = #{planId}
- </update>
- <!--关闭定时任务计划-->
- <update id="updateJobByPlanId" parameterType="SysJob">
- update sys_job
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="remark != null and remark != ''">remark = #{remark},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate(),
- </set>
- where plan_id = #{planId}
- </update>
- <!--关闭定时任务计划-->
- <update id="updateJobByRestartPlan" parameterType="SysJob">
- update sys_job
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="remark != null and remark != ''">remark = #{remark},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate(),
- </set>
- where plan_id = #{planId} and actions = #{actions} and store_id = #{storeId}
- </update>
- <!--关闭该患者的所有定时任务-->
- <update id="updateJobByPatientId" parameterType="SysJob">
- update sys_job
- <set>
- <if test="status !=null">status = #{status},</if>
- <if test="remark != null and remark != ''">remark = #{remark},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate(),
- </set>
- where store_id = #{storeId} and patient_id = #{patientId}
- </update>
- <!-- 关闭该患者的所有计划 -->
- <update id="closeFollowPlanByPatientId" parameterType="pd">
- update s_gxhpz_follow_plan
- <set>
- <if test="status != null">
- status = #{status},
- </if>
- <if test="updatedBy != null and updatedBy != ''">
- updatedBy = #{updatedBy},
- </if>
- <if test="updatedTime != null and updatedTime != ''">
- updatedTime = #{updatedTime},
- </if>
- </set>
- where storeId = #{storeId} and patientId = #{patientId}
- </update>
- <!-- 关闭该患者的所有任务 -->
- <update id="stopFollowTaskByPatientId" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus != null">
- taskStatus = #{taskStatus},
- </if>
- <if test="updatedAt != null and updatedAt != ''">
- updatedAt = #{updatedAt},
- </if>
- <if test="operator != null and operator != ''">
- operator = #{operator},
- </if>
- </set>
- where storeId = #{storeId} and patientId = #{patientId}
- </update>
- <!-- 关闭任务taskid -->
- <update id="closeTaskByTaskId" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus != null">
- taskStatus = #{taskStatus},
- </if>
- <if test="updatedAt != null and updatedAt != ''">
- updatedAt = #{updatedAt},
- </if>
- <if test="operator != null and operator != ''">
- operator = #{operator},
- </if>
- </set>
- where storeId = #{storeId} and patientId = #{patientId} and taskId=#{taskId}
- </update>
- <!-- 开启生成的任务 -->
- <update id="openTaskByTaskId" parameterType="pd">
- update s_gxhpz_follow_task
- <set>
- <if test="taskStatus != null">
- taskStatus = #{taskStatus},
- </if>
- <if test="updatedAt != null and updatedAt != ''">
- updatedAt = #{updatedAt},
- </if>
- <if test="operator != null and operator != ''">
- operator = #{operator},
- </if>
- <if test="appointmentDate != null and appointmentDate != ''">
- appointmentDate = #{appointmentDate},
- </if>
- </set>
- where storeId = #{storeId} and patientId = #{patientId} and taskId=#{taskId}
- </update>
- <!-- 激活创建的计划 -->
- <update id="openPlanByPlanId" parameterType="pd">
- update s_gxhpz_follow_plan
- <set>
- <if test="status != null">
- status = #{status},
- </if>
- <if test="updatedTime != null and updatedTime != ''">
- updatedTime = #{updatedTime},
- </if>
- <if test="updatedBy != null and updatedBy != ''">
- updatedBy = #{updatedBy},
- </if>
- </set>
- where storeId = #{storeId} and patientId = #{patientId} and planId=#{planId}
- </update>
- <!-- 更新job表的任务执行次数和更换taskID -->
- <update id="updateJobStatusByTaskId" parameterType="pd">
- update sys_job
- <set>
- <if test="status != null">
- status = #{status},
- </if>
- <if test="taskId != null and taskId != ''">
- task_id = #{taskId},
- </if>
- <if test="currentExecutionCount != null">
- currentExecutionCount = #{currentExecutionCount},
- </if>
- <if test="remainingExecutions != null">
- remainingExecutions = #{remainingExecutions},
- </if>
- <if test="updateTime != null and updateTime != ''">
- update_time = #{updateTime},
- </if>
- <if test="remark != null and remark != ''">
- remark = #{remark},
- </if>
- <if test="updateBy != null and updateBy != ''">
- update_by = #{updateBy},
- </if>
- </set>
- where store_id = #{storeId} and patient_id = #{patientId} create_id=#{createId}
- </update>
- <!-- 查询任务 -->
- <select id="findTaskFollowerList" parameterType="pd" resultType="pd">
- SELECT * FROM
- s_dtp_review_pharmacists where 1 = 1
- <if test="position != null and position != ''">
- and position = #{position}
- </if>
- <if test="storeId != null and storeId != '' ">
- and storeId in (
- WITH RECURSIVE subordinates AS (
- SELECT dept_id
- FROM sys_dept
- WHERE parent_id = #{storeId} or dept_id = #{storeId}
- UNION ALL
- SELECT sd.dept_id
- FROM sys_dept sd
- INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
- )
- SELECT DISTINCT dept_id
- FROM subordinates
- UNION
- SELECT #{storeId} AS dept_id
- )
- </if>
- <if test="status != null and status != ''">
- and status = #{status}
- </if>
- </select>
- <select id="findTaskStoreList" parameterType="pd" resultType="pd">
- SELECT dept_id AS id, dept_name FROM sys_dept
- WHERE del_flag = '0'
- <if test="storeId != null and storeId != ''">
- AND (
- dept_id = #{storeId}
- OR FIND_IN_SET(#{storeId}, ancestors) > 0
- )
- </if>
- <if test="status != null and status != ''">
- AND status = #{status}
- </if>
- </select>
- <!-- 最近已完成随访距今天数 -->
- <select id="selectRecentlyCompletedFollowUpDays" parameterType="pd" resultType="int">
- SELECT DATEDIFF(CURDATE(), completionTime) AS days
- FROM s_gxhpz_follow_task
- WHERE taskStatus = '已完成' <!-- 完成状态 -->
- AND patientId = #{patientId}
- ORDER BY completionTime DESC
- LIMIT 1;
- </select>
- <!-- 最近待执行随访距今天数 -->
- <select id="selectRecentlyPendingFollowUpDays" parameterType="pd" resultType="int">
- SELECT DATEDIFF(CURDATE(), appointmentDate) AS days
- FROM s_gxhpz_follow_task
- WHERE taskStatus IN ('待执行', '未下发') <!-- 待执行或未下发状态 -->
- AND patientId = #{patientId}
- ORDER BY appointmentDate ASC
- LIMIT 1;
- </select>
- <!-- 最近订单距今天数 -->
- <select id="selectRecentlyOrderDays" parameterType="pd" resultType="int">
- SELECT DATEDIFF(CURDATE(), registrationDate) AS days
- FROM s_dtp_prescription_registration
- WHERE status = 1 <!-- 订单完成状态 -->
- AND patientId = #{patientId}
- ORDER BY registrationDate DESC
- LIMIT 1;
- </select>
- <!-- 触达手机号 -->
- <select id="getPhoneNumberByPatientId" parameterType="pd" resultType="pd">
- SELECT * FROM s_dtp_ysfw_archive_management WHERE id = #{patientId}
- </select>
- <!-- 用药状态 -->
- <select id="getMedicationStatus" parameterType="pd" resultType="pd">
- SELECT * FROM s_gxhpz_follow_task
- WHERE 1 = 1 <!-- 订单完成状态 -->
- AND patientId = #{patientId}
- AND taskId = #{taskId}
- </select>
- <!-- 业务归属 -->
- <select id="getMedicationBusinessBelonging" parameterType="pd" resultType="pd">
- SELECT * FROM s_gxhpz_follow_task WHERE 1 = 1
- <if test="businessBelong !=null and businessBelong != ''">
- AND businessBelonging = #{businessBelonging}
- </if>
- <if test="medicationStatus !=null and medicationStatus != ''">
- AND medicationStatus = #{medicationStatus}
- </if>
- <if test="stoped !=null and stoped != ''">
- AND stoped = #{stoped}
- </if>
- AND patientId = #{patientId}
- AND taskId = #{taskId}
- </select>
- <!-- 查询任务数第几次任务 -->
- <select id="getCountTask" parameterType="pd" resultType="int">
- SELECT count(1) FROM s_gxhpz_follow_task WHERE 1 = 1
- <if test="businessBelong !=null and businessBelong != ''">
- AND businessBelonging = #{businessBelonging}
- </if>
- <if test="taskStatus !=null and taskStatus != ''">
- AND taskStatus = #{taskStatus}
- </if>
- AND patientId = #{patientId}
- AND storeId = #{storeId}
- </select>
- <!-- 查询自由模版 -->
- <select id="createPlanToGetTemplate" parameterType="pd" resultType="pd">
- 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
- <if test="query !=null and query != ''">
- AND (t.templateName LIKE CONCAT('%', #{query}, '%') OR t.templateId =#{query})
- </if>
- <if test="model !=null and model != ''">
- AND d.activateNodeRule = #{model}
- </if>
- <if test="drug !=null and drug != ''">
- AND t.drug is not null
- </if>
- <if test="drug_yes !=null and drug_yes != ''">
- AND t.drug is null
- </if>
- <if test="status !=null">
- AND t.status = #{status}
- </if>
- AND t.storeId in (
- WITH RECURSIVE subordinates AS (
- SELECT dept_id
- FROM sys_dept
- WHERE parent_id = #{storeId} or dept_id = #{storeId}
- UNION ALL
- SELECT sd.dept_id
- FROM sys_dept sd
- INNER JOIN subordinates ss ON sd.parent_id = ss.dept_id
- )
- SELECT DISTINCT dept_id
- FROM subordinates
- UNION
- SELECT #{storeId} AS dept_id
- )
- </select>
- <select id="getSendInfoByPM" parameterType="pd" resultType="pd">
- SELECT
- temp.*
- FROM (
- SELECT
- s.dept_name,
- p.name,
- p.phoneNumber,
- p.id AS patientId,
- d.mdmCode,
- d.storeId,
- d.productName,
- d.sum_total - DATEDIFF(CURRENT_DATE(), d.sum_total_update_time) AS adjusted_sum_total,
- ROW_NUMBER() OVER (PARTITION BY p.id ORDER BY d.sum_total_update_time DESC) AS rn
- FROM s_dtp_ysfw_archive_management p
- LEFT JOIN sys_dept s ON p.storeId = s.dept_id
- LEFT JOIN s_gxhpz_patient_d_value d ON p.id = d.patientId
- WHERE 1 = 1
- <if test="patientId != null and patientId != ''">
- AND p.id = #{patientId}
- </if>
- <if test="mdmCode != null and mdmCode != ''">
- AND d.mdmCode = #{mdmCode}
- </if>
- ) temp
- WHERE temp.rn = 1
- </select>
- <!--查询模版节点配置的任务的有效期天数-->
- <select id="getTaskByTaskId" parameterType="pd" resultType="pd">
- select * from s_gxhpz_follow_task where taskId = #{taskId}
- </select>
- </mapper>
|