Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
    # Each row contains an animal with intake and outcome info:
    a = asm.Animal()
    flags = ""
    animals.append(a)
    a.SpeciesID = asm.species_id_for_name(d["Type"])
    a.AnimalTypeID = 11
    if a.SpeciesID == 1: a.AnimalTypeID = 2  # dog
    if a.SpeciesID == 2: a.AnimalTypeID = 11  # unwanted cat
    a.AnimalName = d["Name"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateBroughtIn = getdate(d["Date In"]) or asm.today()
    if d["DOB"].strip() != "":
        a.DateOfBirth = getdate(d["DOB"])
    if a.DateOfBirth is None:
        a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365)
    a.CreatedDate = a.DateBroughtIn
    a.LastChangedDate = a.DateBroughtIn
    a.ShortCode = d["File"]
    a.ShelterCode = str(a.ID) + " " + d["File"]
    a.BreedID = asm.breed_id_for_name(d["Breed"].replace(" mix", ""))
    a.BreedName = asm.breed_name_for_id(a.BreedID)
    if d["Breed"].find("mix") != -1:
        a.CrossBreed = 1
        a.Breed2ID = 442
        a.BreedName = asm.breed_name(a.BreedID, a.Breed2ID)
    a.BaseColourID = asm.colour_id_for_name(d["Color"])

    a.Sex = asm.getsex_mf(d["Male Female"])
    a.Weight = asm.cint(d["Weight"].replace("lbs", "").strip())
Esempio n. 4
0
 if a.DateBroughtIn is None:
     a.DateBroughtIn = lastbroughtin
 else:
     lastbroughtin = a.DateBroughtIn
 a.BreedID = asm.breed_id_for_name(d["CatBreed"], 261)
 a.BaseColourID = asm.colour_id_for_name(d["CatColor"])
 a.AnimalTypeID = asm.iif(d["OwnerSurrender"] == "1", 11, 12)
 a.SpeciesID = 2
 a.Sex = asm.getsex_mf(d["Sex"])
 a.DateOfBirth = asm.getdate_mmddyy(d["DOB"])
 if a.DateOfBirth is None:
     dy = 365 * asm.cint(d["AgeYrs"])
     dy += 30 * asm.cint(d["AgeMos"])
     dy += 7 * asm.cint(d["AgeWks"])
     dy += asm.cint(d["AgeDays"])
     a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, dy)
 a.Neutered = asm.iif(d["SpayOrNeuteredPreviously"] == "1", 1, 0)
 if a.Neutered == 0:
     a.Neutered = asm.iif(d["Spay/NeuterDate"] != "", 1, 0)
 a.NeuteredDate = asm.getdate_mmddyy(d["Spay/NeuterDate"])
 a.AnimalComments = d["Comments"]
 a.IdentichipDate = asm.getdate_mmddyy(d["MicrochipDate"])
 if a.IdentichipDate is not None:
     a.Identichipped = 1
     a.IdentichipNumber = d["Microchip#"]
 a.CombiTestDate = asm.getdate_mmddyy(d["FIV/FELVDate"])
 if a.CombiTestDate is not None:
     a.CombiTested = 1
     a.CombiTestResult = asm.iif(d["FIVPosorNeg"] == "p", 2, 1)
     a.FLVResult = asm.iif(d["FELVPosorNeg"] == "p", 2, 1)
 a.HealthProblems = d["MedHistory"]
        animalvaccinations.append(av)
        av.DateRequired = date
        av.DateOfVaccination = date
        av.VaccinationID = 6
        if row["MED"].startswith("FelV"): av.VaccinationID = 12
        if row["MED"].startswith("FVRCP"): av.VaccinationID = 9
        if row["MED"].startswith("DA2PP"): av.VaccinationID = 8
        if row["MED"].startswith("Bord"): av.VaccinationID = 6
        if row["MED"].startswith("Rabies"): av.VaccinationID = 4
        if row["MED"].startswith("Lepto"): av.VaccinationID = 3
        av.Comments = "%s %s" % (row["MED"], row["NOTES"])

# Run back through the animals, if we have any that are still
# on shelter after 1 year, add an adoption to an unknown owner
for a in animals:
    if a.Archived == 0 and a.DateBroughtIn < asm.subtract_days(asm.now(), 365):
        m = asm.Movement()
        m.AnimalID = a.ID
        m.OwnerID = uo.ID
        m.MovementType = 1
        m.MovementDate = a.DateBroughtIn
        a.Archived = 1
        a.ActiveMovementID = m.ID
        a.ActiveMovementDate = a.DateBroughtIn
        a.ActiveMovementType = 1
        movements.append(m)

