Goo123
asked on
Adding another field/query to script
I need to add another filter to show:
"INSR_Insurance"."Insuranc e_Sequence "=2
so that this would pull up another name in this Select statement:
VIEW_Insurance"."Organizat ion_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.organizatio n_name2 as the insurance name secondary insurance
thanks
SELECT "APP_Appointment"."Appoint ment_AppSt artTime", "VIEW_Patient"."Person_Dat eOfBirth", "VIEW_Patient"."Person_Nam e", "APP_Appointment"."Appoint ment_Notes ", "VIEW_Address"."Address_Li ne1", "VIEW_Address"."Address_Li ne2", "VIEW_Address"."Address_Ci ty", "VIEW_Address"."State_Abbr eviation", "VIEW_Address"."Address_Zi pCode", "APP_Appointment"."Appoint ment_Phone ", "LKUP_VisitType"."VisitTyp e_Descript ion", "APP_AppointmentType"."App ointmentTy pe_Code", "APP_Appointment"."Appoint ment_ID", "APP_Appointment"."Appoint ment_Statu s", "INSR_Insurance"."Insuranc e_Sequence ", "VIEW_Patient"."Person_Sex ", "VIEW_Address"."AddressTyp e_ID", "LKUP_PatientKind"."Patien tKind_Code ", "VIEW_Address"."Entity_ID" , "VIEW_Patient"."Patient_Fi leID", "APP_Appointment"."Appoint ment_Descr iption", "VIEW_Insurance"."Organiza tion_Name" , "VIEW_Insurance"."Insuranc e_Sequence "
FROM ((((((APP_Appointment "APP_Appointment" INNER JOIN VIEW_Patient "VIEW_Patient" ON "APP_Appointment"."Patient _ID"="VIEW _Patient". "Patient_I D") INNER JOIN APP_AppointmentType "APP_AppointmentType" ON "APP_Appointment"."Appoint mentType_I D"="APP_Ap pointmentT ype"."Appo intmentTyp e_ID") INNER JOIN LKUP_VisitType "LKUP_VisitType" ON "APP_Appointment"."VisitTy pe_ID"="LK UP_VisitTy pe"."Visit Type_ID") LEFT OUTER JOIN INSR_Insurance "INSR_Insurance" ON "VIEW_Patient"."Entity_ID" ="INSR_Ins urance"."E ntity_ID") LEFT OUTER JOIN VIEW_Address "VIEW_Address" ON "VIEW_Patient"."Entity_ID" ="VIEW_Add ress"."Ent ity_ID") INNER JOIN LKUP_PatientKind "LKUP_PatientKind" ON "VIEW_Patient"."PatientKin d_ID"="LKU P_PatientK ind"."Pati entKind_ID ") LEFT OUTER JOIN VIEW_Insurance "VIEW_Insurance" ON "INSR_Insurance"."Insuranc e_ID"="VIE W_Insuranc e"."Insura nce_ID"
WHERE ("VIEW_Address"."Entity_ID " IS NULL OR "VIEW_Address"."AddressTyp e_ID"='000 0000001' AND ("VIEW_Insurance"."Insuran ce_Sequenc e" IS NULL OR "VIEW_Insurance"."Insuranc e_Sequence "=1)) AND ("INSR_Insurance"."Insuran ce_Sequenc e" IS NULL OR "INSR_Insurance"."Insuranc e_Sequence "=1) AND "APP_Appointment"."Appoint ment_Statu s"<>5 AND ("APP_Appointment"."Appoin tment_AppS tartTime"> ={ts '2011-11-07 00:00:00'} AND "APP_Appointment"."Appoint ment_AppSt artTime"<{ ts '2011-11-08 00:00:00'})
"INSR_Insurance"."Insuranc
so that this would pull up another name in this Select statement:
VIEW_Insurance"."Organizat
This would show a primary insurance from insurance_sequence = 1, then selecting view_insurance.organizatio
thanks
SELECT "APP_Appointment"."Appoint
FROM ((((((APP_Appointment "APP_Appointment" INNER JOIN VIEW_Patient "VIEW_Patient" ON "APP_Appointment"."Patient
WHERE ("VIEW_Address"."Entity_ID
Did you try with
("INSR_Insurance"."Insuran ce_Sequenc e" IS NULL OR "INSR_Insurance"."Insuranc e_Sequence "=1 OR "INSR_Insurance"."Insuranc e_Sequence "= 2)
mlmcc
("INSR_Insurance"."Insuran
mlmcc
ASKER
Hmm, I have to reproduce the insurance sequence field = '1' so that view_insurance.organizatio name would equal this statement and, also,
insurance sequence field = '2' so that view_insurance.organizatio name2 would equal this statement
i.e. sequence field = 1 , then organization name as xxxx
AND
sequence field=2 , then organization name2 as yyyy
insurance sequence field = '2' so that view_insurance.organizatio
i.e. sequence field = 1 , then organization name as xxxx
AND
sequence field=2 , then organization name2 as yyyy
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER