 
 INSERT INTO query_objects(instance,scope,module,section,target,short_desc,standard,primary_link,secondary_link) 
   VALUES('lava','crms','query','patient','demographics','Demographics',1,0,1);
+INSERT INTO query_objects(instance,scope,module,section,target,short_desc,standard,primary_link,secondary_link) 
+  VALUES('lava','crms','query','patient','family','Family',1,0,1);
 INSERT INTO query_objects(instance,scope,module,section,target,short_desc,standard,primary_link,secondary_link) 
   VALUES('lava','crms','query','enrollment','status','Enrollment Status',1,0,0);
 INSERT INTO query_objects(instance,scope,module,section,target,short_desc,standard,primary_link,secondary_link) 

CREATE TABLE IF NOT EXISTS `lq_view_demographics` (`PIDN_demographics` INT, `DOB` INT, `AGE` INT, `Gender` INT, `Hand` INT, `Deceased` INT, `DOD` INT, `PrimaryLanguage` INT, `TestingLanguage` INT, `TransNeeded` INT, `TransLanguage` INT);

-- -----------------------------------------------------
-- Placeholder table for view `lq_view_enrollment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `lq_view_enrollment` (`EnrollStatID` INT, `PIDN_Enrollment` INT, `ProjName` INT, `SubjectStudyID` INT, `ReferralSource` INT, `LatestDesc` INT, `LatestDate` INT, `LatestNote` INT, `ReferredDesc` INT, `ReferredDate` INT, `ReferredNote` INT, `DeferredDesc` INT, `DeferredDate` INT, `DeferredNote` INT, `EligibleDesc` INT, `EligibleDate` INT, `EligibleNote` INT, `IneligibleDesc` INT, `IneligibleDate` INT, `IneligibleNote` INT, `DeclinedDesc` INT, `DeclinedDate` INT, `DeclinedNote` INT, `EnrolledDesc` INT, `EnrolledDate` INT, `EnrolledNote` INT, `ExcludedDesc` INT, `ExcludedDate` INT, `ExcludedNote` INT, `WithdrewDesc` INT, `WithdrewDate` INT, `WithdrewNote` INT, `InactiveDesc` INT, `InactiveDate` INT, `InactiveNote` INT, `DeceasedDesc` INT, `DeceasedDate` INT, `DeceasedNote` INT, `AutopsyDesc` INT, `AutopsyDate` INT, `AutopsyNote` INT, `ClosedDesc` INT, `ClosedDate` INT, `ClosedNote` INT, `EnrollmentNotes` INT, `modified` INT);


CREATE VIEW `lq_view_demographics` AS select `patient`.`PIDN` AS `PIDN_demographics`,`patient`.`DOB` AS `DOB`,`patient_age`.`AGE` AS `AGE`,`patient`.`Gender` AS `Gender`,`patient`.`Hand` AS `Hand`,`patient`.`Deceased` AS `Deceased`,`patient_dod`.`DOD` AS `DOD`,`patient`.`PrimaryLanguage` AS `PrimaryLanguage`,`patient`.`TestingLanguage` AS `TestingLanguage`,`patient`.`TransNeeded` AS `TransNeeded`,`patient`.`TransLanguage` AS `TransLanguage` from (`patient` join `patient_age` on((`patient`.`PIDN` = `patient_age`.`PIDN`)) join `patient_dod` on (`patient`.`PIDN` = `patient_dod`.`PIDN`)) where (`patient`.`PIDN` > 0);

-- -----------------------------------------------------
-- View `lq_view_family`
-- -----------------------------------------------------
DROP VIEW IF EXISTS `lq_view_family` ;
DROP TABLE IF EXISTS `lq_view_family`;

CREATE VIEW `lq_view_family` AS select `patient`.`PIDN` AS `PIDN_Family`,`patient`.`FamilyID` AS `FamilyID`,`patient`.`FamilyStatus` AS `FamilyStatus`,`patient`.`FamilyStudy` AS `FamilyStudy`,`patient`.`RelationToProband` AS `RelationToProband`,`patient`.`Twin` AS `Twin`,`patient`.`TwinZygosity` AS `TwinZygosity`,`patient`.`TwinID` AS `TwinID`,`patient`.`RelationNotes` AS `RelationNotes` from ((`patient` join `patient_age` on((`patient`.`PIDN` = `patient_age`.`PIDN`))) join `patient_dod` on((`patient`.`PIDN` = `patient_dod`.`PIDN`))) where (`patient`.`PIDN` > 0);

-- -----------------------------------------------------
-- View `lq_view_enrollment`
