The Department of Homeland Security, the agency tasked with caring for undocumented immigrants immediately after they are apprehended, has diverted $45 million in operational funds to go toward medical costs over the past five years, according to data obtained by the Washington Examiner.

The U.S. Border Patrol has diverted $9 million in operational funding in fiscal year 2019, as it has done in each of the four previous years, to instead cover medical screenings and related services for thousands of immigrants.

Border Patrol began transferring the money at the beginning of fiscal year 2015, just as record-high numbers of unaccompanied minors were arriving at the southern border. The Border Patrol, part of Customs and Border Protection, entered into a Medical Services Blanket Purchase Agreement with a contract medical provider in fiscal 2015.

The agreement included screenings and referrals to specialists when necessary. Patients who needed additional medical help were sent to a local medical treatment facility, which was included in the $9 million.

The millions of dollars transferred in 2019 went toward appointments for more than 4,800 immigrants — one-third of whom were part of a family unit — who were sent to a hospital or medical facility for care between Dec. 22, 2018, and Feb. 24.

[Also read: ICE testing 10-year-old migrant girls for pregnancy due to risk of sexual assault]

CBP estimated its agents have spent more than 49,000 hours facilitating medical trips and watching patients while they are in hospitals during this two-month span. The loss of agents working in law enforcement roles is equivalent to the 2,000 hours worked by 25 Border Patrol agents in a year.

Part of the issue for Border Patrol is the need to transport people who arrive in remote regions of the U.S.-Mexico border. For example, the closest Border Patrol station to Antelope Wells is located 95 miles north in Lordsburg, and all migrants who showed up in Antelope Wells — where just one agent is based — must be transported by border agents to Lordsburg.

Border Patrol facilities are also dealing with communicable disease outbreaks, including scabies at the Lordsburg Station.

In late January, Congress passed a funding bill that gave CBP $415 million for humanitarian relief purposes, which includes medical care, transportation, food, and clothing for migrants in its custody. Border Patrol is supposed to turn over people to Immigration and Customs Enforcement within 72 hours of taking them in.