d["Distemper Parvo Renewal"]) create_vacc("Lepto", d["Lepto Date"], d["Lepto Renewal"]) create_vacc("Influenza", d["Influenza Date"], d["Influenza Renewal"]) create_vacc("Bordetella", d["Bordetella Date"], d["Bordetella Renewal"]) a.HeartwormTestDate = getdate(d["HW Test"]) if a.HeartwormTestDate is not None: a.HeartwormTested = 1 a.HeartwormTestResult = 1 if d["HW Test Results"].find("ositive") != -1: a.HeartwormTestResult = 2 deworm = getdate(d["Dewormed"]) if deworm is not None: animalmedicals.append( asm.animal_regimen_single(a.ID, deworm, "Dewormer", "Dose")) flea = getdate(d["Flea Treatment"]) if flea is not None: animalmedicals.append( asm.animal_regimen_single(a.ID, flea, "Flea treatment", "Dose")) a.IdentichipNumber = d["Microchip Info"] if a.IdentichipNumber != "": a.Identichipped = 1 a.IsGoodWithCats = asm.good_with(d["Good w/ cats"]) a.IsGoodWithDogs = asm.good_with(d["Good w/ dogs"]) a.IsGoodWithChildren = asm.good_with(d["Good w/ children"]) a.HouseTrained = 0 comments = "Breed: " + d["Breed"] comments += "\nType: " + d["Type"]
t = asm.animal_test(a.ID, testdate, testdate, d["Product"], d["Result"]) animaltests.append(t) if asm.file_exists("%s/procedures.csv" % PATH): for d in asm.csv_to_list("%s/procedures.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] meddate = getdate(d["Date"]) treatmentname = "" comments = "" if "Treatment" in d: treatmentname = d["Treatment"] if "Type" in d and treatmentname == "": treatmentname = d["Type"] if "Comments" in d: comments = d["Comments"] m = asm.animal_regimen_single(a.ID, meddate, treatmentname, "Procedure", comments) animalmedicals.append(m) if asm.file_exists("%s/medical.csv" % PATH): for d in asm.csv_to_list("%s/medical.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] 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
m.MovementType = 2 m.MovementDate = a.DateBroughtIn a.ActiveMovementID = m.ID a.ActiveMovementDate = m.MovementDate a.ActiveMovementType = 2 a.CreatedDate = m.MovementDate if asm.file_exists("%s/vet_visits.csv" % PATH): for d in asm.csv_to_list("%s/vet_visits.csv" % PATH): if d["animal_id"] == "animal_id": continue if d["animal_id"] not in ppa: continue a = ppa[d["animal_id"]] meddate = getdate(d["visit_date"]) m = asm.animal_regimen_single(a.ID, meddate, d["treatment"], "Vet Visit", d["reason"], cost=asm.cfloat(d["cost"]) * 100) animalmedicals.append(m) if FETCH_MEDIA and asm.file_exists("%s/documents.csv" % PATH): for d in asm.csv_to_list("%s/documents.csv" % PATH): if d["attachment_type"] == "Animal": a = ppa[d["attachment_id"]] if a is None: continue url = d["url"] filename = url[url.rfind("/") + 1:] data = asm.load_file_from_url(url) asm.media_file(0, a.ID, filename, data) elif d["attachment_type"] == "Person": o = ppo[d["attachment_id"]]
wasvacc = False for k, v in vaccmap.iteritems(): if t.find(k) != -1: av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.VaccinationID = v av.DateRequired = td av.DateOfVaccination = td av.Comments = d["Comments"] wasvacc = True break if not wasvacc: animalmedicals.append( asm.animal_regimen_single(a.ID, td, t, comments=d["Comments"])) # Now that everything else is done, output stored records for a in animals: print a for av in animalvaccinations: print av for am in animalmedicals: print am for o in owners: print o for m in movements: print m asm.stderr_summary(animals=animals, animalmedicals=animalmedicals,
wasvacc = False for k, v in vaccmap.iteritems(): if t.find(k) != -1: av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.VaccinationID = v av.DateRequired = td av.DateOfVaccination = td av.Comments = d["Comments"] wasvacc = True break if not wasvacc: animalmedicals.append(asm.animal_regimen_single(a.ID, td, t, comments = d["Comments"])) # Now that everything else is done, output stored records for a in animals: print a for av in animalvaccinations: print av for am in animalmedicals: print am for o in owners: print o for m in movements: print m asm.stderr_summary(animals=animals, animalmedicals=animalmedicals, animalvaccinations=animalvaccinations, owners=owners, movements=movements)
# medical history asm.stderr("Process medical history") for row in cmedicalhistory: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] if row["Issue"] == "Spay" or row["Issue"] == "Neuter": a.Neutered = 1 a.NeuteredDate = asm.getdate_mmddyy(row["DateOfService"]) else: tname = row["Issue"] if tname == "": tname = row["Note"] sdate = asm.getdate_mmddyy(row["DateOfService"]) if sdate is None: sdate = a.DateBroughtIn animalmedicals.append( asm.animal_regimen_single(a.ID, sdate, tname, "", row["Note"])) # animal notes asm.stderr("Process animal notes") for row in canimalsnotes: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyy(row["NoteDate"]) if l.Date is None: l.Date = asm.now() l.Comments = row["Note"]
if a is None: continue av.AnimalID = a.ID av.VaccinationID = int(row["vacc"].strip()) animalvaccinations.append(av) # tblmedications.csv for row in asm.csv_to_list(PATH + "tblmedications.csv"): a = findanimal(row["animalID"]) if a is None: continue startdate = getdate(row["datefrom"]) treatmentname = medtype[row["medicationID"]] dosage = row["notes"] comments = row["notes"] if startdate is not None: animalmedicals.append( asm.animal_regimen_single(a.ID, startdate, treatmentname, dosage, comments)) # tblreceiptentry.csv for row in asm.csv_to_list(PATH + "tblreceiptentry.csv"): od = asm.OwnerDonation() od.DonationTypeID = 1 pm = getsbpaymentmethod(row["dep_paymentMethod"]) od.DonationPaymentID = 1 if pm.find("Check") != -1: od.DonationPaymentID = 2 if pm.find("Credit Card") != -1: od.DonationPaymentID = 3 if pm.find("Debit Card") != -1: od.DonationPaymentID = 4 od.Date = getdate(row["receiptdate"]) od.OwnerID = findowner(row["recnum"]).ID od.Donation = asm.get_currency(row["dep_amount"]) comments = "Check No: " + row["dep_chequeNo"] comments += "\nMethod: " + pm
a = None if not ppa.has_key(row["Animal Id"]): continue a = ppa[row["Animal Id"]] dg = asm.getdate_iso(row["Date Given"]) if dg is None: dg = a.DateBroughtIn if row["Type of Medical Entry"] == "Vaccination": av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.DateRequired = asm.getdate_iso(row["Date Needed"]) av.DateOfVaccination = dg if av.DateRequired is None: av.DateRequired = av.DateOfVaccination av.VaccinationID = asm.vaccinationtype_id_for_name(row["Vaccination"], True) av.Comments = "%s %s" % (row["Comments"], row["Hidden comments"]) else: asm.animal_regimen_single(a.ID, dg, "%s %s" % (row["Medical Procedure Type"], row["Medication Name"]), row["Medication Dose"], "%s %s" % (row["Comments"], row["Hidden comments"])) # Now that everything else is done, output stored records print "DELETE FROM primarykey;" for a in animals: print a for av in animalvaccinations: print av for o in owners: print o for od in ownerdonations: print od for m in movements: print m for k, v in asm.vaccinationtypes.iteritems(): print v
av.VaccinationID = 6 # Bordetella if d["TreatmentName"].startswith("DHLP"): av.VaccinationID = 8 # DHLPP if d["TreatmentName"].startswith("FVRCP"): av.VaccinationID = 9 # FVRCP av.DateRequired = meddate av.DateOfVaccination = meddate av.BatchNumber = d["SerialNumber"] av.Manufacturer = d["Manufacturer"] av.DateExpires = getdate(d["ExpireDate"]) av.Comments = "%s Vaccinator: %s, Vet: %s, License: %s. %s %s" % ( d["TreatmentName"], d["Vaccinator"], d["Vet"], d["VetLicenseNumber"], d["VaccineTagNbr"], d["Comments"]) else: animalmedicals.append( asm.animal_regimen_single( aid, meddate, d["TreatmentName"], "", "%s %s" % (d["VaccineTagNbr"], d["Comments"]))) # Incidents for d in asm.csv_to_list(COMPLAINTS_FILENAME): if d["Complaint"].strip() == "" or d["ComplaintType"].strip() == "": continue ac = asm.AnimalControl() animalcontrols.append(ac) calldate = getdate(d["ComplaintDate"]) if calldate is None: calldate = asm.now() ac.CallDateTime = calldate ac.IncidentDateTime = calldate ac.DispatchDateTime = calldate ac.CompletedDate = calldate ac.CallerID = d["CallerPersonID"] in ppo and ppo[
l.LinkType = 0 l.Date = ed l.Comments = d["Weight"] if d["Action"] == "Admission" and d[ "Log_Description"] == "Owner Surrender" and o: a.OriginalOwnerID = o.ID a.BroughtInByOwnerID = o.ID a.DateBroughtIn = ed a.CreatedBy = d["User_Id"] elif d["Action"] == "Veterinary" and d["Log_Description"] == "Desexed": a.Neutered = 1 a.NeuteredDate = ed animalmedicals.append( asm.animal_regimen_single(a.ID, ed, d["Log_Description"], "N/A", d["Log_Notes"])) elif d["Action"] == "Veterinary": animalmedicals.append( asm.animal_regimen_single(a.ID, ed, d["Log_Description"], "N/A", d["Log_Notes"])) if d["Log_Description"].startswith("Euthanised"): a.DeceasedDate = ed a.PutToSleep = 1 elif d["Action"] == "Vaccination": vacctypes = {"C3": 16, "C5": 18, "F3": 22, "F4": 23} av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.VaccinationID = 8
"AnimalID", "Name", "Type", "Ustr2", "Ustr3", "Type2", "Thing", "Ubool1", "Ustr4", "Status", "Given", "Due", "U1", "U2", "U3", "U4", "Manufacturer", "BatchNumber", "U7", "U8", "U9", "U10", "User", "Vet", "Ustr5", "TestResult", "Microchip", "Comments" ] for d in asm.csv_to_list_cols(HEALTH_FILENAME, HEALTH_COLS): a = None healthdate = getdate(d["Given"]) or getdate(d["Due"]) if d["AnimalID"] in ppa: a = ppa[d["AnimalID"]] if d["Type"] == "Vaccination": process_vacc(a.ID, healthdate, None, d["Thing"], d["BatchNumber"], d["Manufacturer"], d["Comments"]) elif d["Type"] == "Procedure": animalmedicals.append( asm.animal_regimen_single(d["AnimalID"], healthdate, d["Thing"], "Procedure", d["Comments"] + " " + d["TestResult"])) if d["Thing"] == "Microchip Implant": a.Identichipped = 1 a.IdentichipNumber = d["Microchip"] # Now that everything else is done, output stored records for k, v in asm.locations.iteritems(): print v for a in animals: #if a.Archived == 1: print a print a for am in animalmedicals: print am for av in animalvaccinations: print av
elif row["Type of Medical Entry"] == "Diagnostic Test": if dg is None: dg = a.DateBroughtIn animaltests.append( asm.animal_test( a.ID, dg, dg, row["Diagnostic Test Name"], row["Diagnostic Test Result"], "%s %s" % (row["Comments"], row["Hidden comments"]))) elif row["Type of Medical Entry"] == "Medical Condition": if dg is None: dg = asm.getdate_iso(row["Medical Condition Noticed On"]) if dg is None: dg = a.DateBroughtIn animalmedicals.append( asm.animal_regimen_single( a.ID, dg, row["Medical Condition Name"], "N/A", "%s %s" % (row["Comments"], row["Hidden comments"]))) elif row["Type of Medical Entry"] == "Medical Procedure": if dg is None: dg = dn if dg is None: dg = a.DateBroughtIn animalmedicals.append( asm.animal_regimen_single( a.ID, dg, row["Medical Procedure Type"], "N/A", "%s %s" % (row["Comments"], row["Hidden comments"]))) elif dg is not None: animalmedicals.append( asm.animal_regimen_single( a.ID, dg, "%s %s" % (row["Medical Procedure Type"], row["Medication Name"]),
av.Manufacturer = "%s %s" % (row["RabiesVaccinationManufacturer"], row["RabiesVaccinationBrand"]) av.BatchNumber = "%s %s" % (row["RabiesVaccinationLotNumber"], asm.fw(row["RabiesVaccinationLotExpiration"])) # medical history for row in cmedicalhistory: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] if row["Issue"] == "Spay" or row["Issue"] == "Neuter": a.Neutered = 1 a.NeuteredDate = asm.getdate_mmddyy(row["DateOfService"]) else: tname = row["Issue"] if tname == "": tname = row["Note"] sdate = asm.getdate_mmddyy(row["DateOfService"]) if sdate is None: sdate = a.DateBroughtIn asm.animal_regimen_single(a.ID, sdate, tname, "", row["Note"]) # animal notes for row in canimalsnotes: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyy(row["NoteDate"]) if l.Date is None: l.Date = asm.now() l.Comments = row["Note"]
try: a.Weight = float(d["Weight"]) except ValueError: pass l = asm.Log() logs.append(l) l.LogTypeID = 1 # Weight l.LinkID = a.ID l.LinkType = 0 l.Date = ed l.Comments = d["Weight"] elif d["Action"] == "Veterinary" and d["Log_Description"] == "Desexed": a.Neutered = 1 a.NeuteredDate = ed animalmedicals.append( asm.animal_regimen_single(a.ID, ed, d["Log_Description"], "N/A", d["Log_Notes"]) ) elif d["Action"] == "Veterinary": animalmedicals.append( asm.animal_regimen_single(a.ID, ed, d["Log_Description"], "N/A", d["Log_Notes"]) ) elif d["Action"] == "Vaccination": vacctypes = { "C3": 16, "C5": 18, "F3": 22, "F4": 23 } av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.VaccinationID = 8
for d in asm.csv_to_list("%s/tests.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] testdate = getdate(d["Date"]) t = asm.animal_test(a.ID, testdate, testdate, d["Product"], d["Result"]) animaltests.append(t) if asm.file_exists("%s/procedures.csv" % PATH): for d in asm.csv_to_list("%s/procedures.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] meddate = getdate(d["Date"]) m = asm.animal_regimen_single(a.ID, meddate, d["Treatment"], "Procedure", d["Comments"]) animalmedicals.append(m) if asm.file_exists("%s/medical.csv" % PATH): for d in asm.csv_to_list("%s/medical.csv" % PATH): if d["Animal ID"] == "Animal ID": continue if d["Animal ID"] not in ppa: continue a = ppa[d["Animal ID"]] 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
av.BatchNumber = "%s %s" % (row["RabiesVaccinationLotNumber"], asm.fw(row["RabiesVaccinationLotExpiration"])) # medical history asm.stderr("Process medical history") for row in cmedicalhistory: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] if row["Issue"] == "Spay" or row["Issue"] == "Neuter": a.Neutered = 1 a.NeuteredDate = asm.getdate_mmddyy(row["DateOfService"]) else: tname = row["Issue"] if tname == "": tname = row["Note"] sdate = asm.getdate_mmddyy(row["DateOfService"]) if sdate is None: sdate = a.DateBroughtIn animalmedicals.append(asm.animal_regimen_single(a.ID, sdate, tname, "", row["Note"])) # animal notes asm.stderr("Process animal notes") for row in canimalsnotes: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyy(row["NoteDate"]) if l.Date is None: l.Date = asm.now() l.Comments = row["Note"]