# Can GPT4o do math calculations with chat completion?

I am currently trying to calculate what the copay is. It requires math calculations. Can GPT4o with chat completions do this?

This is what I’m using:

def generate_copay(billingnote, cpt, mdfs):
prompt = f"“”
Given the billing note, CPT Codes for that encounter, the Medical Care Fee Schedule for those CPT codes → determine the copay. Output should be a list of [reasoning, copay (only numeric value)].

``````Billing Note: {billingnote}

CPT Codes: {cpt}

MDFS for CPT Code (in same order as the cpt codes): {mdfs}

Determine Copay

Notes: OV stands for office visit and office visit codes are between 99201 - 99205 or 99212 - 99215. If there are multiple CPT codes, you need to check if the billing note has any information for how much a patient needs to pay for the other CPT codes.

---

Few Examples:

Billing Note: 17, Omega 05/08/2024 02:58:35 PM CDT > No pt resp for OV No auth No referral Texas Childrens Health Plan Star - INN - Benefits are covered @ 100% benefit level. Note: Dr. Darling is INN

CPT Codes: 69210, 99214

MDFS: 48.2, 128.39

Reasoning: Patient has no responsibility, copay should be zero.

Copay: 0

----

Billing Note: 17, Omega 05/10/2024 10:37:39 AM CDT > Co pay \$ 15 for ov 30% pt resp for codes Auth is required through NIA & can be obtained by calling @ 877-687-1187. Authorized referral Dr. Ambetter Value Medical Group is PCP. Ambetter (Focused VALUE Silver) -INN- Benefits subject to ded covered @ 70% for Codes benefit level & Applied towards out of pocket \$ 1350 met \$ 56.56 for 100% benefit level. Note ; Dr. Darling is INN

CPT Codes: 99205

MDFS: 221.23

Reasoning: Co pay is \$15 for office visit and 30% of the MDFS for other codes. Since the only code is 99205, which is an office visit, the copay should be 15.

Copay: 15

---

Billing Note: 17, Omega 05/09/2024 09:36:15 AM CDT > Co pay \$ 50 for OV No auth No referral BCBS (PPO)-INN- Co pay \$ 50 & Applied towards out of pocket \$ 8000 met \$ 4,828.63 for 100% benefit level. Note: Dr Darling is INN

CPT Codes: 99214, 69210

MDFS: 128.39, 48.2

Reasoning: Co pay \$50 for OV. Since there is no other information about the other CPT code, the copay should be 50.

Copay: 50

---

Billing Note: 17, Omega 05/09/2024 09:54:36 AM CDT > Co pay \$ 20 for OV + Codes Authorization is required & can be obtained by calling @ 800-230-6138. Authorized referral is required & Dr.WANG-GOR, MIRANDA is PCP Renaissance Cigna Preferred Medicare (HMO) -INN- Applied towards out of pocket \$ 3400 met \$ 0 for 100% benefit level Note : Dr. Darling is INN

CPT Codes: 69210, 99204

MDFS: 48.2, 167.58

Reasoning: Co pay \$ 20 for OV + Codes so the copay should be 20

Copay: 20

---

Billing Note: 17, Omega 05/08/2024 02:16:48 PM CDT > Co pay \$ 60 for OV + 50% for Codes No auth Authorized referral is required but Dr. Nedal M Adi is PCP UHC (Individual Exchange)(HMO) -INN- Benefits subject to no ded covered @ 50% for codes benefit level & Applied towards out of pocket \$ 9100 met \$ 3,484.19 for 100% benefit level Note ; Dr. Darling is INN

CPT Codes: 69210, 69105, 99204

MDFS: 48.2, 148.2, 167.58

Reasoning: The Co pay is \$ 60 for office visit + 50% for Codes. For 99204 (the office visit) it will be \$60. For 69210 and 69105 it will be 50% of their MDFS. 48.2 * .5 = 24.1. 148.2 * .5 = 74.1. 74.1 + 60 + 24.1

Copay: 158.2

---

Billing Note: 17, Omega 05/08/2024 02:18:14 PM CDT > Co pay \$ 35 for OV 100% pt resp for Codes *Auth is required & can be obtained by calling @ 800-218-7508. No referral Ambetter Complete Gold  - INN - Subject to ded \$ 1,450 met \$ 0 for 80% for Codes & Co pay \$ 35, Applied towards out of pocket \$ 7500 met \$ 579.11 for 100% benefit level Note: Dr. Darling is INN

CPT Codes: 42405, 99205

MDFS: 311.22, 221.23

Reasoning: Copay is \$35 for the office visit and 100% of the MDFS for all other codes. 99205 will be 35. 42405 will be 311.22. 35 + 311.22 = 346.22

Copay: 346.22

---

Billing Note: 17, Omega 05/14/2024 08:22:38 AM CDT > "*Co pay 10 for OV + Codes *No auth *No referral UHC Medicare Managecare LPPO- INN- Co pay \$ 10 & Applied towards out of pocket \$ 3500 met \$ 10 for 100% benefit level. Note: Dr .Darling is INN."

CPT Codes: 99204, 92567

MDFS: 167.58, 16.55

Reasoning: Co pay \$10 for OV + Codes so the copay should be 10

Copay: 10

---

Billing Note: 17, Omega 05/14/2024 02:34:14 PM CDT > *No pt resp for OV + Codes *No auth *No referral Medicare + BCBS -INN- subject to MCR ded \$ 240 met infull and Sec covers infull Note.Dr . Darling is INN

CPT Codes: 99204, 69210

MDFS: 167.58, 48.2

Reasoning: Patient has no responsibility, copay should be zero.

Copay: 0
"""

response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a billing assistant for a major healthcare company."},
{"role": "user", "content": prompt}
],
max_tokens=500,
temperature=1
)
``````

Hey gasperjw - Welcome to the community.

You can create a tool called Math Tool which performs specific calculations required by your use case. Make sure you provide proper tool description and params if required and use it with your assistant.

Cheers!