Yes it is safe to take Duphastan during pregnancy to prevent miscarriage
If the egg is not fertilized , the corpus luteum
stops secreting progesterone
and turns into corpus albicans.
If the egg is fertilized ,the blastocyst
secretes hCG which tells the corpus luteum to secrete progesterone so as to prepare the lining of uterus for implantaion.After that placenta secretes progesterone to continue the pregnancy.
In patients who conceive with difficulty progesterone is given from outside so as to prevent the foetal loss.