def getdateage(arrivaldate, age, period): """ Returns a date adjusted for age. age is a number, period is YEARS, MONTHS or WEEKS """ d = getdate(arrivaldate) if d is None: d = asm.now() if period == "YEARS": d = asm.subtract_days(d, 365 * asm.cfloat(age)) if period == "MONTHS": d = asm.subtract_days(d, 31 * asm.cfloat(age)) if period == "WEEKS": d = asm.subtract_days(d, 7 * asm.cfloat(age)) return d
elif a.DateBroughtIn.year < 2015: a.Archived = 1 a.Neutered = row["desexdate"].strip() != "" and 1 or 0 a.NeuteredDate = getdate(row["desexdate"]) a.BreedName = asm.breed_name_for_id(a.BreedID) a.CrossBreed = row["crossbreed"] == "TRUE" and 1 or 0 if a.CrossBreed == 1: a.Breed2ID = 442 if row["dob"].strip() != "": a.DateOfBirth = getdate(row["dob"]) if a.DateOfBirth is None: a.DateOfBirth = a.DateBroughtIn a.IdentichipNumber = row["MicroChip"] if a.IdentichipNumber != "": a.Identichipped = 1 a.Sex = getsex12(row["Sex"]) a.Weight = asm.cfloat(row["weight"]) a.BaseColourID = asm.colour_id_for_name(row["Colour"]) a.ShelterLocation = 1 a.generateCode(asm.type_name_for_id(a.AnimalTypeID)) a.ReasonForEntry = row["dep_sReason"] if row["sOther"] != "": a.ReasonForEntry = row["sOther"] a.EntryReasonID = 11 if row["circumstance"].find("Stray"): a.EntryReasonID = 7 comments = "Original Type: " + typecol comments += "\nOriginal Breed: " + breedcol + "/" + breed2col comments += "\nOriginal Colour: " + row["Colour"] + "/" + row["SecondaryColour"] comments += "\nCircumstance: " + row["circumstance"] a.HiddenAnimalDetails = comments a.AnimalComments = getsbnotes(row["AnimalID"])
if a.CreatedDate is None: a.CreatedDate = asm.today() if a.LastChangedDate is None: a.LastChangedDate = asm.today() if d["Intake Type"] == "Shelter Transfer" or d[ "Intake Type"] == "Rescue Transfer" or d[ "Intake Type"] == "Pet Pulled": a.IsTransfer = 1 a.ShelterCode = d["Pet ID"] a.ShortCode = d["Pet ID"] a.Markings = d["Colors or Markings"] a.BaseColourID = asm.colour_id_for_name(d["Colors or Markings"], True) a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.ShelterLocationUnit = d["Cage Number"] a.Sex = asm.getsex_mf(d["Gender"]) a.Size = asm.size_from_db(d["Size"]) a.Weight = asm.cfloat(d["Weight"]) if d["Is Declawed"] == "Yes": a.Declawed = 1 if d["HIV Positive"] == "Yes": a.CombiTested = 1 a.CombiTestResult = 0 if d["Has Tattoo"] == "Yes": a.Tattoo = 1 a.Neutered = d["Is Pet Altered"] == "Yes" and 1 or 0 a.IsGoodWithCats = 2 a.IsGoodWithDogs = 2 a.IsGoodWithChildren = 2 a.HouseTrained = asm.iif(d["Housebroken"] == "Yes", 0, 2) a.Archived = 0 a.EntryReasonID = 1 if d["Intake Type"] == "Born In-House": a.EntryReasonID = 13
av.VaccinationID = v av.Comments = d["TypeOfVaccinations"] comments = "color: %s" % d["CatColor"] if d["LocationWhereFound"] != "": comments += "\nfound: %s" % d["LocationWhereFound"] if d["TransferredTo"] != "": comments += "\ntransferred to: %s %s" % (d["TransferredTo"], d["Transferred"]) a.Archived = 1 if d["ReturnedToOwner"] == "1": comments += "\nreturned to owner" a.Archived = 1 if d["SurrenderedBy"] != "": comments += "\nsurrendered: %s %s %s %s" % (d["SurrenderedBy"], d["SurrAddress"], d["SurrDL#"], d["SurrPhone"]) if d["Eyes"] != "": comments += "\neyes: %s" % d["Eyes"] if d["Ears"] != "": comments += "\neyes: %s" % d["Ears"] if asm.cfloat(d["Weight_oz"]) != 0: comments += "\nweight: %d %d" % (asm.cint(d["Weight_lbs"]), asm.cfloat(d["Weight_oz"])) if d["Mouth"] != "": comments += "\nmouth: %s" % d["Mouth"] if d["Nose"] != "": comments += "\nnose: %s" % d["Nose"] if d["Coat"] != "": comments += "\ncoat: %s" % d["Coat"] a.HiddenAnimalDetails = comments a.DeceasedDate = asm.getdate_mmddyy(d["Deceased"]) if d["Euthanized"] == "1": a.PutToSleep = 1 if a.DeceasedDate is not None: a.Archived = 1 if d["Treatable Healthy"] == "1": a.AsilomarIntakeCategory = 1 elif d["Treatable Manageable"] == "1": a.AsilomarIntakeCategory = 2 elif d["Unhealthy Untreatable"] == "1":
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"]] if o is None: continue url = d["url"]
elif a.DateBroughtIn.year < asm.now().year - 1: a.Archived = 1 a.Neutered = row["desexdate"].strip() != "" and 1 or 0 a.NeuteredDate = getdate(row["desexdate"]) a.BreedName = asm.breed_name_for_id(a.BreedID) a.CrossBreed = row["crossbreed"] == "TRUE" and 1 or 0 if a.CrossBreed == 1: a.Breed2ID = 442 if row["dob"].strip() != "": a.DateOfBirth = getdate(row["dob"]) if a.DateOfBirth is None: a.DateOfBirth = a.DateBroughtIn a.IdentichipNumber = row["MicroChip"] if a.IdentichipNumber != "": a.Identichipped = 1 a.Sex = getsex12(row["Sex"]) a.Weight = asm.cfloat(row["weight"]) a.BaseColourID = asm.colour_id_for_name(row["Colour"]) a.ShelterLocation = 1 a.generateCode(asm.type_name_for_id(a.AnimalTypeID)) a.ReasonForEntry = row["dep_sReason"] if row["sOther"] != "": a.ReasonForEntry = row["sOther"] a.EntryReasonID = 11 if row["circumstance"].find("Stray"): a.EntryReasonID = 7 comments = "Original Type: " + typecol comments += "\nOriginal Breed: " + breedcol + "/" + breed2col comments += "\nOriginal Colour: " + row["Colour"] + "/" + row[ "SecondaryColour"] comments += "\nCircumstance: " + row["circumstance"] a.HiddenAnimalDetails = comments
comments = "color: %s" % d["CatColor"] if d["LocationWhereFound"] != "": comments += "\nfound: %s" % d["LocationWhereFound"] if d["TransferredTo"] != "": comments += "\ntransferred to: %s %s" % (d["TransferredTo"], d["Transferred"]) a.Archived = 1 if d["ReturnedToOwner"] == "1": comments += "\nreturned to owner" a.Archived = 1 if d["SurrenderedBy"] != "": comments += "\nsurrendered: %s %s %s %s" % ( d["SurrenderedBy"], d["SurrAddress"], d["SurrDL#"], d["SurrPhone"]) if d["Eyes"] != "": comments += "\neyes: %s" % d["Eyes"] if d["Ears"] != "": comments += "\neyes: %s" % d["Ears"] if asm.cfloat(d["Weight_oz"]) != 0: comments += "\nweight: %d %d" % (asm.cint( d["Weight_lbs"]), asm.cfloat(d["Weight_oz"])) if d["Mouth"] != "": comments += "\nmouth: %s" % d["Mouth"] if d["Nose"] != "": comments += "\nnose: %s" % d["Nose"] if d["Coat"] != "": comments += "\ncoat: %s" % d["Coat"] a.HiddenAnimalDetails = comments a.DeceasedDate = asm.getdate_mmddyy(d["Deceased"]) if d["Euthanized"] == "1": a.PutToSleep = 1 if a.DeceasedDate is not None: a.Archived = 1 if d["Treatable Healthy"] == "1": a.AsilomarIntakeCategory = 1 elif d["Treatable Manageable"] == "1":