def write_timeline()

in functions/source/job-creation/job_creation.py [0:0]


def write_timeline(mrn, previously_reviewed):
    '''
    writes patient MRN, PR and creationtime to JobCreationTime file,
    in order to track label job creation times

    '''
    key = os.environ['CREATIONTIME_JOBS']
    bucket = os.environ['PRODUCTION']
    source_csv = f's3://{bucket}/source-csv/{mrn}.csv'

    s3_client = boto3.client('s3')
    csv_obj = s3_client.get_object(Bucket=bucket, Key=key)
    body = csv_obj['Body']
    csv_string = body.read().decode('utf-8')
    dataframe = pd.read_csv(StringIO(csv_string))

    current_time = time.localtime(time.time())
    timestamp = time.mktime(current_time)
    currenttime = date.fromtimestamp(timestamp)
    dictionary = {'MRN': mrn, 'PR': previously_reviewed,
                  'CreationTime': currenttime,
                  'SourceCSV': source_csv}
    dataframe = dataframe.append(dictionary, ignore_index=True)
    write_dataframe_to_csv_on_s3(dataframe, key, bucket)

    print('finished writing time line')