Skip to content

Instantly share code, notes, and snippets.

@Xodarap
Last active August 26, 2024 22:00
Show Gist options
  • Save Xodarap/c96a31512a0506ae4f4e to your computer and use it in GitHub Desktop.
Save Xodarap/c96a31512a0506ae4f4e to your computer and use it in GitHub Desktop.
--Diagnoses
select "CPTItemDetail"."value", "BillingItems"."itemName", "BillingData"."icdcode1", "BillingData"."icdcode2", "BillingData"."icdcode3", "BillingData"."icdcode4", "PATIENT"."hl7Id", "PATIENT_USERS"."ssn", "PATIENT_USERS"."ptDob", case when "PATIENT_USERS"."sex" = '' then 'Unknown' else "PATIENT_USERS"."sex" end , case when "PATIENT"."deceased" = 1 then 'Yes' when "PATIENT"."deceased" = 0 then 'No' else 'UnKnown' end , "CHARGE_ETHNICITY"."Name", "PATIENT"."language", "encBillingData"."date", "ChargeUser___Patient"."ptDob", "PATIENT_USERS"."ufname", "PATIENT_USERS"."uminitial", "PATIENT_USERS"."ulname", "PATIENT_USERS"."uemail", "PATIENT_USERS"."upPhone", "PATIENT_USERS"."upaddress", "PATIENT_USERS"."upcity", "PATIENT_USERS"."upstate", "PATIENT_USERS"."zipcode", "EDI_FACILITIES"."code", "EDI_FACILITIES"."Id", "EDI_FACILITIES"."Name", "EDI_FACILITIES"."startedOn", "APPOINTMENT_DOCTOR"."NPI", "APPOINTMENT_PROVIDER"."uid", "APPOINTMENT_DOCTOR"."TaxID", "APPOINTMENT_DOCTOR"."SpecialityCode", "APPOINTMENT_DOCTOR"."speciality", "APPOINTMENT_PROVIDER"."prefix", "APPOINTMENT_PROVIDER"."ufname", "APPOINTMENT_PROVIDER"."uminitial", "APPOINTMENT_PROVIDER"."ulname", "APPOINTMENT_PROVIDER"."upaddress", "APPOINTMENT_PROVIDER"."upcity", "APPOINTMENT_PROVIDER"."upstate", "APPOINTMENT_PROVIDER"."zipcode", "APPOINTMENT_PROVIDER"."upPhone", "APPOINTMENT_PROVIDER"."uemail"
from (((((((((((("enc" "EncounterDiagnosis" INNER JOIN "enc" "EMR_ENCOUNTER" on "EncounterDiagnosis"."encounterID" = "EMR_ENCOUNTER"."encounterID") INNER JOIN "patients" "PATIENT" on "EMR_ENCOUNTER"."patientID" = "PATIENT"."pid") INNER JOIN "patients" "ChargePaitent___Patient" on "ChargePaitent___Patient"."pid" = "EncounterDiagnosis"."patientID") INNER JOIN "enc" "encBillingData" on "encBillingData"."patientID" = "ChargePaitent___Patient"."pid") LEFT OUTER JOIN "billingdata" "BillingData" on "encBillingData"."encounterID" = "BillingData"."EncounterId" and 0 = "BillingData"."deleteFlag") LEFT OUTER JOIN "items" "BillingItems" on "BillingData"."itemID" = "BillingItems"."itemID" and 0 = "BillingItems"."deleteFlag") LEFT OUTER JOIN "itemdetail" "CPTItemDetail" on "BillingItems"."itemID" = "CPTItemDetail"."itemID") LEFT OUTER JOIN "edi_facilities" "EDI_FACILITIES" on "EMR_ENCOUNTER"."facilityId" = "EDI_FACILITIES"."Id") LEFT OUTER JOIN "doctors" "APPOINTMENT_DOCTOR" on "EMR_ENCOUNTER"."doctorID" = "APPOINTMENT_DOCTOR"."doctorID") LEFT OUTER JOIN "users" "APPOINTMENT_PROVIDER" on "APPOINTMENT_DOCTOR"."doctorID" = "APPOINTMENT_PROVIDER"."uid" and 1 = "APPOINTMENT_PROVIDER"."UserType") LEFT OUTER JOIN "users" "PATIENT_USERS" on "PATIENT"."pid" = "PATIENT_USERS"."uid" and 0 = "PATIENT_USERS"."delFlag") LEFT OUTER JOIN "ethnicity" "CHARGE_ETHNICITY" on "PATIENT"."ethnicity" = "CHARGE_ETHNICITY"."Code") LEFT OUTER JOIN "users" "ChargeUser___Patient" on "ChargePaitent___Patient"."pid" = "ChargeUser___Patient"."uid"
where "encBillingData"."date" between {d '2016-01-28'} and {d '2016-01-28'} and "CPTItemDetail"."propID" = 13 and "EDI_FACILITIES"."DeleteFlag" = 0 and "EDI_FACILITIES"."Id" = "EDI_FACILITIES"."Id" and "APPOINTMENT_PROVIDER"."UserType" = 1 and "APPOINTMENT_PROVIDER"."delFlag" = 0 and "EMR_ENCOUNTER"."encounterID" = "EMR_ENCOUNTER"."encounterID" and "PATIENT_USERS"."uid" <> 8663
select "EncounterDiagnosis"."date", "OLDRXMAIN"."StartDate", "OLDRXMAIN"."StopDate", "items1"."itemName", "itemdetail1"."value", "OLDRXMAIN"."ndc_code", "EncounterDiagnosis"."encounterID", "EncounterDiagnosis"."patientID"
from (((((((((((("users" "Appointment_DOSProvider" INNER JOIN "doctors" "Appointment_DOSDoctor" on "Appointment_DOSProvider"."uid" = "Appointment_DOSDoctor"."doctorID") INNER JOIN "enc" "EncounterDiagnosis" on "Appointment_DOSDoctor"."doctorID" = "EncounterDiagnosis"."doctorID") INNER JOIN "edi_facilities" "ChargesFacilites" on "EncounterDiagnosis"."facilityId" = "ChargesFacilites"."Id") INNER JOIN "patients" "ChargePaitent___Patient" on "ChargePaitent___Patient"."pid" = "EncounterDiagnosis"."patientID") LEFT OUTER JOIN "diagnosis" "diagnosis" on "EncounterDiagnosis"."encounterID" = "diagnosis"."EncounterId" and "EncounterDiagnosis"."deleteFlag" = 0) LEFT OUTER JOIN "items" "items1" on "diagnosis"."ItemId" = "items1"."itemID" and 0 = "items1"."deleteFlag") LEFT OUTER JOIN "itemdetail" "itemdetail1" on "diagnosis"."ItemId" = "itemdetail1"."itemID" and 13 = "itemdetail1"."propID") LEFT OUTER JOIN "oldrxmain" "OLDRXMAIN" on "diagnosis"."ItemId" = "OLDRXMAIN"."AssessId" and "diagnosis"."EncounterId" = "OLDRXMAIN"."encounterId") LEFT OUTER JOIN "items" "RXItem" on "OLDRXMAIN"."ItemId" = "RXItem"."itemID") LEFT OUTER JOIN "facilitygroupmembers" "FacilityGrpMember" on "ChargesFacilites"."Id" = "FacilityGrpMember"."FacilityId" and 0 = "FacilityGrpMember"."deleteFlag") LEFT OUTER JOIN "facilitygroups" "FacilityGrp" on "FacilityGrpMember"."GroupId" = "FacilityGrp"."Id" and 0 = "FacilityGrp"."deleteFlag" and "FacilityGrpMember"."deleteFlag" = 0 and "FacilityGrpMember"."ParentFlag" = 0) LEFT OUTER JOIN "users" "ChargeUser___Patient" on "ChargePaitent___Patient"."pid" = "ChargeUser___Patient"."uid") LEFT OUTER JOIN "ethnicity" "ChargeEthnicity" on "ChargePaitent___Patient"."ethnicity" = "ChargeEthnicity"."Code"
where "EncounterDiagnosis"."date" between {d '2016-01-28'} and {d '2016-01-28'}
--encounters
select "encBillingData"."encounterID", "encBillingData"."date", "CPTItemDetail"."value", "BillingItems"."itemName", "BillingData"."icdcode1", "BillingData"."icdcode2", "BillingData"."icdcode3", "BillingData"."icdcode4", "encBillingData"."patientID", "PATIENT"."hl7Id", "PATIENT_USERS"."ssn", "PATIENT_USERS"."ptDob", case when "PATIENT_USERS"."sex" = '' then 'Unknown' else "PATIENT_USERS"."sex" end , case when "PATIENT"."deceased" = 1 then 'Yes' when "PATIENT"."deceased" = 0 then 'No' else 'UnKnown' end , "CHARGE_ETHNICITY"."Name", "PATIENT"."language", "ChargeUser___Patient"."ptDob", "PATIENT_USERS"."ufname", "PATIENT_USERS"."uminitial", "PATIENT_USERS"."ulname", "PATIENT_USERS"."uemail", "PATIENT_USERS"."upPhone", "PATIENT_USERS"."upaddress", "PATIENT_USERS"."upcity", "PATIENT_USERS"."upstate", "PATIENT_USERS"."zipcode", "EDI_FACILITIES"."code", "EDI_FACILITIES"."Id", "ChargesFacilites"."Name", "EDI_FACILITIES"."startedOn", "AppointmentUserProviderRefund"."ulname"+' '+"AppointmentUserProviderRefund"."ufname", "APPOINTMENT_DOCTOR"."NPI", "APPOINTMENT_PROVIDER"."uid", "APPOINTMENT_DOCTOR"."TaxID", "APPOINTMENT_DOCTOR"."SpecialityCode", "APPOINTMENT_DOCTOR"."speciality", "APPOINTMENT_PROVIDER"."prefix", "APPOINTMENT_PROVIDER"."ufname", "APPOINTMENT_PROVIDER"."uminitial", "APPOINTMENT_PROVIDER"."ulname", "APPOINTMENT_PROVIDER"."upaddress", "APPOINTMENT_PROVIDER"."upcity", "APPOINTMENT_PROVIDER"."upstate", "APPOINTMENT_PROVIDER"."zipcode", "APPOINTMENT_PROVIDER"."upPhone", "APPOINTMENT_PROVIDER"."uemail"
from (((((((((((((("doctors" "DOSDoctorRefund" INNER JOIN "users" "AppointmentUserProviderRefund" on "DOSDoctorRefund"."doctorID" = "AppointmentUserProviderRefund"."uid") INNER JOIN "enc" "encBillingData" on "DOSDoctorRefund"."doctorID" = "encBillingData"."doctorID") INNER JOIN "patients" "ChargePaitent___Patient" on "encBillingData"."patientID" = "ChargePaitent___Patient"."pid") INNER JOIN "edi_facilities" "ChargesFacilites" on "encBillingData"."facilityId" = "ChargesFacilites"."Id") LEFT OUTER JOIN "billingdata" "BillingData" on "encBillingData"."encounterID" = "BillingData"."EncounterId" and 0 = "BillingData"."deleteFlag") LEFT OUTER JOIN "items" "BillingItems" on "BillingData"."itemID" = "BillingItems"."itemID" and 0 = "BillingItems"."deleteFlag") LEFT OUTER JOIN "itemdetail" "CPTItemDetail" on "BillingItems"."itemID" = "CPTItemDetail"."itemID") FULL OUTER JOIN "enc" "enc" on "BillingData"."EncounterId" = "enc"."encounterID") LEFT OUTER JOIN ("enc" "EMR_ENCOUNTER" INNER JOIN "patients" "PATIENT" on "EMR_ENCOUNTER"."patientID" = "PATIENT"."pid") on "enc"."encounterID" = "EMR_ENCOUNTER"."encounterID") LEFT OUTER JOIN "users" "PATIENT_USERS" on "PATIENT"."pid" = "PATIENT_USERS"."uid" and 0 = "PATIENT_USERS"."delFlag") LEFT OUTER JOIN "edi_facilities" "EDI_FACILITIES" on "EMR_ENCOUNTER"."facilityId" = "EDI_FACILITIES"."Id") LEFT OUTER JOIN "doctors" "APPOINTMENT_DOCTOR" on "EMR_ENCOUNTER"."doctorID" = "APPOINTMENT_DOCTOR"."doctorID") LEFT OUTER JOIN "users" "APPOINTMENT_PROVIDER" on "APPOINTMENT_DOCTOR"."doctorID" = "APPOINTMENT_PROVIDER"."uid" and 1 = "APPOINTMENT_PROVIDER"."UserType") LEFT OUTER JOIN "ethnicity" "CHARGE_ETHNICITY" on "PATIENT"."ethnicity" = "CHARGE_ETHNICITY"."Code") LEFT OUTER JOIN "users" "ChargeUser___Patient" on "ChargePaitent___Patient"."pid" = "ChargeUser___Patient"."uid"
where "encBillingData"."date" between {d '2016-01-28'} and {d '2016-01-28'} and "CPTItemDetail"."propID" = 13 and "EDI_FACILITIES"."DeleteFlag" = 0 and "EDI_FACILITIES"."Id" = "EDI_FACILITIES"."Id" and "APPOINTMENT_PROVIDER"."UserType" = 1 and "APPOINTMENT_PROVIDER"."delFlag" = 0 and "EMR_ENCOUNTER"."encounterID" = "EMR_ENCOUNTER"."encounterID" and "PATIENT_USERS"."uid" <> 8663
--Medications
select "EMR_ENCOUNTER"."date", "OLDRXMAIN"."ndc_code", "oldrxDetailDispense"."value", "oldrxdetailFrequency"."value", "oldrxDetailTake"."value", "oldrxDetailDuration"."value", "RXItem"."itemName", "rxhub_scriptlog"."Dosage", "oldrxDetailRoute"."value", "oldrxDetailStrength"."value", "OLDRXMAIN"."StartDate", "OLDRXMAIN"."StopDate", "CPTItemDetail"."value", "BillingItems"."itemName", "BillingData"."icdcode1", "BillingData"."icdcode2", "BillingData"."icdcode3", "BillingData"."icdcode4", "EMR_ENCOUNTER"."encounterID", "encBillingData"."date", "PATIENT_USERS"."uid", "PATIENT"."hl7Id", "PATIENT_USERS"."ssn", "PATIENT_USERS"."ptDob", case when "PATIENT_USERS"."sex" = '' then 'Unknown' else "PATIENT_USERS"."sex" end , case when "PATIENT"."deceased" = 1 then 'Yes' when "PATIENT"."deceased" = 0 then 'No' else 'UnKnown' end , "CHARGE_ETHNICITY"."Name", "PATIENT"."language", "ChargeUser___Patient"."ptDob", "PATIENT_USERS"."ufname", "PATIENT_USERS"."uminitial", "PATIENT_USERS"."ulname", "PATIENT_USERS"."uemail", "PATIENT_USERS"."upPhone", "PATIENT_USERS"."upaddress", "PATIENT_USERS"."upcity", "PATIENT_USERS"."upstate", "PATIENT_USERS"."zipcode", "EDI_FACILITIES"."code", "EDI_FACILITIES"."Id", "EDI_FACILITIES"."Name", "EDI_FACILITIES"."startedOn", "APPOINTMENT_DOCTOR"."NPI", "APPOINTMENT_PROVIDER"."uid", "APPOINTMENT_DOCTOR"."TaxID", "APPOINTMENT_DOCTOR"."SpecialityCode", "APPOINTMENT_DOCTOR"."speciality", "APPOINTMENT_PROVIDER"."ufname", "APPOINTMENT_PROVIDER"."uminitial", "APPOINTMENT_PROVIDER"."ulname", "APPOINTMENT_PROVIDER"."upaddress", "APPOINTMENT_PROVIDER"."upcity", "APPOINTMENT_PROVIDER"."upstate", "APPOINTMENT_PROVIDER"."zipcode", "APPOINTMENT_PROVIDER"."upPhone", "APPOINTMENT_PROVIDER"."uemail"
from (((((((((((((((((((("enc" "encBillingData" INNER JOIN "patients" "ChargePaitent___Patient" on "encBillingData"."patientID" = "ChargePaitent___Patient"."pid") LEFT OUTER JOIN "billingdata" "BillingData" on "encBillingData"."encounterID" = "BillingData"."EncounterId" and 0 = "BillingData"."deleteFlag") LEFT OUTER JOIN "items" "BillingItems" on "BillingData"."itemID" = "BillingItems"."itemID" and 0 = "BillingItems"."deleteFlag") LEFT OUTER JOIN "itemdetail" "CPTItemDetail" on "BillingItems"."itemID" = "CPTItemDetail"."itemID") FULL OUTER JOIN "enc" "enc" on "BillingData"."EncounterId" = "enc"."encounterID") LEFT OUTER JOIN ("enc" "EMR_ENCOUNTER" INNER JOIN "patients" "PATIENT" on "EMR_ENCOUNTER"."patientID" = "PATIENT"."pid") on "enc"."encounterID" = "EMR_ENCOUNTER"."encounterID") LEFT OUTER JOIN "users" "PATIENT_USERS" on "PATIENT"."pid" = "PATIENT_USERS"."uid" and 0 = "PATIENT_USERS"."delFlag") LEFT OUTER JOIN "edi_facilities" "EDI_FACILITIES" on "EMR_ENCOUNTER"."facilityId" = "EDI_FACILITIES"."Id") LEFT OUTER JOIN "doctors" "APPOINTMENT_DOCTOR" on "EMR_ENCOUNTER"."doctorID" = "APPOINTMENT_DOCTOR"."doctorID") LEFT OUTER JOIN "users" "APPOINTMENT_PROVIDER" on "APPOINTMENT_DOCTOR"."doctorID" = "APPOINTMENT_PROVIDER"."uid" and 1 = "APPOINTMENT_PROVIDER"."UserType") LEFT OUTER JOIN "ethnicity" "CHARGE_ETHNICITY" on "PATIENT"."ethnicity" = "CHARGE_ETHNICITY"."Code") LEFT OUTER JOIN "oldrxmain" "OLDRXMAIN" on "EMR_ENCOUNTER"."encounterID" = "OLDRXMAIN"."encounterId") LEFT OUTER JOIN "items" "RXItem" on "OLDRXMAIN"."ItemId" = "RXItem"."itemID") LEFT OUTER JOIN "oldrxdetail" "oldrxdetailFrequency" on "OLDRXMAIN"."OldRxId" = "oldrxdetailFrequency"."OldRxId" and 46 = "oldrxdetailFrequency"."OldRxId") LEFT OUTER JOIN "oldrxdetail" "oldrxDetailRoute" on "OLDRXMAIN"."OldRxId" = "oldrxDetailRoute"."OldRxId" and 47 = "oldrxDetailRoute"."Prop") LEFT OUTER JOIN "oldrxdetail" "oldrxDetailDuration" on "OLDRXMAIN"."OldRxId" = "oldrxDetailDuration"."OldRxId" and 49 = "oldrxDetailDuration"."Prop") LEFT OUTER JOIN "oldrxdetail" "oldrxDetailStrength" on "OLDRXMAIN"."OldRxId" = "oldrxDetailStrength"."OldRxId" and 51 = "oldrxDetailStrength"."Prop") LEFT OUTER JOIN "oldrxdetail" "oldrxDetailTake" on "OLDRXMAIN"."OldRxId" = "oldrxDetailTake"."OldRxId" and 52 = "oldrxDetailTake"."Prop") LEFT OUTER JOIN "oldrxdetail" "oldrxDetailDispense" on "OLDRXMAIN"."OldRxId" = "oldrxDetailDispense"."OldRxId" and 53 = "oldrxDetailDispense"."Prop") LEFT OUTER JOIN "rxhub_scriptlog" "rxhub_scriptlog" on "EMR_ENCOUNTER"."encounterID" = "rxhub_scriptlog"."EncounterId") LEFT OUTER JOIN "users" "ChargeUser___Patient" on "ChargePaitent___Patient"."pid" = "ChargeUser___Patient"."uid"
where "EMR_ENCOUNTER"."VisitType" <> 'PTDASH' and "OLDRXMAIN"."PatientsFlag" = 1 and "EMR_ENCOUNTER"."deleteFlag" = 0 and "EMR_ENCOUNTER"."patientID" <> 8663 and "EMR_ENCOUNTER"."deleteFlag" = 0 and "EMR_ENCOUNTER"."patientID" <> 8663 and "encBillingData"."date" between {d '2016-01-28'} and {d '2016-01-28'} and "CPTItemDetail"."propID" = 13 and "EDI_FACILITIES"."DeleteFlag" = 0 and "EDI_FACILITIES"."Id" = "EDI_FACILITIES"."Id" and "APPOINTMENT_PROVIDER"."UserType" = 1 and "APPOINTMENT_PROVIDER"."delFlag" = 0 and "EMR_ENCOUNTER"."encounterID" = "EMR_ENCOUNTER"."encounterID" and "PATIENT_USERS"."uid" <> 8663
--Vitals
select "Vitals"."vitalID" "C0" , "ItemKeysVitals"."name" "C1" , "Vitals"."value" "C2" , "EncounterDiagnosis"."VisitType" "C3" , "Vitals"."encounterID" "C4" , "EncounterDiagnosis"."date" "C5" , "ChargeUser___Patient"."uid" "C6" , "PATIENT"."hl7Id" "C7" , "PATIENT_USERS"."ssn" "C8" , "PATIENT_USERS"."ptDob" "C9" , case when "PATIENT_USERS"."sex" = '' then 'Unknown' else "PATIENT_USERS"."sex" end "C10" , case when "PATIENT"."deceased" = 1 then 'Yes' when "PATIENT"."deceased" = 0 then 'No' else 'UnKnown' end "C11" , "CHARGE_ETHNICITY"."Name" "C12" , "PATIENT"."language" "C13" , "PATIENT_USERS"."ufname" "C14" , "PATIENT_USERS"."uminitial" "C15" , "PATIENT_USERS"."ulname" "C16" , "PATIENT_USERS"."uemail" "C17" , "PATIENT_USERS"."upPhone" "C18" , "PATIENT_USERS"."upaddress" "C19" , "PATIENT_USERS"."upcity" "C20" , "PATIENT_USERS"."upstate" "C21" , "PATIENT_USERS"."zipcode" "C22" , "EDI_FACILITIES"."code" "C23" , "EDI_FACILITIES"."Id" "C24" , "EDI_FACILITIES"."Name" "C25" , "EDI_FACILITIES"."startedOn" "C26" , "APPOINTMENT_DOCTOR"."NPI" "C27" , "APPOINTMENT_PROVIDER"."uid" "C28" , "APPOINTMENT_DOCTOR"."TaxID" "C29" , "APPOINTMENT_DOCTOR"."SpecialityCode" "C30" , "APPOINTMENT_DOCTOR"."speciality" "C31" , "APPOINTMENT_PROVIDER"."prefix" "C32" , "APPOINTMENT_PROVIDER"."ufname" "C33" , "APPOINTMENT_PROVIDER"."uminitial" "C34" , "APPOINTMENT_PROVIDER"."ulname" "C35" , "APPOINTMENT_PROVIDER"."upaddress" "C36" , "APPOINTMENT_PROVIDER"."upcity" "C37" , "APPOINTMENT_PROVIDER"."upstate" "C38" , "APPOINTMENT_PROVIDER"."zipcode" "C39" , "APPOINTMENT_PROVIDER"."upPhone" "C40" , "APPOINTMENT_PROVIDER"."uemail" "C41"
from ((((((((((("enc" "EncounterDiagnosis" INNER JOIN "enc" "EMR_ENCOUNTER" on "EncounterDiagnosis"."encounterID" = "EMR_ENCOUNTER"."encounterID") INNER JOIN "patients" "PATIENT" on "EMR_ENCOUNTER"."patientID" = "PATIENT"."pid") INNER JOIN "enc" "encVitals" on "EncounterDiagnosis"."encounterID" = "encVitals"."encounterID") INNER JOIN "vitals" "Vitals" on "encVitals"."encounterID" = "Vitals"."encounterID") INNER JOIN "itemkeys" "ItemKeysVitals" on "ItemKeysVitals"."itemID" = "Vitals"."vitalID") INNER JOIN "patients" "ChargePaitent___Patient" on "ChargePaitent___Patient"."pid" = "EncounterDiagnosis"."patientID") LEFT OUTER JOIN "edi_facilities" "EDI_FACILITIES" on "EMR_ENCOUNTER"."facilityId" = "EDI_FACILITIES"."Id") LEFT OUTER JOIN "doctors" "APPOINTMENT_DOCTOR" on "EMR_ENCOUNTER"."doctorID" = "APPOINTMENT_DOCTOR"."doctorID") LEFT OUTER JOIN "users" "APPOINTMENT_PROVIDER" on "APPOINTMENT_DOCTOR"."doctorID" = "APPOINTMENT_PROVIDER"."uid" and 1 = "APPOINTMENT_PROVIDER"."UserType") LEFT OUTER JOIN "users" "PATIENT_USERS" on "PATIENT"."pid" = "PATIENT_USERS"."uid" and 0 = "PATIENT_USERS"."delFlag") LEFT OUTER JOIN "ethnicity" "CHARGE_ETHNICITY" on "PATIENT"."ethnicity" = "CHARGE_ETHNICITY"."Code") LEFT OUTER JOIN "users" "ChargeUser___Patient" on "ChargePaitent___Patient"."pid" = "ChargeUser___Patient"."uid"
where NOT "ItemKeysVitals"."name" is null and "EncounterDiagnosis"."date" between {d '2016-01-28'} and {d '2016-01-28'} and "EDI_FACILITIES"."DeleteFlag" = 0 and "EDI_FACILITIES"."Id" = "EDI_FACILITIES"."Id" and "APPOINTMENT_PROVIDER"."UserType" = 1 and "APPOINTMENT_PROVIDER"."delFlag" = 0 and "EMR_ENCOUNTER"."encounterID" = "EMR_ENCOUNTER"."encounterID" and "PATIENT_USERS"."uid" <> 8663
select "ChargeUser___Patient"."uid", "CPTItemDetail"."value", "BillingItems"."itemName", "BillingData"."icdcode1", "BillingData"."icdcode2", "BillingData"."icdcode3", "BillingData"."icdcode4", "encBillingData"."date", "ChargeUser___Patient"."ptDob"
from (((("enc" "encBillingData" INNER JOIN "patients" "ChargePaitent___Patient" on "encBillingData"."patientID" = "ChargePaitent___Patient"."pid") LEFT OUTER JOIN "billingdata" "BillingData" on "encBillingData"."encounterID" = "BillingData"."EncounterId" and 0 = "BillingData"."deleteFlag") LEFT OUTER JOIN "items" "BillingItems" on "BillingData"."itemID" = "BillingItems"."itemID" and 0 = "BillingItems"."deleteFlag") LEFT OUTER JOIN "itemdetail" "CPTItemDetail" on "BillingItems"."itemID" = "CPTItemDetail"."itemID") LEFT OUTER JOIN "users" "ChargeUser___Patient" on "ChargePaitent___Patient"."pid" = "ChargeUser___Patient"."uid"
where "encBillingData"."date" between {d '2016-01-28'} and {d '2016-01-28'} and "CPTItemDetail"."propID" = 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment