Example #1
0
def formulation(request, formulation_id, backend_name="django"):
    backend = get_backend(backend_name)

    drug_searcher = DrugSearcher(backend)
    rows = drug_searcher.get_prices_for_formulation_with_id(formulation_id)

    # Don't like that, but results is being changed in the constructor of the table.
    rows_graph = deepcopy(rows)

    formulation_name = drug_searcher.get_formulation_name_with_id(formulation_id)
    formulation_msh = drug_searcher.get_formulation_msh_with_id(formulation_id)

    formulation_table = FormulationTable(rows)
    formulation_graph = FormulationGraph(rows_graph, formulation_msh)

    search_form = SearchForm()

    products_href = reverse('formulation_products', args=[str(formulation_id),
                                                           backend_name])
    formulation_tab = get_formulation_tab(None)
    similar_products_tab = get_similar_products_tab(products_href)
    menu = Menu([formulation_tab, similar_products_tab])

    price_popups = []
    for price_fields in rows:
        price_popups.append(PricePopup(price_fields))
                
    return render_to_response('formulation.html',
                              {'formulation_table': formulation_table,
                               'formulation_graph': formulation_graph,
                               'formulation_msh': formulation_msh,
                               'price_popups': price_popups,
                               'menu' : menu,
                               'search_form' : search_form,
                               'sub_title' : formulation_name},RequestContext(request))
Example #2
0
def formulation_products(request, formulation_id, backend_name="django"):
    backend = get_backend(backend_name)

    drug_searcher = DrugSearcher(backend)

    rows = drug_searcher.get_product_registrations_based_on_formulation_with_id(
        formulation_id)

    supplier_table = ProductTable(rows)
    search_form = SearchForm()

    formulation_name = drug_searcher.get_formulation_name_with_id(
        formulation_id)
    formulation_href = reverse('formulation-by-id',
                               args=[str(formulation_id), backend_name])

    formulation_tab = get_formulation_tab(formulation_href)
    similar_products_tab = get_similar_products_tab()
    menu = Menu([formulation_tab, similar_products_tab])

    return render_to_response(
        'formulation_products.html', {
            'supplier_table': supplier_table,
            'search_form': search_form,
            'menu': menu,
            'sub_title': "Formulation",
            'sub_sub_title': formulation_name,
        }, RequestContext(request))
Example #3
0
def search(request):
    search_term = request.GET.get('search', None)

    initial_form_values = {'search': search_term}

    if search_term is not None:
        backend_name = request.GET.get('backend', "django")

        backend = get_backend(backend_name)

        drug_searcher = DrugSearcher(backend)
        rows = drug_searcher.get_formulations_that_match(search_term)

        results_table = ResultsTable(rows, search_term)
        search_results_tab = get_search_results_tab()
        menu = Menu([search_results_tab])
    else:
        menu = None
        results_table = None

    search_form = SearchForm(initial=initial_form_values)

    return render_to_response('search.html', {
        'search_form': search_form,
        'results_table': results_table,
        'menu': menu
    }, RequestContext(request))
Example #4
0
def search(request):
    search_term = request.GET.get('search', None)
    
    initial_form_values = {'search' : search_term} 

    if search_term is not None:
        backend_name = request.GET.get('backend', "django")
        
        backend = get_backend(backend_name)
            
        drug_searcher = DrugSearcher(backend)
        rows = drug_searcher.get_formulations_that_match(search_term)
    
        results_table = ResultsTable(rows, search_term)
        search_results_tab = get_search_results_tab()
        menu = Menu([search_results_tab])
    else:
        menu = None
        results_table = None
        
    search_form = SearchForm(initial = initial_form_values)
    
    return render_to_response('search.html', 
                              {'search_form': search_form,
                               'results_table': results_table,
                               'menu' : menu},RequestContext(request))