# Now that everything else is done, output stored records
for k, v in asm.locations.iteritems():
    print v
for a in animals:
Esempio n. 6
0
 a.ShortCode = d["Animal ID"]
 a.ShelterCode = d["Animal ID"]
 ppa[d["Animal ID"]] = a
 a.AnimalName = d["Name"]
 if "Created Date" in d: a.DateBroughtIn = getdate(d["Created Date"])
 dob = a.DateBroughtIn
 if dob is None: dob = asm.today()
 a.EstimatedDOB = 1
 # Ages are stored as 2Y/ 4M/ 26D
 # If this column isn't present, we've also seen an Age (Months) column in intake.csv
 age = ""
 if "Age (Y/M/D)" in d:
     age = d["Age (Y/M/D)"]
     for b in age.split("/"):
         b = b.strip()
         if b.endswith("Y"): dob = asm.subtract_days(dob, 365 * asm.atoi(b))
         if b.endswith("M"): dob = asm.subtract_days(dob, 30 * asm.atoi(b))
         if b.endswith("D"): dob = asm.subtract_days(dob, asm.atoi(b))
     a.DateOfBirth = dob
 a.Sex = 1
 if d["Sex"].startswith("F"):
     a.Sex = 0
 primary = d["Primary Breed"]
 secondary = ""
 if "Secondary Breed" in d: secondary = d["Secondary Breed"]
 asm.breed_ids(a, primary, secondary, DEFAULT_BREED)
 color = "Black"
 if "Primary Color" in d: color = d["Primary Color"]
 a.BaseColourID = asm.colour_id_for_name(color)
 if "Current Weight" in d and d["Current Weight"] != "":
     a.Weight = asm.atof(d["Current Weight"])
Esempio n. 7
0
 a.BreedName = asm.breed_name_for_id(a.BreedID)
 if d["BREED"].find("MIX") != -1:
     a.CrossBreed = 1
     a.Breed2ID = 442
     a.BreedName = asm.breed_name_for_id(
         a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID)
 a.DateBroughtIn = d["DATE_SURR"]
 if a.DateBroughtIn is None: a.DateBroughtIn = asm.now()
 a.NeuteredDate = d["NEUTER_DAT"]
 if a.NeuteredDate is not None:
     a.Neutered = 1
 a.EstimatedDOB = 1
 dob = a.DateBroughtIn
 if d["AGE"] != "":
     if d["AGE"].find("YR") != -1:
         dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 365)
     elif d["AGE"].find("M") != -1:
         dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 30)
 a.DateOfBirth = dob
 if d["EUTH_USD"] > 0:
     a.PutToSleep = 1
     a.Archived = 1
     a.DeceasedDate = d["DATE_DISPO"]
 comments = "Original breed: %s\nColor: %s" % (d["BREED"].strip(),
                                               d["COLOR"].strip())
 if asm.nulltostr(d["PU_LOC"]).strip() != "":
     comments += "\nPicked up from: %s" % d["PU_LOC"]
 a.HiddenAnimalDetails = comments
 a.AnimalComments = asm.nulltostr(d["ANIMAL_TXT"]).strip()
 a.HealthProblems = d["HEALTH"]
 a.LastChangedDate = a.DateBroughtIn
Esempio n. 8
0
 a.BaseColourID = asm.colour_id_for_name(d["COLOR"])
 a.BreedName = asm.breed_name_for_id(a.BreedID)
 if d["BREED"].find("MIX") != -1:
     a.CrossBreed = 1
     a.Breed2ID = 442
     a.BreedName = asm.breed_name_for_id(a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID)
 a.DateBroughtIn = d["DATE_SURR"]
 if a.DateBroughtIn is None: a.DateBroughtIn = asm.now()
 a.NeuteredDate = d["NEUTER_DAT"]
 if a.NeuteredDate is not None:
     a.Neutered = 1
 a.EstimatedDOB = 1
 dob = a.DateBroughtIn
 if d["AGE"] != "":
     if d["AGE"].find("YR") != -1:
         dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 365)
     elif d["AGE"].find("M") != -1:
         dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 30)
 a.DateOfBirth = dob
 if d["EUTH_USD"] > 0:
     a.PutToSleep = 1
     a.Archived = 1
     a.DeceasedDate = d["DATE_DISPO"]
 comments = "Original breed: %s\nColor: %s" % (d["BREED"].strip(), d["COLOR"].strip())
 if asm.nulltostr(d["PU_LOC"]).strip() != "":
     comments += "\nPicked up from: %s" % d["PU_LOC"]
 a.HiddenAnimalDetails = comments
 a.AnimalComments = asm.nulltostr(d["ANIMAL_TXT"]).strip()
 a.HealthProblems = d["HEALTH"]
 a.LastChangedDate = a.DateBroughtIn
 if d["ADPT_ID"] != "":
