# Path: collectors/nct/record.py
# class Record(base.Record):
# 
#     # Config
# 
#     table = 'nct'
#     _DATE_FORMATS = [
#         '%B %Y',
#         '%B %d, %Y',
#     ]
# 
#     # General
# 
#     nct_id = Text(primary_key=True)
#     download_date = Text()
#     link_text = Text()
#     url = Text()
#     org_study_id = Text()
#     secondary_ids = Array()
#     nct_aliases = Array()
#     brief_title = Text()
#     acronym = Text()
#     official_title = Text()
#     sponsors = Json()
#     source = Text()
#     oversight_info = Json()
#     brief_summary = Text()
#     detailed_description = Text()
#     overall_status = Text()
#     why_stopped = Text()
#     start_date = Date(_DATE_FORMATS)
#     completion_date_actual = Date(_DATE_FORMATS)
#     completion_date_anticipated = Date(_DATE_FORMATS)
#     primary_completion_date_actual = Date(_DATE_FORMATS)
#     primary_completion_date_anticipated = Date(_DATE_FORMATS)
#     phase = Text()
#     study_type = Text()
#     study_design = Text()
#     target_duration = Text()
#     primary_outcomes = Json()
#     secondary_outcomes = Json()
#     other_outcomes = Json()
#     number_of_arms = Integer()
#     number_of_groups = Integer()
#     enrollment_actual = Integer()
#     enrollment_anticipated = Integer()
#     conditions = Array()
#     arm_groups = Json()
#     interventions = Json()
#     biospec_retention = Text()
#     biospec_desrc = Text()
#     eligibility = Json()
#     overall_officials = Json()
#     overall_contact = Json()
#     overall_contact_backup = Json()
#     locations = Json()
#     location_countries = Array()
#     removed_countries = Array()
#     links = Json()
#     references = Json()
#     results_references = Json()
#     verification_date = Date(_DATE_FORMATS)
#     lastchanged_date = Date(_DATE_FORMATS)
#     firstreceived_date = Date(_DATE_FORMATS)
#     firstreceived_results_date = Date(_DATE_FORMATS)
#     responsible_party = Json()
#     keywords = Array()
#     is_fda_regulated = Boolean('Yes')
#     is_section_801 = Boolean('Yes')
#     has_expanded_access = Boolean('Yes')
#     condition_browse = Json()
#     intervention_browse = Json()
#     clinical_results = Json()
#     results_exemption_date = Date(_DATE_FORMATS)


import logging
import xmltodict
    import xml.etree.ElementTree as etree
    from lxml import etree
from .record import Record
    value = _parse_text(res, path)
    data[key] = value

    key = 'has_expanded_access'
    path = 'has_expanded_access'
    value = _parse_text(res, path)
    data[key] = value

    key = 'condition_browse'
    path = 'condition_browse'
    value = _parse_dict(res, path, expand=key)
    data[key] = value

    key = 'intervention_browse'
    path = 'intervention_browse'
    value = _parse_dict(res, path, expand=key)
    data[key] = value

    key = 'clinical_results'
    path = 'clinical_results'
    value = _parse_dict(res, path, expand=key)
    data[key] = value

    key = 'results_exemption_date'
    path = 'firstreceived_results_disposition_date'
    value = _parse_text(res, path)
    data[key] = value

    # Create record
    url = 'https://clinicaltrials.gov/ct2/show/%s' % data['nct_id']

# Path: collectors/nct/record.py
# class Record(base.Record):
# 
#     # Config
# 
#     table = 'nct'
#     _DATE_FORMATS = [
#         '%B %Y',
#         '%B %d, %Y',
#     ]
# 
#     # General
# 
#     nct_id = Text(primary_key=True)
#     download_date = Text()
#     link_text = Text()
#     url = Text()
#     org_study_id = Text()
#     secondary_ids = Array()
#     nct_aliases = Array()
#     brief_title = Text()
#     acronym = Text()
#     official_title = Text()
#     sponsors = Json()
#     source = Text()
#     oversight_info = Json()
#     brief_summary = Text()
#     detailed_description = Text()
#     overall_status = Text()
#     why_stopped = Text()
#     start_date = Date(_DATE_FORMATS)
#     completion_date_actual = Date(_DATE_FORMATS)
#     completion_date_anticipated = Date(_DATE_FORMATS)
#     primary_completion_date_actual = Date(_DATE_FORMATS)
#     primary_completion_date_anticipated = Date(_DATE_FORMATS)
#     phase = Text()
#     study_type = Text()
#     study_design = Text()
#     target_duration = Text()
#     primary_outcomes = Json()
#     secondary_outcomes = Json()
#     other_outcomes = Json()
#     number_of_arms = Integer()
#     number_of_groups = Integer()
#     enrollment_actual = Integer()
#     enrollment_anticipated = Integer()
#     conditions = Array()
#     arm_groups = Json()
#     interventions = Json()
#     biospec_retention = Text()
#     biospec_desrc = Text()
#     eligibility = Json()
#     overall_officials = Json()
#     overall_contact = Json()
#     overall_contact_backup = Json()
#     locations = Json()
#     location_countries = Array()
#     removed_countries = Array()
#     links = Json()
#     references = Json()
#     results_references = Json()
#     verification_date = Date(_DATE_FORMATS)
#     lastchanged_date = Date(_DATE_FORMATS)
#     firstreceived_date = Date(_DATE_FORMATS)
#     firstreceived_results_date = Date(_DATE_FORMATS)
#     responsible_party = Json()
#     keywords = Array()
#     is_fda_regulated = Boolean('Yes')
#     is_section_801 = Boolean('Yes')
#     has_expanded_access = Boolean('Yes')
#     condition_browse = Json()
#     intervention_browse = Json()
#     clinical_results = Json()
#     results_exemption_date = Date(_DATE_FORMATS)


# Path: collectors/nct/parser.py
import logging
import xmltodict
    import xml.etree.ElementTree as etree
    from lxml import etree
from .record import Record

    value = _parse_text(res, path)
    data[key] = value

    key = 'has_expanded_access'
    path = 'has_expanded_access'
    value = _parse_text(res, path)
    data[key] = value

    key = 'condition_browse'
    path = 'condition_browse'
    value = _parse_dict(res, path, expand=key)
    data[key] = value

    key = 'intervention_browse'
    path = 'intervention_browse'
    value = _parse_dict(res, path, expand=key)
    data[key] = value

    key = 'clinical_results'
    path = 'clinical_results'
    value = _parse_dict(res, path, expand=key)
    data[key] = value

    key = 'results_exemption_date'
    path = 'firstreceived_results_disposition_date'
    value = _parse_text(res, path)
    data[key] = value

    # Create record
    url = 'https://clinicaltrials.gov/ct2/show/%s' % data['nct_id']

    record = Record.create(url, data)