Example #5
0
def formulation_products(request, formulation_id, backend_name="django"):
    backend = get_backend(backend_name)
    
    drug_searcher = DrugSearcher(backend)
    
    rows = drug_searcher.get_product_registrations_based_on_formulation_with_id(formulation_id)
    
    supplier_table = ProductTable(rows)
    search_form = SearchForm()

    formulation_name = drug_searcher.get_formulation_name_with_id(formulation_id)
    formulation_href = reverse('formulation-by-id', args=[str(formulation_id),
                                                    backend_name])

    formulation_tab = get_formulation_tab(formulation_href)
    similar_products_tab = get_similar_products_tab()
    menu = Menu([formulation_tab, similar_products_tab])

    return render_to_response('formulation_products.html',
                              {'supplier_table' : supplier_table,
                               'search_form' : search_form,
                               'menu' : menu,
                               'sub_title' : "Formulation",
                               'sub_sub_title' : formulation_name,
                               },
                               RequestContext(request))
Example #6
0
def supplier(request, formulation_id, backend_name="django"):
    backend = get_backend(backend_name)
    
    drug_searcher = DrugSearcher(backend)
    
    rows = drug_searcher.get_products_based_on_formulation_with_id(formulation_id)
    
    supplier_table = SupplierTable(rows)
    
    return render_to_response('formulation_suppliers.html',
                              {'supplier_table':supplier_table})
Example #7
0
def supplier_catalogue(request, supplier_id, backend_name="django"):
    backend = get_backend(backend_name)

    drug_searcher = DrugSearcher(backend)
    registrations = drug_searcher.get_registrations_from_supplier_with_id(supplier_id)
    search_form = SearchForm()
    catalogue_tab = get_catalogue_tab()
    menu = Menu([catalogue_tab])
    supplier_name = drug_searcher.get_name_of_supplier_with_id(supplier_id)
    
    return render_to_response('supplier_catalogue.html',
                              {'registrations': registrations,
                               'menu': menu,
                               'search_form': search_form,
                               'sub_title': supplier_name,
                               'backend': backend_name},RequestContext(request))
Example #8
0
def supplier_catalogue(request, supplier_id, backend_name="django"):
    backend = get_backend(backend_name)

    drug_searcher = DrugSearcher(backend)
    registrations = drug_searcher.get_registrations_from_supplier_with_id(
        supplier_id)
    search_form = SearchForm()
    catalogue_tab = get_catalogue_tab()
    menu = Menu([catalogue_tab])
    supplier_name = drug_searcher.get_name_of_supplier_with_id(supplier_id)

    return render_to_response(
        'supplier_catalogue.html', {
            'registrations': registrations,
            'menu': menu,
            'search_form': search_form,
            'sub_title': supplier_name,
            'backend': backend_name
        }, RequestContext(request))
Example #9
0
def formulation(request, formulation_id, backend_name="django"):
    backend = get_backend(backend_name)

    drug_searcher = DrugSearcher(backend)
    rows = drug_searcher.get_prices_for_formulation_with_id(formulation_id)

    # Don't like that, but results is being changed in the constructor of the table.
    rows_graph = deepcopy(rows)

    formulation_name = drug_searcher.get_formulation_name_with_id(
        formulation_id)
    formulation_msh = drug_searcher.get_formulation_msh_with_id(formulation_id)

    formulation_table = FormulationTable(rows)
    formulation_graph = FormulationGraph(rows_graph, formulation_msh)

    search_form = SearchForm()

    products_href = reverse('formulation_products',
                            args=[str(formulation_id), backend_name])
    formulation_tab = get_formulation_tab(None)
    similar_products_tab = get_similar_products_tab(products_href)
    menu = Menu([formulation_tab, similar_products_tab])

    price_popups = []
    for price_fields in rows:
        price_popups.append(PricePopup(price_fields))

    return render_to_response(
        'formulation.html', {
            'formulation_table': formulation_table,
            'formulation_graph': formulation_graph,
            'formulation_msh': formulation_msh,
            'price_popups': price_popups,
            'menu': menu,
            'search_form': search_form,
            'sub_title': "Formulation",
            'sub_sub_title': formulation_name
        }, RequestContext(request))
Example #10
0
def formulation(request, formulation_id, backend_name="django"):
    backend = get_backend(backend_name)

    drug_searcher = DrugSearcher(backend)
    rows = drug_searcher.get_prices_for_formulation_with_id(formulation_id)

    # Don't like that, but results is being changed in the constructor of the table.
    from copy import deepcopy
    rows_graph = deepcopy(rows)

    formulation_name = drug_searcher.get_formulation_name_with_id(formulation_id)
    formulation_msh = drug_searcher.get_formulation_msh_with_id(formulation_id)

    formulation_table = FormulationTable(rows)
    formulation_graph = FormulationGraph(rows_graph, formulation_msh)

    results_href = None

    referer = request.META.get('HTTP_REFERER')

    if referer is not None:
        referer_parts = re.sub('^https?:\/\/', '', referer).split('/')

        referer_host = referer_parts[0]

        if referer_host == '' or referer_host == request.META.get('HTTP_HOST'):
            results_href = referer

    search_form = SearchForm()

    return render_to_response('formulation.html',
                              {'formulation_table': formulation_table,
                               'formulation_graph': formulation_graph,
                               'formulation_name': formulation_name,
                               'formulation_msh': formulation_msh,
                               'results_href' : results_href,
                               'search_form' : search_form});
 def setUp(self):
     test_backend = TestBackend()
     self.drug_searcher = DrugSearcher(test_backend)
class DrugSearcherTest(SarpamTestCase):
    def setUp(self):
        test_backend = TestBackend()
        self.drug_searcher = DrugSearcher(test_backend)

    def test_prices_converted_to_usd(self):
        self.set_up_exchange_rate_for_nad()

        fob_price_in_nad = 58.64
        landed_price_in_nad = 67.44

        exchange_rate = 0.12314
        issue_unit = 500

        fob_price_in_usd = (fob_price_in_nad * exchange_rate) / issue_unit
        landed_price_in_usd = (landed_price_in_nad *
                               exchange_rate) / issue_unit

        rows = self.drug_searcher.get_formulations_that_match("amitriptyline")

        row = rows[0]

        self.assertEquals(fob_price_in_usd, row['fob_price'])
        self.assertEquals(landed_price_in_usd, row['landed_price'])

    def test_no_error_when_issue_unit_none(self):
        rows = self.drug_searcher.get_formulations_that_match(
            "issue unit none")
        row = rows[0]

        self.assertEquals(None, row['fob_price'])
        self.assertEquals(None, row['landed_price'])

    def test_prices_for_amoxycillin_is_converted_to_usd(self):
        self.set_up_exchange_rate_for_nad()
        self.set_up_exchange_rate_for_usd()

        fob_price_in_nad = 58.64
        landed_price_in_nad = 67.44

        exchange_rate = 0.12314
        issue_unit = 500

        fob_price_in_usd = (fob_price_in_nad * exchange_rate) / issue_unit
        landed_price_in_usd = (landed_price_in_nad *
                               exchange_rate) / issue_unit

        rows = self.drug_searcher.get_prices_for_formulation_with_id(
            "amitriptyline")
        row = rows[0]

        self.assertEquals(fob_price_in_usd, row['fob_price'])
        self.assertEquals(landed_price_in_usd, row['landed_price'])

    def test_gets_formulation_name_from_backend_given_id(self):
        name = self.drug_searcher.get_formulation_name_with_id(1)
        self.assertEquals("amitriptyline 25mg tablet", name)

    def get_formulations_that_match_amox(self):
        self.set_up_exchange_rate_for_eur()
        self.set_up_exchange_rate_for_nad()
        self.set_up_exchange_rate_for_usd()

        return self.drug_searcher.get_formulations_that_match("amox")

    def test_matching_formulations_grouped_by_formulation_name(self):
        formulations = self.get_formulations_that_match_amox()

        self.assertEquals(3, len(formulations))
        amoxycillin125 = formulations[0]
        amoxycillin500 = formulations[1]
        tamoxifen = formulations[2]

        self.assertEquals(amoxycillin125['formulation'],
                          "amoxycillin 125mg/5ml suspension")
        self.assertEquals(amoxycillin500['formulation'],
                          "amoxycillin 500mg tablet/capsule")
        self.assertEquals(tamoxifen['formulation'], "tamoxifen 20mg tablet")

    def test_matching_formulations_include_median_fob_price(self):
        formulations = self.get_formulations_that_match_amox()

        # fob prices are:
        # Angola None
        # DRC 0.004
        # Namibia 0.005
        # Botswana 0.009

        amoxycillin125 = formulations[0]

        fob_price_for_namibia = 4.36
        nad_exchange_rate = 0.12314
        issue_unit = 100

        expected_median = (fob_price_for_namibia *
                           nad_exchange_rate) / issue_unit

        self.assertAlmostEquals(expected_median, amoxycillin125['fob_price'])

    def test_matching_formulations_include_median_landed_price(self):
        formulations = self.get_formulations_that_match_amox()

        amoxycillin125 = formulations[0]

        landed_price_for_namibia = 4.93
        nad_exchange_rate = 0.12314
        issue_unit = 100

        expected_median = (landed_price_for_namibia *
                           nad_exchange_rate) / issue_unit

        self.assertAlmostEquals(expected_median,
                                amoxycillin125['landed_price'])

    def test_amitrilon_25_returned_as_product_based_on_amitryptyline(self):
        registrations = self.get_amitrilon_25_registrations()
        self.assertEquals("AMITRILON-25", registrations[0]['product']['name'])
        self.assertEquals("AMITRILON-25", registrations[1]['product']['name'])

    def test_afrifarmacia_and_aspen_returned_as_suppliers_of_amitryptyline(
            self):
        registrations = self.get_amitrilon_25_registrations()

        afrifarmacia = {
            'id': 1,
            'name': u"Afrifármacia, Lda",
            'url': "/suppliers/1/test"
        }
        aspen_pharmacare = {
            'id': 2,
            'name': "Aspen Pharmacare Ltd, S.A",
            'url': "/suppliers/2/test"
        }

        self.assertEquals(afrifarmacia, registrations[0]['supplier'])
        self.assertEquals(aspen_pharmacare, registrations[1]['supplier'])

    def test_stallion_laboratories_returned_as_manufacturer_of_amitryptyline(
            self):
        registrations = self.get_amitrilon_25_registrations()

        stallion = {'name': "STALLION LABORATORIES LTD-INDIA"}

        self.assertEquals(stallion, registrations[0]['manufacturer'])
        self.assertEquals(stallion, registrations[1]['manufacturer'])

    def get_amitrilon_25_registrations(self):
        registrations = self.drug_searcher.get_product_registrations_based_on_formulation_with_id(
            1)

        return registrations

    def test_amitrilon_25_returned_as_product_supplied_by_afrifarmacia(self):
        products = self.drug_searcher.get_products_from_supplier_with_id(1)

        amitrilon25 = {}
        amitrilon25['product'] = "AMITRILON-25"
        amitrilon25['formulation_name'] = "amitriptyline 25mg tablet"
        amitrilon25['formulation_url'] = "/formulation/1/test"

        expected_products = [amitrilon25]
        self.assertEquals(expected_products, products)
 def setUp(self):
     test_backend = TestBackend()
     self.drug_searcher = DrugSearcher(test_backend)
