Opened 6 days ago

Last modified 6 days ago

#138 assigned defect

Multiple hazards bug

Reported by: Chris B Owned by:
Priority: high Version: 3.x
Keywords: chemical hazards Cc: chris.bernabe@…

Description (last modified by Mike Dewhirst)

Here is an excerpt from an error generated when the software was attempting to add a hazard ...

line 1643, in add_hazard ... chemhazard = ChemicalHazards.objects.get_or_create(

Local Vars

Variable Value
hazard <Hazard: H317 Skin sensitization: Category 1: May cause an allergic skin reaction>
hazards <QuerySet [<Hazard: H317 Skin sensitization: Category 1: May cause an allergic skin reaction>, <Hazard: H317 Skin sensitization: Category 1A: May cause an allergic skin reaction>, <Hazard: H317 Skin sensitization: Category 1B: May cause an allergic skin reaction>]>
hazlabel 'Skin sensitization: Category 1'

In theory this should work in all circumstances because 'get_or_create' should return an existing chemical hazard rather than create one. In practice however, if there is more than one hazard with the same identifying characteristics, the 'get' part of 'get_or_create' complains instead of returning it. As can be seen in the error excerpt, there were three such hazards.

We need to respect user requirements here. Because there can be multiple hazards with the same Hazard Code but different Hazard Category (eg., 2, 2A, 2B etc) we cannot just arbitrarily decide to select one. Even if Australia elects to settle on, say 2A for a category, next week it might be simplified by the regulator to say, Category 2.

The fix will therefore permit as many hazards as desired/added by the user and the software will display them all in reports and permit the user to delete those which are eventually unnecessary.

The software however, will now look separately for the Hazard Code and if discovered, won't try to add another.

Change History (2)

comment:1 by Mike Dewhirst, 6 days ago

Reporter: changed from Mike Dewhirst to Chris B

comment:2 by Mike Dewhirst, 6 days ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.