示例#1
0
def process_subjects(reportuid, ac):
    """ Handle people linked to an ac record
        VIC = victim, WIT = witness, OWN / SUS = suspect, ACO """
    for row in db.query("select * from ac_subject where reportuid = %s" %
                        reportuid):
        ck = "sub%s" % row.subjectuid
        if ck in ppo:
            o = ppo[ck]
        else:
            o = asm.Owner()
            owners.append(o)
            ppo[ck] = o
            o.OwnerForeNames = row.subjFirstName
            o.OwnerSurname = row.subjLastName
            if o.OwnerSurname is None or o.OwnerSurname == "":
                o.OwnerSurname = "Unknown"
            o.OwnerAddress = row.subjaddr1 + " " + row.subjaddr2
            o.OwnerTown = row.subjcity
            o.OwnerCounty = row.subjstate
            o.OwnerPostcode = row.subjzipcode
            o.HomeTelephone = row.subjphone1
            o.WorkTelephone = row.subjphone2
            o.MobileTelephone = row.subjphone3
            o.Comments = asm.strip("%s %s %s" %
                                   (row.physdescr, row.notes, row.statement))
        st = str(row.subject_type)
        if st.find("VIC") != -1:
            ac.VictimID = o.ID
        if st.find("WIT") != -1 or st.find("ACO") != -1:
            ac.CallerID = o.ID
        if st.find("OWN") != -1 or st.find("SUS") != -1:
            if ac.OwnerID == 0:
                ac.OwnerID = o.ID
            elif ac.Owner2ID == 0:
                ac.Owner2ID = o.ID
            elif ac.Owner3ID == 0:
                ac.Owner3ID = o.ID
示例#2
0
    caddress = open_dbf("address")
    caddrlink = open_dbf("addrlink")
canimal = open_dbf("animal")
if LICENCE_IMPORT: clicense = open_dbf("license")
cperson = open_dbf("person")
if SHELTER_IMPORT: cshelter = open_dbf("shelter")
if VACCINATION_IMPORT: cvacc = open_dbf("vacc")
if INCIDENT_IMPORT: cincident = open_dbf("incident")
if NOTE_IMPORT: cnote = open_dbf("note")

# Addresses if we have a separate file
if SEPARATE_ADDRESS_TABLE:
    for row in caddress:
        addresses[row["ADDRESSKEY"]] = {
            "address":
            asm.strip(row["ADDRESSSTR"]) + " " + asm.strip(row["ADDRESSST2"]) +
            " " + asm.strip(row["ADDRESSST3"]),
            "city":
            asm.strip(row["ADDRESSCIT"]),
            "state":
            asm.strip(row["ADDRESSSTA"]),
            "zip":
            asm.strip(row["ADDRESSPOS"])
        }
    # The link between addresses and people
    for row in caddrlink:
        addrlink[row["EVENTKEY"]] = row["ADDRLINKAD"]

# People
for row in cperson:
    o = asm.Owner()
示例#3
0
    ppo[str(row.CustUid)] = o
    o.OwnerTitle = row.Title
    o.OwnerSurname = row.LastName
    if o.OwnerSurname is None or o.OwnerSurname == "":
        o.OwnerSurname = row.OrgName
        o.OwnerType = 2
    if o.OwnerSurname is None: o.OwnerSurname = "Unknown"
    o.OwnerForeNames = row.FirstName
    o.OwnerAddress = "%s %s" % (row.Addr1, row.Addr2)
    o.OwnerTown = row.City
    o.OwnerCounty = row.State
    o.OwnerPostcode = row.Zip
    o.HomeTelephone = row.Phone1
    o.WorkTelephone = row.Phone2
    o.MobileTelephone = row.Phone3
    o.Comments = asm.strip(row.Comments)
    o.IsACO = asm.iif(row.ACOFlag == "Y", 1, 0)
    o.IsShelter = asm.iif(row.RescueFlag == "Y", 1, 0)
    o.IsFosterer = asm.iif(row.FosterFlag == "Y", 1, 0)
    o.IsMember = asm.iif(row.MailingList == "Y", 1, 0)
    o.EmailAddress = row.Email

# Animals/intake
for row in db.query("select animals.*, intake.Comments as IntakeComments, intake.CustUid as IntakeCustUid, " \
    "IntakeDTL1, IntakeDTL2, intake.ReasonCode " \
    #"coalesce((select descr from lookup where value = intake.ReasonCode limit 1), '') AS IntakeReason, " \
    #"coalesce((select descr from lookup where value = animals.Color limit 1), '') AS ColorName " \
    "from animals " \
    "left outer join intake on intake.RefUID = animals.IntakeRefUID " \
    "order by IntakeDTL1").list():
示例#4
0
canimal = dbfread.DBF("%s/animal.dbf" % PATH)
clicense = dbfread.DBF("%s/license.dbf" % PATH)
cperson = dbfread.DBF("%s/person.dbf" % PATH)
cshelter = dbfread.DBF("%s/shelter.dbf" % PATH)
cvacc = dbfread.DBF("%s/vacc.dbf" % PATH)
cincident = dbfread.DBF("%s/incident.dbf" % PATH)
cnote = dbfread.DBF("%s/note.dbf" % PATH)

# 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 = asm.strip(row["PETNAME"])
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    age = row["AGE"].split(" ")[0]
    # TODO: DOB is not always present in these things
    a.DateOfBirth = row["DOB"]
    if a.DateOfBirth is None: a.DateOfBirth = getdateage(age, row["ADDEDDATET"])
    a.DateBroughtIn = row["ADDEDDATET"]
    if a.DateBroughtIn is None:
        asm.stderr("Bad datebroughtin: '%s'" % row["ADDEDDATET"])
        a.DateBroughtIn = datetime.datetime.today()    
    a.LastChangedDate = a.DateBroughtIn
    a.CreatedDate = a.DateBroughtIn
    a.EntryReasonID = 4
    a.generateCode(gettypeletter(a.AnimalTypeID))
    a.Neutered = asm.cint(row["FIX"])