I suggest you get a few tests done.
The kind of symptom that you described is generally suggestive of a bleeding from the upper urinary tract
, and when this bleeding stops and forms a clot and come down the ureters (which are hollow tubes which drain the urine from the kidneys to the urinary bladder
) this kind of a worm like stringy clot comes out.
Ideally you should have at least a complete urine examination, an ultrasound
of your kidneys and bladder, and we can take it from there. You might require a CT scan
depending on what are the findings on these initial investigations.
Hope I have been able to help you.