Esempio n. 9
0
 if d.RGT == 1: a.AnimalTypeID = 43  # RGT
 a.SpeciesID = 1
 a.BaseColourID = 72  # Unknown
 if colours.has_key(d.colour.lower()):
     a.BaseColourID = colours[d.colour.lower()]
 a.AnimalName = d.name
 if a.AnimalName.strip() == "":
     a.AnimalName = "(unknown)"
 a.DateBroughtIn = d.date_of_entry
 if a.DateBroughtIn is None:
     has_intake = False
     a.DateBroughtIn = DEFAULT_INTAKE_DATE
 if d.dob is not None:
     a.DateOfBirth = d.dob
 elif d.date_of_entry is not None and d.approx_age is not None:
     a.DateOfBirth = asm.subtract_days(d.date_of_entry, d.approx_age * 365)
 elif a.DateBroughtIn != DEFAULT_INTAKE_DATE:
     a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365 * 2)
 else:
     a.DateOfBirth = DEFAULT_DATE_OF_BIRTH
 a.CreatedDate = a.DateBroughtIn
 a.LastChangedDate = a.DateBroughtIn
 if d.relinquishment_ownership == 0:
     a.IsTransfer = 1
 a.generateCode()
 a.IsNotAvailableForAdoption = 0
 a.ShelterLocation = asm.location_id_for_name(d.locationname)
 a.Sex = asm.iif(d.sex == "Dog", 1, 0)
 a.Size = 2
 a.Neutered = 1
 a.NeuteredDate = d.neutering_date
Esempio n. 10
0
     if a.EntryReasonID == 7:
         a.AnimalTypeID = 10  # Stray Dog
 else:
     a.AnimalTypeID = 40  # Misc
 a.SpeciesID = asm.species_id_for_name(d["Species"])
 a.AnimalName = d["AnimalName"]
 if a.AnimalName.strip() == "":
     a.AnimalName = "(unknown)"
 a.DateBroughtIn = getdate(d["IntakeDate"])
 if a.DateBroughtIn is None:
     a.DateBroughtIn = asm.today()
 ageinmonths = asm.cint(d["AgeMonths"])
 age = asm.cint(d["Age"])
 if age > 0: ageinmonths += (age * 12)
 if ageinmonths == 0: ageinmonths = 12
 a.DateOfBirth = asm.subtract_days(a.DateBroughtIn,
                                   int(ageinmonths * 30.5))
 a.CreatedDate = getdate(d["CreateDate"])
 a.LastChangedDate = getdate(d["UpdateDate"])
 a.generateCode()
 if asm.cint(d["AnimalNumber"]) > 0:
     a.ShortCode = d["AnimalNumber"]
 else:
     # Animals with a 0 or non-integer number are non-shelter
     a.NonShelterAnimal = 1
     a.Archived = 1
     a.OriginalOwnerID = get_asm_ownerid(d["ID"])
     activeowner = a.OriginalOwnerID
 a.IsNotAvailableForAdoption = 0
 a.Sex = asm.getsex_mf(d["Gender"])
 a.Size = 2
 a.Neutered = asm.iif(d["SpayNeuter"] == "TRUE", 1, 0)
