def customizeClient(self, client): #print "==== Customize Client:", self.configurationRec.odbid, self.person.person_id_id_num client.attrib["record_id"] = "CL-" + str(self.person.id) #client.attrib["external_id"] = self.person.person_id_id_num # JCS -this item is optional client.attrib["system_id"] = self.person.person_id_id_num # JCS just a guess ???? client.attrib["date_added"] = dateutils.fixDate(datetime.now()) client.attrib["date_updated"] = dateutils.fixDate(datetime.now())
def createEntryExit(self, entry_exits, EE): # Outer Node, one EntryExit(ssp) entry_exit = ET.SubElement(entry_exits, "EntryExit") entry_exit.attrib["record_id"] = "EE-"+str(EE.id) # ssp-idid-num looks like it ought to be unique, but isn't in sample input data, so append client id???? entry_exit.attrib["system_id"] = EE.site_service_participation_idid_num+"-"+EE.person.person_id_id_num # person.site_service_participations = relationship("SiteServiceParticipation", backref="person") entry_exit.attrib["date_added"] = dateutils.fixDate(datetime.now()) entry_exit.attrib["date_updated"] = dateutils.fixDate(datetime.now()) self.customizeEntryExit(entry_exit, EE) return entry_exit
def customizeEntryExit(self, entry_exit, EE): # Schema expects one of ( active, typeEntryExit, client, exitDate, reasonLeavingValue, reasonLeavingOther, # destinationValue, destinationOther, notes, group ) # There is no type in our input XML, nor a field in ssp. Schema needs {'basic', 'basic center program entry/exit', # 'hprp', 'hud', 'path', 'quick call', 'standard', 'transitional living program entry/exit'} type1 = ET.SubElement(entry_exit, "typeEntryExit") # JCS this is a fudge to pass validation type1.text = "basic" # "hud-40118" provider_id = ET.SubElement(entry_exit, "provider") provider_id.text = '%s' % self.configurationRec.providerid if EE.participation_dates_start_date <> "" and EE.participation_dates_start_date <> None: entry_date = ET.SubElement(entry_exit, "entryDate") entry_date.text = dateutils.fixDate(EE.participation_dates_start_date) if EE.participation_dates_end_date <> "" and EE.participation_dates_end_date <> None: exit_date = ET.SubElement(entry_exit, "exitDate") exit_date.text = dateutils.fixDate(EE.participation_dates_end_date) return
def customizeAssessmentData(self, assessment_data): if self.person.person_gender_unhashed <> "" and self.person.person_gender_unhashed <> None: persGender = ET.SubElement(assessment_data, "svpprofgender" ) #"gender") persGender.attrib["date_added"] = dateutils.fixDate(self.person.person_gender_unhashed_date_collected) persGender.attrib["date_effective"] = dateutils.fixDate(self.person.person_gender_unhashed_date_effective) persGender.text = str(self.person.person_gender_unhashed) # dob (Date of Birth) lots of:SVPPROFDOB a few:DATEOFBIRTH if self.person.person_date_of_birth_unhashed <> "" and self.person.person_date_of_birth_unhashed <> None: dob = ET.SubElement(assessment_data, "svpprofdob") dob.attrib["date_added"] = dateutils.fixDate(self.person.person_date_of_birth_unhashed_date_collected) dob.attrib["date_effective"] = dateutils.fixDate(datetime.now()) # No date effect. in Person dob.text = dateutils.fixDate(self.person.person_date_of_birth_unhashed) # Ethnicity lots of:SVPPROFETH a few:Ethnicity uses:ETHNICITYPickOption if self.person.person_ethnicity_unhashed <> "" and self.person.person_ethnicity_unhashed <> None: # Our Interpretpicklist basically has 2 options. The schema has 23 ethText = self.pickList.getValue("EthnicityPick",str(self.person.person_ethnicity_unhashed)) eth = ET.SubElement(assessment_data, "svpprofeth") eth.attrib["date_added"] = dateutils.fixDate(self.person.person_ethnicity_unhashed_date_collected) eth.attrib["date_effective"] = dateutils.fixDate(datetime.now()) # No date effect. in Person eth.text = ethText # str(self.person.person_ethnicity_unhashed) # Race more than one?? JCS for race in self.race: # JCS schema has 'RACEPickOption' - using existing RacePick for now raceText = self.pickList.getValue("RacePick",str(race.race_unhashed)) # print '==== race:', race.race_unhashed, raceText if raceText <> None: raceNode = ET.SubElement(assessment_data, "svpprofrace") # JCS "primaryrace" or "svpprofrace"? raceNode.attrib["date_added"] = dateutils.fixDate(race.race_date_collected) raceNode.attrib["date_effective"] = dateutils.fixDate(race.race_date_effective) raceNode.text = raceText for ph in self.ph: #print '==== ph person id:', ph.person_index_id #, ph.__dict__ # JCS - Fails if none - seen in going from tbc to here - but don't know if that ever happens hs = self.session.query(dbobjects.HousingStatus).filter(dbobjects.HousingStatus.person_historical_index_id == ph.id).one() hsText = self.pickList.getValue("HOUSINGSTATUSPickOption",hs.housing_status) #print '==== hs:', hsText if hsText <> None: housingStatus = ET.SubElement(assessment_data, "svp_hud_housingstatus") # JCS housingStatus.attrib["date_added"] = dateutils.fixDate(hs.housing_status_date_collected) housingStatus.attrib["date_effective"] = dateutils.fixDate(hs.housing_status_date_effective) housingStatus.text = hsText foster = self.session.query(dbobjects.FosterChildEver).filter(dbobjects.FosterChildEver.person_historical_index_id == ph.id).one() fosterText = self.pickList.getValue("ENHANCEDYESNOPickOption",str(foster.foster_child_ever)) if fosterText <> None: fosterEver = ET.SubElement(assessment_data, "x20wereyoueverafoster") # JCS fosterEver.attrib["date_added"] = dateutils.fixDate(foster.foster_child_ever_date_collected) fosterEver.attrib["date_effective"] = dateutils.fixDate(foster.foster_child_ever_date_effective) fosterEver.text = fosterText # length of stay at prior residence losapr = self.session.query(dbobjects.LengthOfStayAtPriorResidence).filter(dbobjects.LengthOfStayAtPriorResidence.person_historical_index_id == ph.id).one() losaprText = self.pickList.getValue("LENGTHOFTHESTAYPickOption",losapr.length_of_stay_at_prior_residence) #print '==== losapr:', losaprText if losaprText <> None: lengthOfStay = ET.SubElement(assessment_data, "hud_lengthofstay") # JCS lengthOfStay.attrib["date_added"] = dateutils.fixDate(losapr.length_of_stay_at_prior_residence_date_collected) lengthOfStay.attrib["date_effective"] = dateutils.fixDate(losapr.length_of_stay_at_prior_residence_date_effective) lengthOfStay.text = losaprText # "Prior Residence" becomes "typeoflivingsituation" tols = self.session.query(dbobjects.PriorResidence).filter(dbobjects.PriorResidence.person_historical_index_id == ph.id).one() tolsText = self.pickList.getValue("LIVINGSITTYPESPickOption",tols.prior_residence_code) #print '==== (prior) tols:', tolsText if tolsText <> None: priorLiving = ET.SubElement(assessment_data, "typeoflivingsituation") # JCS priorLiving.attrib["date_added"] = dateutils.fixDate(tols.prior_residence_code_date_collected) priorLiving.attrib["date_effective"] = dateutils.fixDate(tols.prior_residence_code_date_effective) priorLiving.text = tolsText # There's also a prior_residence_id_id_num populated with a 13 digit number as string JCS # Physical Disability - Boolean pdyn = self.session.query(dbobjects.PhysicalDisability).filter(dbobjects.PhysicalDisability.person_historical_index_id == ph.id).one() pdynText = pdyn.has_physical_disability #print '==== pdyn:', pdynText if pdynText <> None: physDisabYN = ET.SubElement(assessment_data, "svpphysicaldisabilit") # JCS physDisabYN.attrib["date_added"] = dateutils.fixDate(pdyn.has_physical_disability_date_collected) # This is required, but input is usually blank - something plugs in now() physDisabYN.attrib["date_effective"] = dateutils.fixDate(pdyn.has_physical_disability_date_effective) physDisabYN.text = pdynText # There is also a complex type "disabilities_1" # Veteran Status - Uses "ENHANCEDYESNOPickOption" which is a union, and allows anything vvs = self.session.query(dbobjects.VeteranVeteranStatus).filter(dbobjects.VeteranVeteranStatus.person_historical_index_id == ph.id).one() vvsText = vvs.veteran_status #print '==== vvs:', vvsText if vvsText <> None: vetStat = ET.SubElement(assessment_data, "veteran") # JCS vetStat.attrib["date_added"] = dateutils.fixDate(vvs.veteran_status_date_collected) vetStat.attrib["date_effective"] = dateutils.fixDate(vvs.veteran_status_date_effective) vetStat.text = vvsText