The drug at the centre of an inquest into six epilepsy deaths was made at a plant in India that was investigated for significant quality control issues in 2017.
The generic drug company Mylan uses a manufacturing facility in Nashik, in the west Indian state of Maharashtra, to manufacture and test Logem, a generic form of the anti-epileptic drug lamotrigine, sold in New Zealand.
After the US Food and Drug Administration (FDA) warned Mylan about violating quality standards - including "missing, deleted and lost data" - New Zealand's medical safety watchdog Medsafe did its own investigation.
Medsafe's investigation closed in July 2017 and it decided that because there was "no evidence to suggest a direct quality or safety impact" a product recall was not required.
Medsafe didn't tell Pharmac about the quality control issues at the plant which manufactures Logem, and in August 2018 Pharmac signed a deal to make Logem the only funded brand of lamotrigine in New Zealand.
The deal meant more than 10,000 people taking lamotrigine had to switch brands, in a move Pharmac made to try to save $30 million over five years.
Today Medsafe takes the stand at an inquest by the Chief Coroner into the deaths of six people, who died after switching from their original brands of lamotrigine to the Logem generic.
Pharmac will give evidence on Wednesday.
There is no evidence yet to show that the switch in medications led to any of the six deaths being investigated by the coroner, nor that the Logem generic is inferior to the two other brands patients had been using.
Pharmac has stressed that people who have been prescribed Logem should not stop taking it.
"For most people taking it, Logem works in the same way as the other two lamotrigine brands," Pharmac's director of operations Lisa Williams said. "Logem has the same active ingredient, and is delivered to the body in the same way."
Pharmac said Logem had been approved for use in New Zealand by Medsafe and about 80 million doses of the drug were used each year, including in Australia, Canada, Germany, UK, Spain, France, and the Netherlands.
Medsafe opposed Pharmac's brand switch on safety grounds, saying it went against international best practice and posed a potentially significant safety risk.
It made that assessment based not on the quality of Logem but on the grounds that lamotrigine was a finely balanced drug, so small changes in the amount absorbed by the body could produce significant side effects.
In response to Official Information Act requests from RNZ, Medsafe said it saw no reason to tell Pharmac about the quality assurance problems at the Indian factory where Logem is made.
It said the FDA could sometimes issue several warning letters a week, and Medsafe would only inform Pharmac if supply issues could arise with one of its funded medicines.
"In this instance we agreed with the supplier that no market action was needed. There was therefore no need for Medsafe to communicate with Pharmac," Medsafe said in a statement.
The FDA visited the Mylan plant in India in September 2016, and found the company had violated quality standards.
The authority then sent Mylan a warning letter in April 2017 saying Mylan "failed to thoroughly investigate" unexplained discrepancies in drug batches.
The FDA also said the Mylan plant "failed to establish an adequate quality control unit" to review production errors. "Your quality system does not adequately ensure the accuracy and integrity of data to support the safety effectiveness and quality of the drugs you manufacture."
Investigators from the FDA found "interrupted, missing, deleted and lost data" which Mylan had looked into but claimed was due to power and "connectivity problems", including disconnection of a power cord.
According to FDA records, Mylan was told in July 2018 that its "corrective actions" in response to the FDA warning had addressed the violations.
Mylan has declined multiple requests by RNZ for an interview about its Logem drug.
When RNZ first asked Medsafe whether it was aware of quality control issues at Mylan it responded: "Medsafe is not aware, and has not been made aware by Mylan, of a quality control issue with respect to the manufacture of the product that is approved for use in New Zealand."
But when RNZ came back with a specific inquiry about the FDA warning letter, Medsafe revealed it had actually conducted its own investigation.
Medsafe said its investigation included a review of correspondence between the manufacturing site and the FDA, the remedial actions taken at the site and a risk assessment prepared by the New Zealand supplier of the medicines.
"Batches supplied to the market in New Zealand met all release specifications. Based on our review of this information we concluded that there was no evidence to suggest a direct quality or safety impact of product manufactured at the site, and that market actions (eg recall) were not required."
Medsafe said it took similar actions to other regulators around the world, and noted the Indian site has current FDA and EU approval.
It also said that ESR had tested two strengths of the Logem drug, and found them to comply with pharmaceutical specifications, and the drug was "identical" to that used in Australia.