class DrugSearcherTest(SarpamTestCase):
    def setUp(self):
        test_backend = TestBackend()
        self.drug_searcher = DrugSearcher(test_backend)
    
    def test_prices_converted_to_usd(self):
        self.setup_exchange_rate_for_nad()
        
        fob_price_in_nad = 58.64
        landed_price_in_nad = 67.44
        
        exchange_rate = 0.12314
        issue_unit = 500
        
        fob_price_in_usd = (fob_price_in_nad * exchange_rate) / issue_unit
        landed_price_in_usd = (landed_price_in_nad * exchange_rate) / issue_unit
         
        rows = self.drug_searcher.get_formulations_that_match("amitriptyline")
        
        row = rows[0]
        
        self.assertEquals(fob_price_in_usd, row['fob_price'])
        self.assertEquals(landed_price_in_usd, row['landed_price'])

    def test_no_error_when_issue_unit_none(self):
        rows = self.drug_searcher.get_formulations_that_match("issue unit none")
        row = rows[0]

        self.assertEquals(None, row['fob_price'])
        self.assertEquals(None, row['landed_price'])
        
    def test_prices_for_amoxycillin_is_converted_to_usd(self):
        self.setup_exchange_rate_for_nad()
        
        fob_price_in_nad = 58.64
        landed_price_in_nad = 67.44
        
        exchange_rate = 0.12314
        issue_unit = 500
        
        fob_price_in_usd = (fob_price_in_nad * exchange_rate) / issue_unit
        landed_price_in_usd = (landed_price_in_nad * exchange_rate) / issue_unit
        
        rows = self.drug_searcher.get_prices_for_formulation_with_id("amitriptyline")
        row = rows[0]
        
        self.assertEquals(fob_price_in_usd, row['fob_price'])
        self.assertEquals(landed_price_in_usd, row['landed_price'])

    def test_gets_formulation_name_from_backend_given_id(self):
        name = self.drug_searcher.get_formulation_name_with_id(1)
        self.assertEquals("amitriptyline 25mg tablet", name)

    def get_formulations_that_match_amox(self):
        self.setup_exchange_rate_for_eur()
        self.setup_exchange_rate_for_nad()
        self.setup_exchange_rate_for_usd()
        
        return self.drug_searcher.get_formulations_that_match("amox")
        

    def test_matching_formulations_grouped_by_formulation_name(self):
        formulations = self.get_formulations_that_match_amox()

        self.assertEquals(3, len(formulations))
        amoxycillin125 = formulations[0]
        amoxycillin500 = formulations[1]
        tamoxifen = formulations[2]

        self.assertEquals(amoxycillin125['formulation'], 
                          "amoxycillin 125mg/5ml suspension")
        self.assertEquals(amoxycillin500['formulation'],
                          "amoxycillin 500mg tablet/capsule")
        self.assertEquals(tamoxifen['formulation'],
                          "tamoxifen 20mg tablet")

    def test_matching_formulations_include_median_fob_price(self):
        formulations = self.get_formulations_that_match_amox()

        # fob prices are:
        # Angola None
        # DRC 0.004
        # Namibia 0.005
        # Botswana 0.009

        amoxycillin125 = formulations[0]

        fob_price_for_namibia = 4.36
        nad_exchange_rate = 0.12314
        issue_unit = 100

        expected_median = (fob_price_for_namibia * nad_exchange_rate) / issue_unit

        self.assertAlmostEquals(expected_median, amoxycillin125['fob_price'])

    def test_matching_formulations_include_median_landed_price(self):
        formulations = self.get_formulations_that_match_amox()

        amoxycillin125 = formulations[0]

        landed_price_for_namibia = 4.93
        nad_exchange_rate = 0.12314
        issue_unit = 100

        expected_median = (landed_price_for_namibia * nad_exchange_rate) / issue_unit

        self.assertAlmostEquals(expected_median, amoxycillin125['landed_price'])

    def test_none_returned_for_median_of_empty_list(self):
        empty_list = []
        median = self.drug_searcher.get_median(empty_list)
        self.assertEquals(None, median)

    def test_middle_value_returned_for_median_of_list_with_odd_length(self):
        price_list = [0.09, 0.05, 0.14]
        median = self.drug_searcher.get_median(price_list)
        self.assertAlmostEquals(0.09, median)
        
    def test_average_of_middle_values_returned_for_median_of_list_with_even_length(self):
        price_list = [0.04, 0.05, 0.14, 0.07]
        median = self.drug_searcher.get_median(price_list)
        self.assertAlmostEquals(0.06, median)

    def test_none_values_ignored_when_calculating_median_fob_price_of_list(self):
        price_list = [{'fob_price':None, 'landed_price':None},
                      {'fob_price':0.09, 'landed_price':None}, 
                      {'fob_price':None, 'landed_price':None},
                      {'fob_price':0.05, 'landed_price':None},
                      {'fob_price':None, 'landed_price':None}, 
                      {'fob_price':0.14, 'landed_price':None}]
        median = self.drug_searcher.get_median_prices(price_list)
        self.assertAlmostEquals(0.09, median[0])

    def test_none_values_ignored_when_calculating_median_landed_price_of_list(self):
        price_list = [{'landed_price':None, 'fob_price':None},
                      {'landed_price':0.09, 'fob_price':None}, 
                      {'landed_price':None, 'fob_price':None},
                      {'landed_price':0.05, 'fob_price':None},
                      {'landed_price':None, 'fob_price':None}, 
                      {'landed_price':0.14, 'fob_price':None}]
        median = self.drug_searcher.get_median_prices(price_list)
        self.assertAlmostEquals(0.09, median[1])

    def get_amitrilon_25(self):
        products = self.drug_searcher.get_products_based_on_formulation_with_id(1)
        
        amitrilon25 = products[0]
        
        return amitrilon25

    def test_amitrilon_25_returned_as_product_based_on_amitryptyline(self):
        amitrilon25 = self.get_amitrilon_25()
        self.assertEquals("AMITRILON-25", amitrilon25['product'])

    def test_afrifarmacia_returned_as_supplier_of_amitryptyline(self):
        amitrilon25 = self.get_amitrilon_25()
        self.assertEquals(u"Afrifármacia, Lda, Aspen Pharmacare Ltd, S.A", 
                          amitrilon25['suppliers'])
