first of all you need to evacuate immediately for this you can take dulcolax
or glycerine suppository or proctaclys.
if you have severe faecal impaction
then go for rectal enema
of 150ml olive oil followed by breaking of faecal masses manually with gloves covered fingers and then you can take tab prostigmine 15 mg for few weeks.
to correct your bowel habit you should take proper high residue diet, isaphgul or softovac daily and should drink plenty of water every day, do some yoga
and exercise every day.
for deworming you can take albendazole
400mg once and repeat it after 14 days.
wish you all the best.