Nurses, hospitals reach agreement; strike avoided