def parse_matches(patient_id, match_objs):
LOG.info('<STR_LIT>'.format(patient_id))<EOL>parsed_matches = []<EOL>for match_obj in match_objs:<EOL><INDENT>milliseconds_date = match_obj['<STR_LIT>']['<STR_LIT>']<EOL>mdate = datetime.datetime.fromtimestamp(milliseconds_date/<NUM_LIT>)<EOL>match_type = '<STR_LIT>'<EOL>matching_patients = []<EOL>parsed_match = {<EOL>'<STR_LIT>' : match_obj['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT>' : mdate<EOL>}<EOL>if match_obj['<STR_LIT:data>']['<STR_LIT>']['<STR_LIT:id>'] == patient_id:<EOL><INDENT>match_results = match_obj['<STR_LIT>'] <EOL>for node_result in match_results:<EOL><INDENT>if match_obj['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>match_type = '<STR_LIT>'<EOL><DEDENT>for patient in node_result['<STR_LIT>']:<EOL><INDENT>match_patient = {<EOL>'<STR_LIT>' : patient['<STR_LIT>']['<STR_LIT:id>'],<EOL>'<STR_LIT>' : patient['<STR_LIT>'],<EOL>'<STR_LIT>' : patient['<STR_LIT>'],<EOL>'<STR_LIT>' : node_result['<STR_LIT>']<EOL>}<EOL>matching_patients.append(match_patient)<EOL><DEDENT><DEDENT><DEDENT>else: <EOL><INDENT>m_patient = match_obj['<STR_LIT:data>']['<STR_LIT>']<EOL>contact_institution = m_patient['<STR_LIT>'].get('<STR_LIT>')<EOL>if contact_institution and '<STR_LIT>' in contact_institution:<EOL><INDENT>match_type = '<STR_LIT>'<EOL><DEDENT>score = None<EOL>for res in match_obj['<STR_LIT>']:<EOL><INDENT>for patient in res['<STR_LIT>']:<EOL><INDENT>LOG.info('<STR_LIT>'.format(patient['<STR_LIT>']['<STR_LIT:id>']))<EOL>if patient['<STR_LIT>']['<STR_LIT:id>'] == patient_id:<EOL><INDENT>score = patient['<STR_LIT>']<EOL>match_patient = {<EOL>'<STR_LIT>' : m_patient['<STR_LIT:id>'],<EOL>'<STR_LIT>' : score,<EOL>'<STR_LIT>' : m_patient,<EOL>'<STR_LIT>' : res['<STR_LIT>']<EOL>}<EOL>matching_patients.append(match_patient)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>parsed_match['<STR_LIT>'] = match_type<EOL>parsed_match['<STR_LIT>'] = matching_patients<EOL>parsed_matches.append(parsed_match)<EOL><DEDENT>parsed_matches = sorted(parsed_matches, key=lambda k: k['<STR_LIT>'], reverse=True)<EOL>return parsed_matches<EOL>
Parse a list of matchmaker matches objects and returns
       a readable list of matches to display in matchmaker matches view.

    Args:
        patient_id(str): id of a mme patient
        match_objs(list): list of match objs returned by MME server for the patient
                # match_objs looks like this:
                    [
                        {
                            'node' : { id : node_id , label: node_label},
                            'patients' : [
                                { 'patient': {patient1_data} },
                                { 'patient': {patient2_data} },
                                ..
                            ]
                        },
                        ..
                    ]

    Returns:
        parsed_matches(list): a list of parsed match objects