Can I contribute the full IRS deduction for 2023 before the medical plan ends July 31, 2023?

My high deductible medical plan ends 7/31/2023.  Can I contribute the full IRS deduction for my HSA account before then or would I have to be in the medical plan the full year to be eligible to contribute the full amount to my HSA account?