Esempio n. 11
0
def process_impound(d, dt):
    a = asm.Animal()
    animals.append(a)
    a.EntryReasonID = 7  # Stray
    if d["Species"].lower() == "cat":
        a.AnimalTypeID = 12  # Stray Cat
    elif d["Species"].lower() == "dog":
        a.AnimalTypeID = 10  # Stray Dog
    else:
        a.AnimalTypeID = 40  # Misc
    a.SpeciesID = asm.species_id_for_name(d["Species"])
    a.AnimalName = d["Animal's Name"].replace("\n", " ")
    if a.AnimalName == "?" or a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    releasedate = getdate(d["Date of Release"])
    intakedate = getdate(d["Date of P/U"])
    if intakedate is None and releasedate is not None: intakedate = releasedate
    if intakedate is None: intakedate = dt
    a.DateBroughtIn = intakedate
    a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365)
    a.CreatedDate = a.DateBroughtIn
    a.LastChangedDate = a.DateBroughtIn
    a.generateCode()
    a.Sex = asm.getsex_mf(d["Sex-Altered?"])
    a.Size = 2
    a.Neutered = asm.iif(
        d["Sex-Altered?"].lower() == "mn" or d["Sex-Altered?"].lower() == "fs",
        1, 0)
    a.IdentichipNumber = d["Microchip"]
    if a.IdentichipNumber != "no chip found" and a.IdentichipNumber != "Unable to scan" and a.IdentichipNumber != "no" and a.IdentichipNumber != "":
        a.Identichipped = 1
    asm.breed_ids(a, d["Breed"], default=442)
    if d["Breed"].lower().find("mix") != -1 or d["Breed"].find("X") != -1:
        a.CrossBreed = 1
        a.Breed2ID = 442
    a.HiddenDetails = "Breed: %s\nColor: %s\nCollar: %s\nTags: %s\nMicrochip: %s\n" % (
        d["Breed"], d["Color"], d["Collar"], d["Tags"], d["Microchip"])
    a.Comments = d["Comments"]
    # Now create the owner
    if d["Owner's Name"] != "n/a" and d["Owner's Name"] != "" and d[
            "Owner's Name"] != "?" and d[
                "Owner's Name"] != "Went to Rescue" and d[
                    "Owner's Name"] != "unknown" and d["Address"] != "" and d[
                        "Address"] != "n/a":
        o = asm.Owner()
        owners.append(o)
        name = d["Owner's Name"]
        lastname = name
        firstname = ""
        if name.find(" ") != -1:
            firstname, lastname = name.split(" ", 1)
        ppo[name] = o
        o.OwnerForeNames = firstname
        o.OwnerSurname = lastname
        o.OwnerName = "%s, %s" % (lastname, firstname)
        o.OwnerAddress = d["Address"]
        o.OwnerTown = "Burnsville"
        o.OwnerCounty = "MN"
        o.HomeTelephone = d["Phone #"]
        # Reclaim if there's a date
        if releasedate is not None:
            m = asm.Movement()
            m.AnimalID = a.ID
            m.OwnerID = o.ID
            m.MovementType = 5
            m.MovementDate = releasedate
            a.Archived = 1
            a.ActiveMovementID = m.ID
            a.ActiveMovementType = 5
            a.LastChangedDate = m.MovementDate
            movements.append(m)
    # Was the animal euthanised?
    if "Euthanized" in d and d["Euthanized"] == "1":
        a.DeceasedDate = releasedate or intakedate
        a.PutToSleep = 1
        a.PTSReasonID = 4
        a.PTSReason = d["If Euthanized, Why?"]
        a.Archived = 1
    # Is this animal still on shelter? If so, we need to get it off with a fake reclaim
    if a.Archived == 0:
        m = asm.Movement()
        m.AnimalID = a.ID
        m.OwnerID = uo.ID
        m.MovementType = 5
        m.MovementDate = releasedate or intakedate
        a.Archived = 1
        a.ActiveMovementID = m.ID
        a.ActiveMovementType = 5
        a.LastChangedDate = m.MovementDate
        movements.append(m)
Esempio n. 12
0
 # Each row contains an animal
 a = asm.Animal()
 animals.append(a)
 ppa[d["ID"]] = a
 if d["Species"] == "Cat":
     a.AnimalTypeID = 11  # Unwanted Cat
 elif d["Species"] == "Dog":
     a.AnimalTypeID = 2  # Unwanted Dog
 else:
     a.AnimalTypeID = 40  # Misc
 a.SpeciesID = asm.species_id_for_name(d["Species"])
 a.AnimalName = d["Name"]
 if a.AnimalName.strip() == "":
     a.AnimalName = "(unknown)"
 a.DateBroughtIn = getdate(d["AddedDate"]) or asm.today()
 a.DateOfBirth = getdate(d["DOB"]) or asm.subtract_days(
     a.DateBroughtIn, 365)
 a.CreatedDate = getdate(d["AddedDate"])
 a.CreatedBy = d["AddedBy"]
 a.LastChangedDate = getdate(d["AddedDate"])
 a.LastChangedBy = d["AddedBy"]
 #if d["Intake Type"] == "Transfer In":
 #    a.IsTransfer = 1
 a.generateCode()
 a.IsNotAvailableForAdoption = 0
 a.Sex = asm.getsex_mf(d["Sex"])
 a.Size = 2
 a.Neutered = d["Altered"] == "TRUE" and 1 or 0
 a.EntryReasonID = 17  # Surrender
 a.IsGoodWithCats = 2
 a.IsGoodWithDogs = 2
 a.IsGoodWithChildren = 2
