def pre_populate_events_and_participants(self, n=2): model_events = self.model['events'] model_participants = self.model['event_participants'] for i in range(n): m_event = model_events.iloc[i] import datetime # todo missing fields address longitude latitude start_date = datetime.date.today() # m_event.date event_desc = 'hope1' # random.choice(['Party', 'BBQ', 'Family meeting']) location_dto = gen_location_dto( m_event.latitude, m_event.longitude, region_ref(self.regions['Voreingestellte Bundesländer']['uuid']), self.districts['Voreingestellter Landkreis']['uuid'] # m_event.address] ) # FIXME use the real place event_dto = gen_event_dto(event_desc, start_date, location_dto, Disease.CORONAVIRUS) # add participants m_participants = model_participants.query(f'id_event == {m_event.id}') participants = [] for m_particpant in m_participants.iterrows(): person = self._create_person(m_particpant[1]) particpant = EventParticipant(person, event_dto.uuid) participants.append(particpant) self.today.events.append(Event(event_dto, participants))
def _create_person(self, pers): from sormas import Sex date = pers.reporting_date birthdate_yyyy = None if type(date) is float else int(date.split('-')[0]) - pers.age lat = 0 if np.isnan(pers.latitude) else pers.latitude # Fixme 0 condition lon = 0 if np.isnan(pers.longitude) else pers.longitude # Fixme 0 condition location_dto = gen_location_dto( lat, lon, region_ref(self.regions['Voreingestellte Bundesländer']['uuid']), self.districts['Voreingestellter Landkreis']['uuid'] ) person = gen_person_dto( first_name=pers.first_name, last_name=pers.family_name, # todo other values like diverse sex=Sex.MALE if pers.sex == 'm' else Sex.FEMALE, birthdate_yyyy=birthdate_yyyy, address=location_dto, present_condition=PresentCondition.DEAD if pers.died else PresentCondition.ALIVE ) # todo use Person class? return person