Advertisement
temaon_lieto

#H24-20107 sql with params

May 13th, 2024
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- /api/v2/inpatient/hospitalizations/find_by_date
  2.  
  3. -- Запрос с параматрами
  4. SELECT "ehr_hospitalizations".*
  5. FROM "ehr_hospitalizations"
  6.          INNER JOIN "disease_histories" ON "disease_histories"."id" = "ehr_hospitalizations"."episode_of_care_id"
  7.          INNER JOIN "user_patients" ON "user_patients"."id" = "ehr_hospitalizations"."patient_id"
  8. WHERE "disease_histories"."period_start" BETWEEN '2022-10-05 21:00:00' AND '2024-05-13 07:55:26.058000'
  9.   AND "user_patients"."id" = 86
  10.   AND ("ehr_hospitalizations"."state" NOT IN ('hospitalized_refusal', 'discharged') OR
  11.        "ehr_hospitalizations"."state" = 'discharged' AND (discharge_date >= '2024-05-13 07:55:26.058000'))
  12. ORDER BY "period_start" ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement