Link to home
Create AccountLog in
Avatar of Goo123
Goo123Flag for United States of America

asked on

Adding another field/query to script

I need to add another filter to show:

"INSR_Insurance"."Insurance_Sequence"=2  

so that this would pull up another name in this Select statement:

VIEW_Insurance"."Organization_Name",    so it would be called view_insurance. organization_name 2

This would show a primary insurance from insurance_sequence = 1, then selecting view_insurance.organization_name2 as the insurance name secondary insurance

thanks



SELECT "APP_Appointment"."Appointment_AppStartTime", "VIEW_Patient"."Person_DateOfBirth", "VIEW_Patient"."Person_Name", "APP_Appointment"."Appointment_Notes", "VIEW_Address"."Address_Line1", "VIEW_Address"."Address_Line2", "VIEW_Address"."Address_City", "VIEW_Address"."State_Abbreviation", "VIEW_Address"."Address_ZipCode", "APP_Appointment"."Appointment_Phone", "LKUP_VisitType"."VisitType_Description", "APP_AppointmentType"."AppointmentType_Code", "APP_Appointment"."Appointment_ID", "APP_Appointment"."Appointment_Status", "INSR_Insurance"."Insurance_Sequence", "VIEW_Patient"."Person_Sex", "VIEW_Address"."AddressType_ID", "LKUP_PatientKind"."PatientKind_Code", "VIEW_Address"."Entity_ID", "VIEW_Patient"."Patient_FileID", "APP_Appointment"."Appointment_Description", "VIEW_Insurance"."Organization_Name", "VIEW_Insurance"."Insurance_Sequence"

FROM   ((((((APP_Appointment "APP_Appointment" INNER JOIN VIEW_Patient "VIEW_Patient" ON "APP_Appointment"."Patient_ID"="VIEW_Patient"."Patient_ID") INNER JOIN APP_AppointmentType "APP_AppointmentType" ON "APP_Appointment"."AppointmentType_ID"="APP_AppointmentType"."AppointmentType_ID") INNER JOIN LKUP_VisitType "LKUP_VisitType" ON "APP_Appointment"."VisitType_ID"="LKUP_VisitType"."VisitType_ID") LEFT OUTER JOIN INSR_Insurance "INSR_Insurance" ON "VIEW_Patient"."Entity_ID"="INSR_Insurance"."Entity_ID") LEFT OUTER JOIN VIEW_Address "VIEW_Address" ON "VIEW_Patient"."Entity_ID"="VIEW_Address"."Entity_ID") INNER JOIN LKUP_PatientKind "LKUP_PatientKind" ON "VIEW_Patient"."PatientKind_ID"="LKUP_PatientKind"."PatientKind_ID") LEFT OUTER JOIN VIEW_Insurance "VIEW_Insurance" ON "INSR_Insurance"."Insurance_ID"="VIEW_Insurance"."Insurance_ID"

WHERE  ("VIEW_Address"."Entity_ID" IS  NULL  OR "VIEW_Address"."AddressType_ID"='0000000001' AND ("VIEW_Insurance"."Insurance_Sequence" IS  NULL  OR "VIEW_Insurance"."Insurance_Sequence"=1)) AND ("INSR_Insurance"."Insurance_Sequence" IS  NULL  OR "INSR_Insurance"."Insurance_Sequence"=1) AND "APP_Appointment"."Appointment_Status"<>5 AND ("APP_Appointment"."Appointment_AppStartTime">={ts '2011-11-07 00:00:00'} AND "APP_Appointment"."Appointment_AppStartTime"<{ts '2011-11-08 00:00:00'})

Avatar of Goo123
Goo123
Flag of United States of America image

ASKER

any assistance appreciated
Avatar of Mike McCracken
Mike McCracken

Did you try with

 ("INSR_Insurance"."Insurance_Sequence" IS  NULL  OR "INSR_Insurance"."Insurance_Sequence"=1 OR "INSR_Insurance"."Insurance_Sequence"= 2)

mlmcc
Avatar of Goo123

ASKER

Hmm, I have to reproduce the insurance sequence field = '1' so that view_insurance.organizationame would equal this statement   and, also,
insurance sequence field = '2'  so that view_insurance.organizationame2 would equal this statement  

i.e.   sequence field = 1   , then organization name as xxxx
AND
sequence field=2  , then organization name2  as  yyyy

ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer