def gen_event_dto(event_desc=None, start_date=None, location=None, disease=None): if event_desc is None: raise NotImplementedError if start_date is None: raise NotImplementedError if location is None: raise NotImplementedError if disease is None: raise NotImplementedError event_dto = EventDto( uuid=duuid(), # todo EventFacade:163 not null fires event_status=EventStatus.EVENT, event_desc=event_desc, report_date_time=dnow(), reporting_user=surv_sup_user_ref(), start_date=start_date, event_location=location, disease=Disease.CORONAVIRUS # todo region + district is required in the UI! ) return event_dto
def gen_event_participant_dto(person_uuid, event_uuid): event_participant_dto = EventParticipantDto( uuid=duuid(), # todo triggers EventParticipantFacadeEjb:174 person=person_ref(person_uuid), event=event_ref(event_uuid) # todo creation date is not required ) return event_participant_dto
def gen_health_condition_dto(): health_condition_dto = HealthConditionsDto( uuid=duuid(), # todo must not be null ClinicalCourseFacadeRjb:133 ) return health_condition_dto #YesNoUnknown
def gen_contact_dto(person_uuid, case_uuid, disease): contact_dto = ContactDto( uuid=duuid(), # todo broken handling in backend ContactFacadeEjb:280 person=person_ref(person_uuid), report_date_time=dnow(), creation_date=dnow(), # todo required missing change_date=dnow(), # todo required missing reporting_user=surv_sup_user_ref(), last_contact_date=datetime.date.fromisoformat('2020-02-01'), disease=disease, caze=case_ref( case_uuid), # todo validation exception talking about region health_conditions=gen_health_condition_dto( ) # todo ContactFacadeRjb:1092 nullpointer if missing # todo contact classifaction is required in UI ) return contact_dto
def insert_region(region): with sormas_db_connect() as conn: with conn.cursor() as cur: cur.execute("SELECT uuid FROM region WHERE name=%s", [region]) exists = cur.fetchone()[0] if exists: print(f'{region} already exists in the DB') return exists cur.execute("SELECT id FROM region") all_ids = list(chain.from_iterable(cur.fetchall())) _id = max(all_ids) + 1 date = datetime.date.today() uuid = duuid() cur.execute( "INSERT INTO region (id,changedate, creationdate, name, uuid, epidcode, archived)" "VALUES (%s,%s, %s, %s, %s, %s, %s)", [_id, date, date, region, uuid, 'REG', False]) return uuid
def insert_district(district, region_id): with sormas_db_connect() as conn: with conn.cursor() as cur: cur.execute("SELECT uuid FROM district WHERE name=%s", [district]) exists = cur.fetchone()[0] if exists: logging.info(f'{district} already exists in the DB') return exists cur.execute("SELECT id FROM district") all_ids = list(chain.from_iterable(cur.fetchall())) _id = max(all_ids) + 1 date = datetime.date.today() uuid = duuid() cur.execute( "INSERT INTO district (id, changedate, creationdate, name, uuid, region_id, epidcode, archived)" "VALUES (%s,%s, %s, %s, %s, %s, %s, %s)", [_id, date, date, district, uuid, region_id, 'DIS', False]) return uuid
def gen_case_dto(date, p_uuid, disease, symptoms, case_classification=None, investigation_status=None, case_outcome=None, outcome_date=None): if case_classification is None: case_classification = get_case_classification() if investigation_status is None: investigation_status = get_investigation_status() if case_outcome is None or outcome_date is None: raise NotImplementedError # FIXME date needs to be more specified date = datetime.datetime.combine(datetime.date.fromisoformat(date), datetime.time(0, 0, 0)) case_dto = CaseDataDto( uuid=duuid(), disease=disease, person=person_ref( p_uuid), # FIXME case can be pushed without the person existing report_date=date, change_date=date, # FIXME not annotated as required creation_date=date, # FIXME not annotated as required reporting_user=surv_sup_user_ref(), case_classification=case_classification, investigation_status=investigation_status, region=default_region(), district=default_district(), health_facility=none_facility_ref( ), # FIXME not required, somewhat validated but without telling the user health_facility_details= "Home", # FIXME not required, somewhat validated but without telling the user symptoms=symptoms, outcome=case_outcome, outcome_date=outcome_date) return case_dto
def gen_location_dto(latitude=None, longitude=None, region=None, district=None): if latitude is None: raise NotImplementedError if longitude is None: raise NotImplementedError if region is None or district is None: raise NotImplementedError location_dto = LocationDto( uuid=duuid(), latitude=latitude, longitude=longitude, region=region, district=district, ) return location_dto
def gen_person_dto(first_name=None, last_name=None, sex=None, birthdate_yyyy=None, address=None, present_condition=None): if first_name is None: first_name = choice(male_first_names) if sex is Sex.MALE else choice(female_first_names) if last_name is None: last_name = choice(last_names) if sex is None: sex = choice([Sex.MALE, Sex.FEMALE]) if birthdate_yyyy is None: birthdate_yyyy = random.randrange(10, 90) # FIXME #fixme address can be none # Person extends PersonDto, but Person overwrites __str__ for better debugging person_dto = Person( uuid=duuid(), first_name=first_name, last_name=last_name, sex=sex, birthdate_yyyy=birthdate_yyyy, address=address, present_condition=present_condition ) return person_dto