<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_reference_fields(citation_elements, line_marker, raw_ref, reference_format):
 """Create the final representation of the reference information. @param citation_elements: (list) an ordered list of dictionary elements, with each element corresponding to a found piece of information from a reference line. @param line_marker: (string) The line marker for this single reference line (e.g. [19]) @param raw_ref: (string) The raw string of this line @return reference_fields: (list) A list of one dictionary containing the reference elements """

    # Begin the datafield element
    current_field = create_reference_field(line_marker)
    current_field['raw_ref'] = [raw_ref]

    reference_fields = [current_field]

    for element in citation_elements:
        # Before going onto checking 'what' the next element is,
        # handle misc text and semi-colons
        # Multiple misc text subfields will be compressed later
        # This will also be the only part of the code that deals with MISC
        # tag_typed elements
        misc_txt = element['misc_txt']
        if misc_txt.strip("., [](){}"):
            misc_txt = misc_txt.lstrip('])} ,.').rstrip('[({ ,.')
            add_subfield(current_field, 'misc', misc_txt)

        # Now handle the type dependent actions
        # JOURNAL
        if element['type'] == "JOURNAL":
            add_journal_subfield(current_field, element, reference_format)

        # REPORT NUMBER
        elif element['type'] == "REPORTNUMBER":
            add_subfield(current_field, 'reportnumber', element['report_num'])

        # URL
        elif element['type'] == "URL":
            if element['url_string'] == element['url_desc']:
                # Build the datafield for the URL segment of the reference
                # line:
                add_subfield(current_field, 'url', element['url_string'])
            # Else, in the case that the url string and the description differ
            # in some way, include them both
            else:
                add_subfield(current_field, 'url', element['url_string'])
                add_subfield(current_field, 'urldesc', element['url_desc'])

        # DOI
        elif element['type'] == "DOI":
            add_subfield(current_field, 'doi', 'doi:' + element['doi_string'])

        # HDL
        elif element['type'] == "HDL":
            add_subfield(current_field, 'hdl', 'hdl:' + element['hdl_id'])

        # AUTHOR
        elif element['type'] == "AUTH":
            value = element['auth_txt']
            if element['auth_type'] == 'incl':
                value = "(%s)" % value

            add_subfield(current_field, 'author', value)

        elif element['type'] == "QUOTED":
            add_subfield(current_field, 'title', element['title'])

        elif element['type'] == "ISBN":
            add_subfield(current_field, 'isbn', element['ISBN'])

        elif element['type'] == "BOOK":
            add_subfield(current_field, 'title', element['title'])

        elif element['type'] == "PUBLISHER":
            add_subfield(current_field, 'publisher', element['publisher'])

        elif element['type'] == "YEAR":
            add_subfield(current_field, 'year', element['year'])

        elif element['type'] == "COLLABORATION":
            add_subfield(current_field,
                         'collaboration',
                         element['collaboration'])

        elif element['type'] == "RECID":
            add_subfield(current_field, 'recid', str(element['recid']))

    return reference_fields