Example #1
0
    def create_dismissed_charge(
        cls,
        case_number=1,
        name="Theft of services",
        statute="164.125",
        level="Misdemeanor Class A",
        date=date_class(1901, 1, 1),
        violation_type="Offense Misdemeanor",
    ) -> Charge:
        cls.charge_count += 1
        disposition = DispositionCreator.create(date=date_class.today(),
                                                ruling="Dismissed")
        kwargs = {
            "case_number": case_number,
            "name": name,
            "statute": statute,
            "level": level,
            "date": date,
            "disposition": disposition,
            "violation_type": violation_type,
            "balance_due_in_cents": 0,
            "edit_status": EditStatus.UNCHANGED,
        }

        charges = ChargeCreator.create(str(cls.charge_count), **kwargs)[0]
        assert len(charges) == 1
        return charges[0]
Example #2
0
    def create_dismissed_charge(
        cls,
        case_number=1,
        name="Theft of services",
        statute="164.125",
        level="Misdemeanor Class A",
        date=date_class(1901, 1, 1),
        violation_type="Offense Misdemeanor",
    ) -> Charge:
        cls.charge_count += 1
        disposition = DispositionCreator.create(date=date_class.today(),
                                                ruling="Dismissed")
        kwargs = {
            "case_number": case_number,
            "name": name,
            "statute": statute,
            "level": level,
            "date": date.strftime("%m/%d/%Y"),
            "disposition": disposition,
            "violation_type": violation_type,
        }

        charges = ChargeCreator.create(cls.charge_count, **kwargs)[0]
        assert len(charges) == 1
        return charges[0]
 def _build_case(
         oeci_case: OeciCase) -> Tuple[AmbiguousCase, List[Question]]:
     ambiguous_charges: List[AmbiguousCharge] = []
     questions: List[Question] = []
     for oeci_charge in oeci_case.charges:
         ambiguous_charge_id = oeci_charge.ambiguous_charge_id
         charge_dict = {
             "name": oeci_charge.name,
             "statute": oeci_charge.statute,
             "level": oeci_charge.level,
             "date": oeci_charge.date,
             "disposition": oeci_charge.disposition,
             "probation_revoked": oeci_charge.probation_revoked,
             "case_number": oeci_case.summary.case_number,
             "violation_type": oeci_case.summary.violation_type,
             "birth_year": oeci_case.summary.birth_year,
         }
         ambiguous_charge, question = ChargeCreator.create(
             ambiguous_charge_id, **charge_dict)
         ambiguous_charges.append(ambiguous_charge)
         if question:
             questions.append(question)
     ambiguous_case: AmbiguousCase = []
     for charges in product(*ambiguous_charges):
         possible_case = Case(oeci_case.summary, charges=tuple(charges))
         ambiguous_case.append(possible_case)
     return ambiguous_case, questions
Example #4
0
 def __build_charge(
         charge_id, charge,
         case_parser_data) -> Tuple[AmbiguousCharge, Optional[Question]]:
     if case_parser_data.hashed_dispo_data.get(charge_id):
         disposition_data = case_parser_data.hashed_dispo_data[charge_id]
         date = datetime.date(
             datetime.strptime(
                 disposition_data.get("date"),
                 "%m/%d/%Y"))  # TODO: Log error if format is not correct
         ruling = disposition_data.get("ruling")
         charge["disposition"] = DispositionCreator.create(
             date, ruling, "amended" in disposition_data["event"].lower())
     return ChargeCreator.create(charge_id, **charge)
Example #5
0
 def _build_ambiguous_charge(cls, case_number, date, disposition, level,
                             name, statute, violation_type):
     cls.charge_count += 1
     if disposition and not date:
         date_string = disposition.date.strftime("%m/%d/%Y")
     elif date:
         date_string = date.strftime("%m/%d/%Y")
     else:
         date_string = "1/1/1901"
     kwargs = {
         "case_number": case_number,
         "name": name,
         "statute": statute,
         "level": level,
         "date": date_string,
         "disposition": disposition,
         "violation_type": violation_type,
     }
     charges = ChargeCreator.create(cls.charge_count, **kwargs)[0]
     return charges
 def _build_ambiguous_charge(cls, case_number, date, disposition, level,
                             name, statute, violation_type):
     cls.charge_count += 1
     if disposition and not date:
         updated_date = disposition.date
     elif date:
         updated_date = date
     else:
         updated_date = date_class(1901, 1, 1)
     kwargs = {
         "case_number": case_number,
         "name": name,
         "statute": statute,
         "level": level,
         "date": updated_date,
         "disposition": disposition,
         "violation_type": violation_type,
     }
     charges = ChargeCreator.create(str(cls.charge_count), **kwargs)[0]
     return charges
