Version 3 (modified by 11 years ago) ( diff ) | ,
---|
CiviCRM Graphic 2 Patient Export
Direct Query
Requirements
- Bring across consents and IDs etc from the civicrm_value_graphic2_10 table.
- Check that the patient has one of the required statuses in the civicrm_case.status_id column. These are: 6: Available for cohort, 10: Completed, 1: Open, 5: Recruited.
Query
As usual the queries are different for test and for live. Hurray!
Test
SELECT recruit.id civiCRM_contact_id , cids.nhs_number_1 nhs_number , cids.uhl_s_number_2 uhl_s_number , g2d.* , recruit.birth_date , enrollment.start_date enrollment_date /* , CASE WHEN (wstatus.withdrawal_status_24 = 'A') THEN enrollment.end_date END withdrawal_date */ FROM civicrm_contact recruit JOIN civicrm_case_contact enrollcontact ON enrollcontact.contact_id = recruit.id JOIN civicrm_case enrollment ON enrollment.id = enrollcontact.case_id AND enrollment.status_id NOT IN (7 /* declined */, 9 /* excluded */, 4 /* Recruitment Pending */) AND enrollment.case_type_id = "5" /* Graphic 2 */ AND enrollment.is_deleted = 0 JOIN civicrm_value_contact_ids_2 cids ON cids.entity_id = recruit.id /* Is this the case? */ JOIN civicrm_value_graphic2_10 g2d ON g2d.entity_id = enrollment.id /* CHECK THIS */ /* MAYBE: LEFT JOIN civicrm_value_genvasc_withdrawal_status_9 wstatus ON wstatus.entity_id = enrollment.id */ WHERE recruit.is_deleted = 0 /* AND COALESCE(wstatus.withdrawal_status_24, '') <> 'B' */ ;
Note:
See TracWiki
for help on using the wiki.