# Gestational age and expected due date

I was wondering if there are any docs that have figured out how to make a snippet that allows you to figure out gestational age (expressed as weeks and days) and expected due date from a last menstrual period date.

I think its possible to use the formula function just not sure how to use a date in it to calculate another date

1 Like

Hey @Doc_Krieger
Does this work?
I had to look up the formulas Last menstrual period date: {formdate: M/D/YY; name=LMP}
{GA=datetimediff({time: YYYY-MM-DD; at={=LMP}; pattern=M/D/YY}, {time: YYYY-MM-DD}, "D")}Gestational age: {=floor(GA/7)} weeks {=remainder(GA,7)} days
Expected due date: {time: M/D/YYYY; at={=LMP}; shift=+280D; pattern=M/D/YY}

1 Like

That's awesome! Thank you so much. This will make my life so much easier!

Is it possible to similarly make a snippet for GA + EDD based on the patient's first-term ultrasound? I'll see if I cant make it work but just curious

Hi @Doc_Krieger, I missed your last question.
Can you share the formula you'll use to calculate GA and EDD from the patient's first-term ultrasound?

actually made it myself, here it is if anyone else is looking for it:

EDD: {formdate: YYYY-MMM-DD; name=EDD}
{LMP=({time: YYYY-MMM-DD; at={=EDD}; shift=-280D; pattern=YYYY-MMM-DD})}{GA=datetimediff({time: YYYY-MM-DD; at={=LMP}; pattern=YYYY-MMM-DD}, {time: YYYY-MM-DD}, "D")}GA: {=floor(GA/7)} weeks {=remainder(GA,7)} days

1 Like

Hi all,
Just starting to use TextBlaze in my EMR so my Programming skill set is currently weak. Is there a way to modify this and enter the days and weeks (from and Ultrasound CRL) and have it CALC an EDD?

@Brian_Haley does this one help?

Date from: {formdate: YYYY-MM-DD; name=from}
Weeks: {formtext: name=weeks}
Days: {formtext: name=days}
EED: {=datetimeformat(datetimeadd(from, -weeks*7-days, "D"), "MMM D, YYYY")}

1 Like

yes with some slight modification that you led me to. Thanks!

2 Likes

US date: {formdate: YYYY-MMM-DD; name=us_date}
GA per US: {formtext: name=weeks}w {formtext: name=days}d
{TOTAL_DAYS=(weeks * 7) + days}{LMP=({time: YYYY-MMM-DD; at={=us_date}; shift=-{=TOTAL_DAYS}D; pattern=YYYY-MMM-DD})}EDD: {=({time: YYYY-MMM-DD; at={=LMP}; shift=+280D; pattern=YYYY-MMM-DD})}

Just in case someone else looking for the same.
The above should calculate EDD based on the first US gestational age.

1 Like