Example #7
0
 def _build_ambiguous_charge(cls, case_number, date, disposition, level,
                             name, statute, violation_type):
     cls.charge_count += 1
     if disposition.status != DispositionStatus.UNKNOWN and not date:
         updated_date = disposition.date
     elif date:
         updated_date = date
     else:
         updated_date = date_class(1901, 1, 1)
     kwargs = {
         "case_number": case_number,
         "name": name,
         "statute": statute,
         "level": level,
         "date": updated_date,
         "disposition": disposition,
         "violation_type": violation_type,
         "balance_due_in_cents": 0,
         "edit_status": EditStatus.UNCHANGED,
     }
     charges = ChargeCreator.create(str(cls.charge_count), **kwargs)[0]
     return charges
 def _build_case(
     oeci_case: OeciCase, new_charges: List[Charge]
 ) -> Tuple[AmbiguousCase, List[QuestionSummary]]:
     ambiguous_charges: List[AmbiguousCharge] = []
     questions: List[QuestionSummary] = []
     for oeci_charge in oeci_case.charges:
         ambiguous_charge_id = oeci_charge.ambiguous_charge_id
         charge_dict = {
             "name": oeci_charge.name,
             "statute": oeci_charge.statute,
             "level": oeci_charge.level,
             "date": oeci_charge.date,
             "disposition": oeci_charge.disposition,
             "probation_revoked": oeci_charge.probation_revoked,
             "balance_due_in_cents": oeci_charge.balance_due_in_cents,
             "case_number": oeci_case.summary.case_number,
             "violation_type": oeci_case.summary.violation_type,
             "birth_year": oeci_case.summary.birth_year,
             "edit_status": EditStatus(oeci_charge.edit_status),
         }
         if oeci_charge.disposition.status == DispositionStatus.UNKNOWN:
             charge_dict.pop("disposition")
             ambiguous_charge_dismissed, question_dismissed = ChargeCreator.create(
                 ambiguous_charge_id,
                 **charge_dict,
                 disposition=DispositionCreator.create(
                     date_class.today(), "dismissed"),
             )
             ambiguous_charge_convicted, question_convicted = ChargeCreator.create(
                 ambiguous_charge_id,
                 **charge_dict,
                 disposition=DispositionCreator.create(
                     date_class.future(), "convicted"),
             )
             if RecordCreator._disposition_question_is_irrelevant(
                     ambiguous_charge_convicted,
                     ambiguous_charge_dismissed):
                 ambiguous_charges.append(ambiguous_charge_dismissed)
                 question = RecordCreator._append_ambiguous_charge_id_to_question_id(
                     question_dismissed, ambiguous_charge_id
                 ) if question_dismissed else None  # type: ignore # TODO: Fix type
             else:
                 ambiguous_charges.append(ambiguous_charge_dismissed +
                                          ambiguous_charge_convicted)
                 disposition_question_text = "Choose the disposition"
                 question_id_prefix = ambiguous_charge_id + disposition_question_text
                 dismissed_option = RecordCreator._build_option(
                     question_dismissed, "Dismissed",
                     f"{question_id_prefix}-dismissed")
                 convicted_option = RecordCreator._build_option(
                     question_convicted, "Convicted",
                     f"{question_id_prefix}-convicted")
                 probation_revoked_option = RecordCreator._build_probation_revoked_option(
                     question_convicted, f"{question_id_prefix}-revoked")
                 unknown_option = {"Unknown": Answer()}
                 question = Question(
                     question_id_prefix,
                     disposition_question_text,
                     {
                         **dismissed_option,
                         **convicted_option,
                         **probation_revoked_option,
                         **unknown_option
                     },
                 )
         else:
             ambiguous_charge, maybe_question = ChargeCreator.create(
                 ambiguous_charge_id, **charge_dict)
             ambiguous_charges.append(ambiguous_charge)
             question = RecordCreator._append_ambiguous_charge_id_to_question_id(
                 maybe_question, ambiguous_charge_id
             ) if maybe_question else None  # type: ignore # TODO: Fix type
         if question:
             question_summary = QuestionSummary(
                 ambiguous_charge_id, oeci_case.summary.case_number,
                 question)
             questions.append(question_summary)
     ambiguous_charges += [[charge] for charge in new_charges]
     ambiguous_case: AmbiguousCase = []
     for charges in product(*ambiguous_charges):
         possible_case = Case(oeci_case.summary, charges=tuple(charges))
         ambiguous_case.append(possible_case)
     return ambiguous_case, questions