Skip to content

Instantly share code, notes, and snippets.

@petebrowne
Created January 15, 2014 21:03
Show Gist options
  • Save petebrowne/8444616 to your computer and use it in GitHub Desktop.
Save petebrowne/8444616 to your computer and use it in GitHub Desktop.
Insurance Coverage SQL queries. Third one is broken...
SELECT DISTINCT "insurance_insuranceissuer"."id", "insurance_insuranceissuer"."slug", "insurance_insuranceissuer"."issuer_code", "insurance_insuranceissuer"."legal_name", "insurance_insuranceissuer"."marketing_name", "insurance_insuranceissuer"."company_code", "insurance_insuranceissuer"."group_code", "insurance_insuranceissuer"."state", "insurance_insuranceissuer"."created_at", "insurance_insuranceissuer"."updated_at" FROM "insurance_insuranceissuer" INNER JOIN "insurance_coverage_practiceissuer" ON ( "insurance_insuranceissuer"."id" = "insurance_coverage_practiceissuer"."issuer_id" ) WHERE ("insurance_coverage_practiceissuer"."in_network" = %s AND "insurance_coverage_practiceissuer"."practice_id" = %s ) LIMIT 21' - PARAMS = (True, u'b107925f-aac8-4baa-b304-3ec720ef082d'); args=(True, u'b107925f-aac8-4baa-b304-3ec720ef082d')
SELECT DISTINCT "insurance_insuranceissuer"."id", "insurance_insuranceissuer"."slug", "insurance_insuranceissuer"."issuer_code", "insurance_insuranceissuer"."legal_name", "insurance_insuranceissuer"."marketing_name", "insurance_insuranceissuer"."company_code", "insurance_insuranceissuer"."group_code", "insurance_insuranceissuer"."state", "insurance_insuranceissuer"."created_at", "insurance_insuranceissuer"."updated_at" FROM "insurance_insuranceissuer" LEFT OUTER JOIN "insurance_coverage_practiceissuer" ON ( "insurance_insuranceissuer"."id" = "insurance_coverage_practiceissuer"."issuer_id" ) WHERE (("insurance_coverage_practiceissuer"."in_network" = %s AND "insurance_coverage_practiceissuer"."practice_id" = %s ) OR NOT ("insurance_insuranceissuer"."id" IN (SELECT U1."issuer_id" FROM "insurance_coverage_practiceissuer" U1 WHERE U1."in_network" = %s ) AND "insurance_insuranceissuer"."id" IN (SELECT U1."issuer_id" FROM "insurance_coverage_practiceissuer" U1 WHERE U1."practice_id" = %s ))) LIMIT 21' - PARAMS = (True, u'b107925f-aac8-4baa-b304-3ec720ef082d', False, u'b107925f-aac8-4baa-b304-3ec720ef082d'); args=(True, u'b107925f-aac8-4baa-b304-3ec720ef082d', False, u'b107925f-aac8-4baa-b304-3ec720ef082d')
SELECT DISTINCT "insurance_insuranceissuer"."id", "insurance_insuranceissuer"."slug", "insurance_insuranceissuer"."issuer_code", "insurance_insuranceissuer"."legal_name", "insurance_insuranceissuer"."marketing_name", "insurance_insuranceissuer"."company_code", "insurance_insuranceissuer"."group_code", "insurance_insuranceissuer"."state", "insurance_insuranceissuer"."created_at", "insurance_insuranceissuer"."updated_at" FROM "insurance_insuranceissuer" WHERE NOT ("insurance_insuranceissuer"."id" IN (SELECT U1."issuer_id" FROM "insurance_coverage_practiceissuer" U1 WHERE U1."in_network" = %s ) AND "insurance_insuranceissuer"."id" IN (SELECT U1."issuer_id" FROM "insurance_coverage_practiceissuer" U1 WHERE U1."practice_id" = %s )) LIMIT 21' - PARAMS = (False, u'b107925f-aac8-4baa-b304-3ec720ef082d'); args=(False, u'b107925f-aac8-4baa-b304-3ec720ef082d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment