A patient is helped by her relatives while policemen stand guard at the gate of CURE Hospital in Kabul on Thursday. (Reuters)

On Thursday, three Americans were killed in a hospital in Kabul when an Afghan security officer opened fire. Correspondent Tim Craig in Kabul says the attack happened as doctors and nurses were arriving at the hospital, which is run by a Pennsylvania charity.

It's the latest in a wave of violence targeting foreigners in Afghanistan. What appear to be random attacks by Afghan security officials are increasing the pace at which foreigners are leaving Kabul.

A look at recent attacks on foreigners in Kabul:

Afghan security officials stand guard outside the damaged entrance of a Lebanese restaurant Jan. 18. (EPA)

Jan. 17: At least 21 people, including two Americans, were killed in an attack by Taliban insurgents on La Taverna du Liban, a bistro popular with foreign and local elites. A suicide bomber blew himself up outside the restaurant gate, then gunmen entered the busy dining room and started shooting.

(Read Pamela Constable's story of how the attack changed Kabul for foreigners.)

Afghan men walk at the scene where a Swedish journalist was fatally shot in Kabul. (AP)

March 11: Swedish journalist Nils Horner is shot and killed in broad daylight while conducting an interview on the street.

Private guards secure the Serena Hotel in Kabul on March 21. (EPA)

March 20: Four teens armed with pistols and disguised as guests enter the posh Serena Hotel and open fire hours later. Nine people are killed.

Foreigners take refuge behind a generator after being evacuated from a guesthouse in Kabul. (AFP/Getty Images)

March 28: Taliban gunmen attack the offices of U.S.-based nonprofit Roots of Peace. After a several-hour standoff, 25 foreign residents of the charity's guesthouse were released after Afghan forces killed the four attackers. An Afghan girl was killed during the attack. This also started with a suicide bombing.

This bullet-riddled vehicle was carrying the two journalists. (EPA)

April 4: Anja Niedringhaus, a photographer for the Associated Press, was killed and AP reporter Kathy Gannon was wounded when a police officer walked up to a car they were in and opened fire.

(Check out some of Niedringhaus's amazing photographs.)

April 24: An Afghan security official turns his gun on medical staff at a charity-run hotel in Kabul, killing three Americans. The gunmen unsuccessfully tried to commit suicide and was arrested.