add this to your map initialisation trigger
Actions
_ Unit Group - Pick every unit in (Units of type Gold Mine) and do (Actions)
_ _ Loop - Actions
_ _ _ Set Int_C = (Int_C + 1)
_ _ _ Set Mine[Int_C] = (Picked unit)
_ _ _ Unit - Set the custom value of (Picked unit) to (Resource quantity contained in (Picked unit))
and create this trigger
Prospecting
_ Events
_ _ Time - Every 0.50 seconds of game time
_ Conditions
_ Actions
_ _ For each (Integer A) from 1 to Int_C, do (Actions)
_ _ _ Loop - Actions
_ _ _ _ If (All Conditions are True) then do (Then Actions) else do (Else Actions)
_ _ _ _ _ If - Conditions
_ _ _ _ _ _ (Custom value of Mine[(Integer A)]) Greater than (Resource quantity contained in Mine[(Integer A)])
_ _ _ _ _ _ (Random integer number between 1 and 1000) Equal to 7
_ _ _ _ _ Then - Actions
_ _ _ _ _ _ Item - Create Gem Fragment at (Position of Mine[(Integer A)])
_ _ _ _ _ _ Hero - Give (Last created item) to Mine[(Integer A)]
_ _ _ _ _ Else - Actions
_ _ _ _ Unit - Set the custom value of Mine[(Integer A)] to (Resource quantity contained in Mine[(Integer A)])
Int_C = integer (default 0), Mine = unit array
Though if the gold mine is neutral, you're not going to get that gem out of there, better off to just create it at the position of the mine and let it automatically place at the side. If you meant create the item in the worker's inventory, I'm not sure how to detect a unit that is carrying gold. You could give the item to the nearest worker, or a worker within range, but that may not select the worker that just left it.
EDIT:
Ah, okay. Here's an updated version that will give the item to the miners, and will only work for miners, not wisps or acolytes. The downside is however that it will not be detected when the worker is issued an order whilst inside the mine, only when they are allowed to "resumeharvesting" by default. Then again, if it's a 0.1% chance of a gem dropping, this will be hardly noticeable. This also removes the necessity of the first trigger.
Prospecting
Events
Unit - A unit Is issued an order targeting an object
Conditions
(Issued order) Equal to (Order(resumeharvesting))
(Random integer number between 1 and 1000) Equal to 7
Actions
Item - Create Gem Fragment at (Position of (Triggering unit))
Hero - Give (Last created item) to (Triggering unit)
....
Though
Harvesting lumber uses the same order string -_-.
If you use this trigger you'll have to add a unit-type condition as well, and make sure that unit type can only harvest gold. ack -_-