class DrugSearcherTest(SarpamTestCase):
    def setUp(self):
        test_backend = TestBackend()
        self.drug_searcher = DrugSearcher(test_backend)
    
    def test_prices_converted_to_usd(self):
        self.set_up_exchange_rate_for_nad()
        
        fob_price_in_nad = 58.64
        landed_price_in_nad = 67.44
        
        exchange_rate = 0.12314
        issue_unit = 500
        
        fob_price_in_usd = (fob_price_in_nad * exchange_rate) / issue_unit
        landed_price_in_usd = (landed_price_in_nad * exchange_rate) / issue_unit
         
        rows = self.drug_searcher.get_formulations_that_match("amitriptyline")
        
        row = rows[0]
        
        self.assertEquals(fob_price_in_usd, row['fob_price'])
        self.assertEquals(landed_price_in_usd, row['landed_price'])

    def test_no_error_when_issue_unit_none(self):
        rows = self.drug_searcher.get_formulations_that_match("issue unit none")
        row = rows[0]

        self.assertEquals(None, row['fob_price'])
        self.assertEquals(None, row['landed_price'])
        
    def test_prices_for_amoxycillin_is_converted_to_usd(self):
        self.set_up_exchange_rate_for_nad()
        self.set_up_exchange_rate_for_usd()
        
        fob_price_in_nad = 58.64
        landed_price_in_nad = 67.44
        
        exchange_rate = 0.12314
        issue_unit = 500
        
        fob_price_in_usd = (fob_price_in_nad * exchange_rate) / issue_unit
        landed_price_in_usd = (landed_price_in_nad * exchange_rate) / issue_unit
        
        rows = self.drug_searcher.get_prices_for_formulation_with_id("amitriptyline")
        row = rows[0]
        
        self.assertEquals(fob_price_in_usd, row['fob_price'])
        self.assertEquals(landed_price_in_usd, row['landed_price'])

    def test_gets_formulation_name_from_backend_given_id(self):
        name = self.drug_searcher.get_formulation_name_with_id(1)
        self.assertEquals("amitriptyline 25mg tablet", name)

    def get_formulations_that_match_amox(self):
        self.set_up_exchange_rate_for_eur()
        self.set_up_exchange_rate_for_nad()
        self.set_up_exchange_rate_for_usd()
        
        return self.drug_searcher.get_formulations_that_match("amox")
        

    def test_matching_formulations_grouped_by_formulation_name(self):
        formulations = self.get_formulations_that_match_amox()

        self.assertEquals(3, len(formulations))
        amoxycillin125 = formulations[0]
        amoxycillin500 = formulations[1]
        tamoxifen = formulations[2]

        self.assertEquals(amoxycillin125['formulation'], 
                          "amoxycillin 125mg/5ml suspension")
        self.assertEquals(amoxycillin500['formulation'],
                          "amoxycillin 500mg tablet/capsule")
        self.assertEquals(tamoxifen['formulation'],
                          "tamoxifen 20mg tablet")

    def test_matching_formulations_include_median_fob_price(self):
        formulations = self.get_formulations_that_match_amox()

        # fob prices are:
        # Angola None
        # DRC 0.004
        # Namibia 0.005
        # Botswana 0.009

        amoxycillin125 = formulations[0]

        fob_price_for_namibia = 4.36
        nad_exchange_rate = 0.12314
        issue_unit = 100

        expected_median = (fob_price_for_namibia * nad_exchange_rate) / issue_unit

        self.assertAlmostEquals(expected_median, amoxycillin125['fob_price'])

    def test_matching_formulations_include_median_landed_price(self):
        formulations = self.get_formulations_that_match_amox()

        amoxycillin125 = formulations[0]

        landed_price_for_namibia = 4.93
        nad_exchange_rate = 0.12314
        issue_unit = 100

        expected_median = (landed_price_for_namibia * nad_exchange_rate) / issue_unit

        self.assertAlmostEquals(expected_median, amoxycillin125['landed_price'])

    def test_amitrilon_25_returned_as_product_based_on_amitryptyline(self):
        registrations = self.get_amitrilon_25_registrations()
        self.assertEquals("AMITRILON-25", registrations[0]['product']['name'])
        self.assertEquals("AMITRILON-25", registrations[1]['product']['name'])

    def test_afrifarmacia_and_aspen_returned_as_suppliers_of_amitryptyline(self):
        registrations = self.get_amitrilon_25_registrations()
        
        afrifarmacia = {'id': 1, 'name':u"Afrifármacia, Lda",
            'url':"/suppliers/1/test"}
        aspen_pharmacare = {'id': 2, 'name':"Aspen Pharmacare Ltd, S.A",
            'url':"/suppliers/2/test"}
        
        self.assertEquals(afrifarmacia, registrations[0]['supplier'])
        self.assertEquals(aspen_pharmacare, registrations[1]['supplier'])
        
    def test_stallion_laboratories_returned_as_manufacturer_of_amitryptyline(self):
        registrations = self.get_amitrilon_25_registrations()
        
        stallion = {'name':"STALLION LABORATORIES LTD-INDIA"}
        
        self.assertEquals(stallion, registrations[0]['manufacturer'])
        self.assertEquals(stallion, registrations[1]['manufacturer'])

    def get_amitrilon_25_registrations(self):
        registrations = self.drug_searcher.get_product_registrations_based_on_formulation_with_id(1)
        
        return registrations

    def test_amitrilon_25_returned_as_product_supplied_by_afrifarmacia(self):
        products = self.drug_searcher.get_products_from_supplier_with_id(1)

        amitrilon25 = {}
        amitrilon25['product'] = "AMITRILON-25"
        amitrilon25['formulation_name'] = "amitriptyline 25mg tablet"
        amitrilon25['formulation_url'] = "/formulation/1/test"

        expected_products = [amitrilon25]
        self.assertEquals(expected_products, products)