Skip to content

Commit

Permalink
Merge pull request #5074 from ebmdatalab/evansd/fix-tariff-import
Browse files Browse the repository at this point in the history
Fix drug tariff import code
  • Loading branch information
evansd authored Nov 18, 2024
2 parents 48253d4 + 17329b1 commit c3cd89e
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,27 @@ def import_month(rows, date):

# The third row is column headings
header_row = next(rows)
headers = ["".join((c or "?").lower().split()) for c in header_row]
assert headers == [
headers = {"".join((c or "?").lower().split()): n for n, c in enumerate(header_row)}
required_headers = {
"medicine",
"packsize",
"?",
"vmpsnomedcode",
"vmppsnomedcode",
"drugtariffcategory",
"basicprice",
]
}
missing_headers = required_headers - headers.keys()
assert not missing_headers, (
f"Missing required headers: {missing_headers}\n"
f"Headers: {headers}\n"
f"Original headers: {header_row}"
)

with transaction.atomic():
for row in rows:
if all(v is None for v in row):
continue

d = dict(zip(headers, row))
d = {k: row[n] for k, n in headers.items()}

if d["basicprice"] is None:
msg = "Missing price for {} Drug Tariff for {}".format(
Expand Down

0 comments on commit c3cd89e

Please sign in to comment.