Esempio n. 13
0
    else:
        a.generateCode()
    a.AnimalName = d["Name"]

    broughtin = asm.today()
    if "Created" in d and d["Created"] != "":
        broughtin = getdate(d["Created"])
    if "Received Date" in d and d["Received Date"] != "":
        broughtin = getdate(d["Received Date"])
    a.DateBroughtIn = broughtin

    dob = broughtin
    a.EstimatedDOB = 1
    if "General Age" in d:
        if d["General Age"].find("Baby") != -1:
            dob = asm.subtract_days(asm.today(), 91)
        elif d["General Age"].find("Young") != -1:
            dob = asm.subtract_days(asm.today(), 182)
        elif d["General Age"].find("Adult") != -1:
            dob = asm.subtract_days(asm.today(), 730)
        elif d["General Age"].find("Senior") != -1:
            dob = asm.subtract_days(asm.today(), 2555)
    if "Birthdate" in d and d["Birthdate"] != "":
        dob = getdate(d["Birthdate"])
        a.EstimatedDOB = 0
    a.DateOfBirth = dob
    a.Sex = 1
    if d["Sex"].startswith("F"):
        a.Sex = 0
    
    breed1 = ""
Esempio n. 14
0
    if row["FINALOUTCO"] == "ANIMAL PICKED UP":
        ac.IncidentCompletedID = 2
    elif row["FINALOUTCO"] == "OTHER":
        ac.IncidentCompletedID = 6 # Does not exist in default data
    ac.IncidentTypeID = 1
    comments = "outcome: %s\n" % row["FINALOUTCO"]
    comments += "precinct: %s\n" % row["PRECINCT"]
    if notes.has_key(row["INCIDENTKE"]):
        comments += notes[row["INCIDENTKE"]]
    ac.CallNotes = comments
    ac.Sex = 2

# Run back through the animals, if we have any that are still
# on shelter after 2 years, add an adoption to an unknown owner
for a in animals:
    if a.Archived == 0 and a.DateBroughtIn < asm.subtract_days(asm.now(), 365*2):
        m = asm.Movement()
        m.AnimalID = a.ID
        m.OwnerID = uo.ID
        m.MovementType = 1
        m.MovementDate = a.DateBroughtIn
        a.Archived = 1
        a.ActiveMovementID = m.ID
        a.ActiveMovementDate = a.DateBroughtIn
        a.ActiveMovementType = 1
        movements.append(m)

# Now that everything else is done, output stored records
for a in animals:
    print a
for av in animalvaccinations:
Esempio n. 15
0
 a.SpeciesID = asm.species_id_for_name(d["Species"])
 a.generateCode()
 a.ShortCode = d["Animal ID"]
 a.ShelterCode = d["Animal ID"]
 ppa[d["Animal ID"]] = a
 a.AnimalName = d["Name"]
 if "Intake Date" in d: a.DateBroughtIn = getdate(d["Intake Date"])
 if a.DateBroughtIn is None and "Created Date" in d:
     a.DateBroughtIn = getdate(d["Created Date"])
 dob = a.DateBroughtIn
 a.EstimatedDOB = 1
 # Ages are stored as 2Y/ 4M/ 26D
 age = d["Age (Y/M/D)"]
 for b in age.split("/"):
     b = b.strip()
     if b.endswith("Y"): dob = asm.subtract_days(dob, 365 * asm.atoi(b))
     if b.endswith("M"): dob = asm.subtract_days(dob, 30 * asm.atoi(b))
     if b.endswith("D"): dob = asm.subtract_days(dob, asm.atoi(b))
 a.DateOfBirth = dob
 a.Sex = 1
 if d["Sex"].startswith("F"):
     a.Sex = 0
 primary = d["Primary Breed"]
 secondary = ""
 if "Secondary Breed" in d: secondary = d["Secondary Breed"]
 asm.breed_ids(a, primary, secondary, DEFAULT_BREED)
 a.BaseColourID = asm.colour_id_for_name(d["Primary Color"])
 if "Current Weight" in d and d["Current Weight"] != "":
     a.Weight = asm.atof(d["Current Weight"])
 a.HiddenAnimalDetails = "Age: %s, Breed: %s / %s, Color: %s" % (
     age, primary, secondary, d["Primary Color"])