od.DonationTypeID = 4 # Surrender if p["PMNT_CODE"] == "ADP": od.DonationTypeID = 2 for l in DBF("%s/LICENSE.DBF" % PATH): ol = asm.OwnerLicence() ownerlicences.append(ol) if ppo.has_key(l["OWNER_ID"]): o = ppo[l["OWNER_ID"]] ol.OwnerID = o.ID ol.LicenceTypeID = 1 ol.LicenceNumber = l["LIC_NUM"] ol.LicenceFee = int(l["FEE"] * 100) ol.IssueDate = l["LIC_DATE"] if ol.IssueDate is None: ol.IssueDate = asm.parse_date("2015-01-01", "%Y-%m-%d") ol.ExpiryDate = l["LIC_EXDATE"] if ol.ExpiryDate is None: ol.ExpiryDate = asm.parse_date("2015-01-01", "%Y-%m-%d") for c in DBF("%s/CMPLAINT.DBF" % PATH, encoding="cp1252"): ac = asm.AnimalControl() animalcontrol.append(ac) if c["FROM_ID"] != "" and ppo.has_key(c["FROM_ID"]): ac.CallerID = ppo[c["FROM_ID"]].ID if c["ABOUT_ID"] != "" and ppo.has_key(c["ABOUT_ID"]): ac.OwnerID = ppo[c["ABOUT_ID"]].ID ac.CallDateTime = c["C_DATE"] if ac.CallDateTime is None: ac.CallDateTime = asm.parse_date("2015-01-01", "%Y-%m-%d") ac.IncidentDateTime = ac.CallDateTime
def getdatetime(d, noblanks=False): rv = asm.parse_date(d, "%Y/%m/%d %H:%M:%S") if noblanks and rv is None: rv = asm.now() return rv
od.Date = p["PMNT_DATE"] od.DonationTypeID = 4 # Surrender if p["PMNT_CODE"] == "ADP": od.DonationTypeID = 2 for l in DBF("%s/LICENSE.DBF" % PATH): ol = asm.OwnerLicence() ownerlicences.append(ol) if ppo.has_key(l["OWNER_ID"]): o = ppo[l["OWNER_ID"]] ol.OwnerID = o.ID ol.LicenceTypeID = 1 ol.LicenceNumber = l["LIC_NUM"] ol.LicenceFee = int(l["FEE"] * 100) ol.IssueDate = l["LIC_DATE"] if ol.IssueDate is None: ol.IssueDate = asm.parse_date("2015-01-01", "%Y-%m-%d") ol.ExpiryDate = l["LIC_EXDATE"] if ol.ExpiryDate is None: ol.ExpiryDate = asm.parse_date("2015-01-01", "%Y-%m-%d") for c in DBF("%s/CMPLAINT.DBF" % PATH, encoding="cp1252"): ac = asm.AnimalControl() animalcontrol.append(ac) if c["FROM_ID"] != "" and ppo.has_key(c["FROM_ID"]): ac.CallerID = ppo[c["FROM_ID"]].ID if c["ABOUT_ID"] != "" and ppo.has_key(c["ABOUT_ID"]): ac.OwnerID = ppo[c["ABOUT_ID"]].ID ac.CallDateTime = c["C_DATE"] if ac.CallDateTime is None: ac.CallDateTime = asm.parse_date("2015-01-01", "%Y-%m-%d") ac.IncidentDateTime = ac.CallDateTime ac.DispatchDateTime = ac.CallDateTime
l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 1 l.Date = asm.now() l.Comments = row["Note"] asm.stderr("Process complaints") for row in ccomplaints: ac = asm.AnimalControl() ppac[row["tblComplaintsID"]] = ac animalcontrol.append(ac) ac.CallDateTime = asm.getdate_mmddyy(row["ReceivedDate"]) if ac.CallDateTime is None: ac.CallDateTime = asm.parse_date("2015-01-01", "%Y-%m-%d") ac.IncidentDateTime = ac.CallDateTime incidentname = asm.find_value(ccomplainttypes, "sysComplaintTypesID", row["sysComplaintTypesID"], "ComplaintType") ac.IncidentTypeID = asm.incidenttype_from_db(incidentname) ac.DispatchDateTime = ac.CallDateTime ac.CompletedDate = asm.getdate_mmddyy(row["StatusDate"]) if ac.CompletedDate is None: ac.CompletedDate = ac.CallDateTime ac.DispatchAddress = row["StreetNumber"] + " " + row["Street"] ac.DispatchTown = row["City"] ac.DispatchCounty = row["State"] ac.DispatchPostcode = row["ZipCode"] comments = "" if row["Location"].strip() != "": comments += "Location: %s" % row["Location"]
def getdate(d): return asm.parse_date(d, "%d.%m.%y")
a = ppo[row["tblKnownPersonsID"]] l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 1 l.Date = asm.now() l.Comments = row["Note"] for row in ccomplaints: ac = asm.AnimalControl() ppac[row["tblComplaintsID"]] = ac animalcontrol.append(ac) ac.CallDateTime = asm.getdate_mmddyy(row["ReceivedDate"]) if ac.CallDateTime is None: ac.CallDateTime = asm.parse_date("2015-01-01", "%Y-%m-%d") ac.IncidentDateTime = ac.CallDateTime incidentname = asm.find_value(ccomplainttypes, "sysComplaintTypesID", row["sysComplaintTypesID"], "ComplaintType") ac.IncidentTypeID = asm.incidenttype_from_db(incidentname) ac.DispatchDateTime = ac.CallDateTime ac.CompletedDate = asm.getdate_mmddyy(row["StatusDate"]) if ac.CompletedDate is None: ac.CompletedDate = ac.CallDateTime ac.DispatchAddress = row["StreetNumber"] + " " + row["Street"] ac.DispatchTown = row["City"] ac.DispatchCounty = row["State"] ac.DispatchPostcode = row["ZipCode"] comments = "" if row["Location"].strip() != "": comments += "Location: %s" % row["Location"] comments += "\nMO ID: %s" % row["tblComplaintsID"] ac.CallNotes = comments
#!/usr/bin/python3 import asm """ Import script for ARK DBF databases, covers people, animals, payments, events, licences and complaints 21st March, 2015 Last changed: 12th Mar, 2022 """ PATH = "/home/robin/tmp/asm3_import_data/ark_tp2734" START_ID = 1000 PICTURE_IMPORT = True BLANK_DATE = asm.parse_date("2015-01-01", "%Y-%m-%d") # Date used for licenses and incidents when the date was blank in ARK owners = [] ownerdonations = [] ownerlicences = [] movements = [] logs = [] animals = [] animalcontrol = [] ppa = {} ppo = {} arkspecies = { "C": 1, # Dog "F": 2, # Cat "E": 24,# Horse