meddate = getdate(d["Date given"]) m = asm.animal_regimen_single(a.ID, meddate, d["Product"], d["Amount"], d["Dose notes"]) animalmedicals.append(m) if asm.file_exists("%s/vaccinations.csv" % PATH): for d in asm.csv_to_list("%s/vaccinations.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] vaccdate = getdate(d["Date given"]) lotno = "" if "Lot #" in d: lotno = d["Lot #"] t = asm.animal_vaccination(a.ID, vaccdate, vaccdate, d["Vaccine product"], rabiestag=d["Rabies tag number"], batchnumber=lotno) animalvaccinations.append(t) # Allow shelter animals to have their chips registered for a in animals: if a.Archived == 0: a.IsNotForRegistration = 0 # Now that everything else is done, output stored records for k, v in asm.testtypes.items(): if v.ID >= START_ID: print(v) for k, v in asm.vaccinationtypes.items(): if v.ID >= START_ID: print(v) for k, v in asm.locations.items():
# allmedical.csv vx = {} # lookup of animal ID to vaccinations for speed for row in asm.csv_to_list(PATH + "allmedical.csv", remove_non_ascii=True): a = None if not ppa.has_key(row["Animal Id"]): continue a = ppa[row["Animal Id"]] dg = asm.getdate_iso(row["Date Given"]) dn = asm.getdate_iso(row["Date Needed"]) if row["Type of Medical Entry"] == "Vaccination": if a.ID not in vx: vx[a.ID] = [] # Create a vacc with just the needed date if dn is not None: av = asm.animal_vaccination( a.ID, dn, None, row["Vaccination"], "%s %s" % (row["Comments"], row["Hidden comments"])) animalvaccinations.append(av) vx[a.ID].append(av) # now, go back through our vaccinations to find any for this animal with a needed date that matches the given date # so we can mark them given. This is because ishelters store pairs of given and next needed, where we store needed and given. gotone = False for v in vx[a.ID]: if v.AnimalID == a.ID and v.DateOfVaccination is None and v.DateRequired == dg: v.DateOfVaccination = dg v.Comments += " %s %s" % (row["Comments"], row["Hidden comments"]) gotone = True if not gotone and dg is not None: # We didn't find one, record it as a standalone vacc av = asm.animal_vaccination(