Exemplo n.º 1
0
def getdateage(age, arrivaldate):
    """ Returns a date adjusted for age. Age can be one of
        ADULT, PUPPY, KITTEN, SENIOR """
    d = asm.getdate_mmddyy(arrivaldate)
    if d == None: d = asm.now()
    if age == "ADULT":
        d = d - datetime.timedelta(days = 365 * 2)
    if age == "SENIOR":
        d = d - datetime.timedelta(days = 365 * 7)
    if age == "KITTEN":
        d = d - datetime.timedelta(days = 60)
    if age == "PUPPY":
        d = d - datetime.timedelta(days = 60)
    return d
Exemplo n.º 2
0
    "FVRC": 9,
    "FVRCP": 9,
    "FVCP": 9,
    "abies": 4,
    "elovax": 9
}

lastbroughtin = None
for d in ccats:
    # Each row contains an animal with intake info and sometimes outcome
    a = asm.Animal()
    animals[d["CatId"]] = a
    a.AnimalName = d["Name"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateBroughtIn = asm.getdate_mmddyy(d["IntakeDate"])
    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"])
    m.OwnerID = o.ID
    m.MovementType = 1
    m.MovementDate = getdate(row["ADOPTION"])
    a.Archived = 1
    a.ActiveMovementID = m.ID
    a.ActiveMovementDate = m.MovementDate
    a.ActiveMovementType = 1
    movements.append(m)

# Medical
for row in cmed:
    auid = row["ANIMAL NUMBER"]
    if auid.find("&") != -1: auid = auid[0:auid.find("&")]
    if not auid in ppa: continue
    a = ppa[auid]
    date = asm.getdate_mmddyy(row["DATE USED"])
    # Each row contains a vaccination or test
    if row["MED"].startswith("HW Test"):
        a.HeartwormTested = 1
        a.HeartwormTestDate = date
        a.HeartwormTestResult = row["NOTES"].find("gative") != -1 and 1 or 2
    elif row["MED"].startswith("Combo"):
        a.CombiTested = 1
        a.CombiTestDate = date
        a.CombiTestResult = row["NOTES"].find("gative") != -1 and 1 or 2
    else:
        av = asm.AnimalVaccination()
        animalvaccinations.append(av)
        av.DateRequired = date
        av.DateOfVaccination = date
        av.VaccinationID = 6
Exemplo n.º 4
0
        comments += "precinct: %s\n" % asm.strip(row["PRECINCT"])
        ac.CallNotes = comments
        ac.Sex = 2
        if "ANIMALKEY" in row:
            if row["ANIMALKEY"] in ppa:
                a = ppa[row["ANIMALKEY"]]
                animalcontrolanimals.append(
                    "INSERT INTO animalcontrolanimal (AnimalControlID, AnimalID) VALUES (%s, %s);"
                    % (ac.ID, a.ID))

# Notes as log entries
if NOTE_IMPORT:
    for row in cnote:
        eventtype = row["EVENTTYPE"]
        eventkey = row["EVENTKEY"]
        notedate = asm.getdate_mmddyy(row["NOTEDATE"])
        memo = row["NOTEMEMO"]
        if eventtype in [1, 3]:  # animal/intake or case notes
            if not eventkey in ppa: continue
            linkid = ppa[eventkey].ID
            ppa[eventkey].HiddenAnimalDetails += "\n" + memo
            l = asm.Log()
            logs.append(l)
            l.LogTypeID = 3
            l.LinkID = linkid
            l.LinkType = 0
            l.Date = notedate
            if l.Date is None:
                l.Date = asm.now()
            l.Comments = memo
        elif eventtype in [2, 5, 10]:  # person, case and incident notes
Exemplo n.º 5
0
def getdate(s):
    return asm.getdate_mmddyy(s)
Exemplo n.º 6
0
def getdate(s):
    if s.find("/1900") != -1 or s.find("/00") != -1: return None
    return asm.getdate_mmddyy(s)
Exemplo n.º 7
0
    ownermapbymasterid[o.ExtraID] = o
    ownermapbyname[o.OwnerName] = o
    ownermapbykey[o.OwnerForeNames + " " + o.OwnerSurname + " " + asm.fw(o.OwnerAddress)] = o

# On shelter animals are kept in a separate database table called RECORD
# with a slightly different layout to animalhistory
for row in asm.csv_to_list(PATH + "record.csv", strip=True):

    # Each row contains a new animal
    a = asm.Animal(nextanimalid)
    animals.append(a)
    animalmap[row["RECORDNUMBER"]] = a
    nextanimalid += 1
    a.ExtraID = row["RECORDNUMBER"]

    a.DateBroughtIn = asm.getdate_mmddyy(row["DATE"])
    if a.DateBroughtIn is None:
        a.DateBroughtIn = asm.now()
    a.AnimalTypeID = gettype(row["SPECIES"])
    if row["SPECIES"] == "Kitten":
        a.SpeciesID = 1
    elif row["SPECIES"] == "Puppy":
        a.SpeciesID = 2
    else:
        a.SpeciesID = asm.species_id_for_name(row["SPECIES"])
    a.generateCode(gettypeletter(a.AnimalTypeID))
    a.ShortCode = row["FORMNUM"]
    ob = row["BREEDID"]
    a.CrossBreed = 0
    if ob.find("Mix") != -1:
        a.CrossBreed = 1
Exemplo n.º 8
0
            o = ppo[row["tblKnownPersonsID"]]
            asm.additional_field("DriversLicense", 1, o.ID, row["Code"])

# animals
for row in canimals:
    if row["PrimaryIDString"] == "": continue
    a = asm.Animal()
    animals.append(a)
    ppa[row["tblAnimalsID"]] = a
    species = asm.find_value(cspecies, "sysSpeciesID", row["sysSpeciesID"], "CommonName")
    a.AnimalTypeID = 2
    a.SpeciesID = asm.species_id_for_name(asm.fw(species))
    a.AnimalName = row["Name"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateOfBirth = asm.getdate_mmddyy(row["DateOfBirth"])
    if a.DateOfBirth is None: a.DateOfBirth = asm.now()
    a.DateBroughtIn = asm.now()
    irow = asm.find_row(canimalintakes, "tblAnimalsID", row["tblAnimalsID"])
    if irow is not None:
        a.DateBroughtIn = asm.getdate_mmddyy(irow["DateReceived"])
    if a.DateBroughtIn is None:
        a.DateBroughtIn = asm.now()
    a.EntryReasonID = 1
    #a.generateCode(gettypeletter(a.AnimalTypeID))
    code = "MO" + asm.padleft(row["tblAnimalsID"], 6)
    a.ShelterCode = code
    a.ShortCode = code
    a.NeuteredDate = asm.getdate_mmddyy(row["SpayNeuterPerformedDate"])
    if a.NeuteredDate is not None:
        a.Neutered = 1
Exemplo n.º 9
0
# Start with animals
for row in canimal:
    a = asm.Animal()
    animals.append(a)
    ppa[row["ANIMALKEY"]] = a
    a.AnimalTypeID = gettype(row["ANIMLDES"])
    a.SpeciesID = asm.species_id_for_name(row["ANIMLDES"].split(" ")[0])
    a.AnimalName = row["PETNAME"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    age = row["AGE"].split(" ")[0]
    a.DateOfBirth = getdateage(age, row["ADDEDDATETIME"])
    # TODO: some have DOB
    # a.DateOfBirth = asm.getdate_yyyymmdd(row["DOB"])
    a.DateBroughtIn = asm.getdate_mmddyy(row["ADDEDDATETIME"])
    if a.DateBroughtIn is None:
        asm.stderr("Bad datebroughtin: '%s'" % row["ADDEDDATET"])
        a.DateBroughtIn = asm.now()
    a.EntryReasonID = 4
    #a.generateCode(gettypeletter(a.AnimalTypeID))
    a.ShelterCode = "SP%s" % row["ANIMALKEY"]
    a.ShortCode = a.ShelterCode
    a.Neutered = asm.cint(row["FIX"])
    a.Declawed = asm.cint(row["DECLAWED"])
    a.IsNotAvailableForAdoption = 0
    a.ShelterLocation = 1
    a.Sex = asm.getsex_mf(asm.fw(row["GENDER"]))
    a.Size = getsize(asm.fw(row["WEIGHT"]))
    a.BaseColourID = asm.colour_id_for_names(asm.fw(row["FURCOLR1"]), asm.fw(row["FURCOLR2"]))
    a.IdentichipNumber = row["MICROCHIP"]
Exemplo n.º 10
0
         a.AnimalTypeID = 11
 if d["SURR_ID"] != "":
     if ppo.has_key(d["SURR_ID"]):
         a.OriginalOwnerID = ppo[d["SURR_ID"]].ID
 a.generateCode()
 a.ShortCode = d["ID_NUM"]
 a.Sex = asm.getsex_mf(d["SEX"])
 a.ShelterLocationUnit = d["LOCATION"]
 a.BreedID = asm.breed_id_for_name(d["BREED"])
 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 = asm.getdate_mmddyy(d["DATE_SURR"])
 if a.DateBroughtIn is None: a.DateBroughtIn = asm.now()
 a.NeuteredDate = asm.getdate_mmddyy(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 asm.atoi(d["EUTH_USD"]) > 0:
     a.PutToSleep = 1
     a.Archived = 1
Exemplo n.º 11
0
for row in canimals:
    if row["PrimaryIDString"] == "": continue
    a = asm.Animal()
    animals.append(a)
    ppa[row["tblAnimalsID"]] = a
    species = asm.find_value(cspecies, "sysSpeciesID", row["sysSpeciesID"],
                             "CommonName")
    a.AnimalTypeID = 2
    a.SpeciesID = asm.species_id_for_name(asm.fw(species))
    a.AnimalName = row["Name"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateBroughtIn = DEFAULT_INTAKE_DATE
    irow = None
    if row["tblAnimalsID"] in intakes: irow = intakes[row["tblAnimalsID"]]
    if irow is not None and asm.getdate_mmddyy(
            irow["DateReceived"]) is not None:
        a.DateBroughtIn = asm.getdate_mmddyy(irow["DateReceived"])
    a.DateOfBirth = asm.getdate_mmddyy(row["DateOfBirth"])
    if a.DateOfBirth is None:
        a.DateOfBirth = a.DateBroughtIn
    a.CreatedDate = a.DateBroughtIn
    a.LastChangedDate = a.DateBroughtIn
    a.EntryReasonID = 1
    #a.generateCode(gettypeletter(a.AnimalTypeID))
    code = "MO" + asm.padleft(row["tblAnimalsID"], 6)
    a.ShelterCode = code
    a.ShortCode = code
    a.NeuteredDate = asm.getdate_mmddyy(row["SpayNeuterPerformedDate"])
    if a.NeuteredDate is not None:
        a.Neutered = 1
    # 1 = neutered, 2 = spayed, 3 = entire, 5 = unknown
Exemplo n.º 12
0
 if d["SURR_ID"] != "":
     if ppo.has_key(d["SURR_ID"]):
         a.OriginalOwnerID = ppo[d["SURR_ID"]].ID
 a.generateCode()
 a.ShortCode = d["ID_NUM"]
 a.Sex = asm.getsex_mf(d["SEX"])
 a.ShelterLocationUnit = d["LOCATION"]
 a.BreedID = asm.breed_id_for_name(d["BREED"])
 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 = asm.getdate_mmddyy(d["DATE_SURR"])
 if a.DateBroughtIn is None: a.DateBroughtIn = asm.now()
 a.NeuteredDate = asm.getdate_mmddyy(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 asm.atoi(d["EUTH_USD"]) > 0:
     a.PutToSleep = 1
     a.Archived = 1
Exemplo n.º 13
0
    "FVRC": 9,
    "FVRCP": 9,
    "FVCP": 9,
    "abies": 4,
    "elovax": 9
}

lastbroughtin = None
for d in ccats:
    # Each row contains an animal with intake info and sometimes outcome
    a = asm.Animal()
    animals[d["CatId"]] = a
    a.AnimalName = d["Name"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateBroughtIn = asm.getdate_mmddyy(d["IntakeDate"])
    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"])
Exemplo n.º 14
0
def getdate(d):
    return asm.getdate_mmddyy(d)
Exemplo n.º 15
0
def getdate(d):
    return asm.getdate_mmddyy(d)
Exemplo n.º 16
0
def getdate(s):
    if s.find("/1900") != -1 or s.find("/00") != -1: return None
    return asm.getdate_mmddyy(s)
Exemplo n.º 17
0
ccatinfo = asm.csv_to_list("data/sz1242_access/catinfo.csv", unicodehtml=True)
creturns = asm.csv_to_list("data/sz1242_access/returns.csv", unicodehtml=True)

for d in ccatinfo:
    a = asm.Animal()
    animals.append(a)
    ppa[d["CatName"]] = a
    a.AnimalTypeID = 12 # stray cat
    if d["AcquiredType"].startswith("County"):
        a.AnimalTypeID = 44 # county shelter cat
        a.TransferIn = 1
    a.SpeciesID = 2
    a.AnimalName = d["CatName"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateBroughtIn = asm.getdate_mmddyy(d["DateAcquired"])
    if a.DateBroughtIn is None:
        a.DateBroughtIn = asm.today()
    ea = asm.cint(d["EstimatedAge"])
    eu = d["EstimatedAgeUnits"]
    if eu.startswith("Week"):
        ea = ea * 7
    elif eu.startswith("Month"):
        ea = ea * 30.5
    elif eu.startswith("Year"):
        ea = ea * 365
    a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, ea)
    if a.DateOfBirth is None:
        a.DateOfBirth = asm.today()
    a.CreatedDate = a.DateBroughtIn
    a.LastChangedDate = a.DateBroughtIn