     "_pageLabel=as_login_page"
 
     reimbursementUrl = "https://assure.ameli.fr/PortailAS/appmanager/" + \
-    "PortailAS/assure?_nfpb=true&_pageLabel=as_dernier_paiement_page"
+    "PortailAS/assure?_nfpb=true&_pageLabel=as_paiements_page"
+
+    refererUrl = "https://assure.ameli.fr/PortailAS/appmanager/" + \
+    "PortailAS/assure?_nfpb=true&_pageLabel=as_login_page"
 
     form =
         "connexioncompte_2numSecuriteSociale": requiredFields.login


    $ = cheerio.load data.html

    $('#tabDerniersPaiements tbody tr').each ->
        date = $($(this).find('td').get(0)).text()
        subtype = $($(this).find('td').get(1)).text()

        amount = $($(this).find('td').get(2)).text()
        amount = amount.replace(' euros', '').replace(',','.')
        amount = parseFloat amount

        # Get the details url
        detailsUrl = $($(this).find('td a').get(1)).attr('href')
        # Remove the unecessary port to avoid buggy request
        detailsUrl = detailsUrl.replace(':443', '')

        bill =
            amount: amount
            type: 'health'
            subtype: subtype
            date: moment date, 'DD/MM/YYYY'
            vendor: 'Ameli'
            detailsUrl: detailsUrl

        healthBills.fetched.push bill if bill.amount?

    # For each bill, get the pdf
    async.each healthBills.fetched, getPdf, (err) ->
        next err


# Retrieve pdf url
getPdf = (bill, callback) ->
    detailsUrl = bill.detailsUrl

    options =
        method: 'GET'
        jar: true
        strictSSL: false
        url: detailsUrl

    # Request to get the pdf url
    request options, (err, res, body) ->
        if err? or res.statusCode isnt 200
            callback new Error 'Pdf not found'
        else
            html = cheerio.load body
            pdfUrl = "https://assure.ameli.fr"
            pdfUrl += html('.r_lien_pdf').attr('href')
            # Remove all the dirty escape characters...
            pdfUrl = pdfUrl.replace(/(?:\r\n|\r|\n|\t)/g, '')
            bill.pdfurl = pdfUrl
            callback null


buildNotification = (requiredFields, healthBills, data, next) ->

logIn = (requiredFields, billInfos, data, next) ->

    loginUrl = "https://assure.ameli.fr/PortailAS/appmanager/PortailAS/" + \
    "assure?_somtc=true"

    submitUrl = "https://assure.ameli.fr/PortailAS/appmanager/PortailAS/" + \
    "assure?_nfpb=true&_windowLabel=connexioncompte_2&connexioncompte_2_" + \
