Advertisement
temaon_lieto

#H24-20108 sql with params

May 13th, 2024 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- DiagnosticRelated::ReportActualizeWorker
  2.  
  3. -- Запрос с параматрами
  4. SELECT "receptions"."id", "receptions"."legal_entity_id", "receptions"."performer_id", "receptions"."ehealth_status"
  5. FROM "receptions"
  6.          INNER JOIN "ehealth_async_jobs" ON "ehealth_async_jobs"."jobable_id" = "receptions"."id" AND
  7.                                             "ehealth_async_jobs"."jobable_type" = 'Ehr::Encounter'
  8.          LEFT OUTER JOIN "diagnostic_related_reports"
  9.                          ON "diagnostic_related_reports"."reportable_id" = "receptions"."id" AND
  10.                             "diagnostic_related_reports"."reportable_type" = 'Ehr::Encounter'
  11. WHERE "receptions"."encounter_class_id" != 1293
  12.   AND "receptions"."ehealth_status" = 1
  13.   AND "receptions"."legal_entity_id" IN (3047, 1733, 1453)
  14.   AND "receptions"."signed_at" BETWEEN '2024-05-12 21:00:00' AND '2024-05-13 07:24:20.115435'
  15.   AND "diagnostic_related_reports"."id" IS NULL
  16. ORDER BY "receptions"."id" ASC
  17. LIMIT 100
  18.  
  19.  
  20. -- Остальные запросы с этой джобы
  21. SELECT "ehr_procedures"."id",
  22.        "ehr_procedures"."legal_entity_id",
  23.        "ehr_procedures"."performer_id",
  24.        "ehr_procedures"."ehealth_status"
  25. FROM "ehr_procedures"
  26.          INNER JOIN "ehealth_async_jobs" ON "ehealth_async_jobs"."jobable_id" = "ehr_procedures"."id" AND
  27.                                             "ehealth_async_jobs"."jobable_type" = 'Ehr::Procedure'
  28.          LEFT OUTER JOIN "diagnostic_related_reports"
  29.                          ON "diagnostic_related_reports"."reportable_id" = "ehr_procedures"."id" AND
  30.                             "diagnostic_related_reports"."reportable_type" = 'Ehr::Procedure'
  31. WHERE "ehr_procedures"."encounter_id" IS NULL
  32.   AND "ehr_procedures"."ehealth_status" = 1
  33.   AND "ehr_procedures"."legal_entity_id" IN (3047, 1733, 1453)
  34.   AND "ehr_procedures"."signed_at" BETWEEN '2024-05-12 21:00:00' AND '2024-05-13 07:24:20.166089'
  35.   AND "diagnostic_related_reports"."id" IS NULL
  36. ORDER BY "ehr_procedures"."id" ASC
  37. LIMIT 100
  38.  
  39. SELECT "ehr_diagnostic_reports"."id",
  40.        "ehr_diagnostic_reports"."legal_entity_id",
  41.        "ehr_diagnostic_reports"."performer_id",
  42.        "ehr_diagnostic_reports"."ehealth_status"
  43. FROM "ehr_diagnostic_reports"
  44.          INNER JOIN "ehealth_async_jobs" ON "ehealth_async_jobs"."jobable_id" = "ehr_diagnostic_reports"."id" AND
  45.                                             "ehealth_async_jobs"."jobable_type" = 'Ehr::DiagnosticReport'
  46.          LEFT OUTER JOIN "diagnostic_related_reports"
  47.                          ON "diagnostic_related_reports"."reportable_id" = "ehr_diagnostic_reports"."id" AND
  48.                             "diagnostic_related_reports"."reportable_type" = 'Ehr::DiagnosticReport'
  49. WHERE "ehr_diagnostic_reports"."encounter_id" IS NULL
  50.   AND "ehr_diagnostic_reports"."ehealth_status" = 1
  51.   AND "ehr_diagnostic_reports"."legal_entity_id" IN (3047, 1733, 1453)
  52.   AND "ehr_diagnostic_reports"."signed_at" BETWEEN '2024-05-12 21:00:00' AND '2024-05-13 07:24:20.193687'
  53.   AND "diagnostic_related_reports"."id" IS NULL
  54. ORDER BY "ehr_diagnostic_reports"."id" ASC
  55. LIMIT 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement