|
| 1 | +from enum import Enum |
| 2 | +from typing import Optional, Dict |
| 3 | + |
| 4 | + |
| 5 | +class BowelScopeDDReasonForChangeType(Enum): |
| 6 | + """ |
| 7 | + Enum representing reasons for change to Bowel Scope Due Date. |
| 8 | +
|
| 9 | + Attributes: |
| 10 | + Ceased: Ceased |
| 11 | + DateOfBirthAmendment: Date of birth amendment |
| 12 | + EligibleToBeInvitedForFsScreening: Eligible to be invited for FS Screening |
| 13 | + FsScreeningEpisodeOpened: FS Screening episode opened |
| 14 | + MultipleDateOfBirthChanges: Multiple Date of Birth Changes |
| 15 | + NoLongerEligibleToBeInvitedForFsScreening: No longer eligible to be invited for FS Screening |
| 16 | + ReopenedFsEpisode: Reopened FS Episode |
| 17 | + SeekingFurtherData: Seeking further data |
| 18 | + """ |
| 19 | + |
| 20 | + Ceased = (200669, "Ceased") |
| 21 | + DateOfBirthAmendment = (205266, "Date of birth amendment") |
| 22 | + EligibleToBeInvitedForFsScreening = ( |
| 23 | + 200685, |
| 24 | + "Eligible to be invited for FS Screening", |
| 25 | + ) |
| 26 | + FsScreeningEpisodeOpened = (205002, "FS Screening episode opened") |
| 27 | + MultipleDateOfBirthChanges = (202426, "Multiple Date of Birth Changes") |
| 28 | + NoLongerEligibleToBeInvitedForFsScreening = ( |
| 29 | + 200668, |
| 30 | + "No longer eligible to be invited for FS Screening", |
| 31 | + ) |
| 32 | + ReopenedFsEpisode = (205012, "Reopened FS Episode") |
| 33 | + SeekingFurtherData = (200670, "Seeking further data") |
| 34 | + |
| 35 | + def __init__(self, valid_value_id: int, description: str): |
| 36 | + """ |
| 37 | + Initialize a BowelScopeDDReasonForChangeType enum member. |
| 38 | +
|
| 39 | + Args: |
| 40 | + valid_value_id (int): The unique identifier for the reason. |
| 41 | + description (str): The string description of the reason. |
| 42 | + """ |
| 43 | + self._valid_value_id: int = valid_value_id |
| 44 | + self._description: str = description |
| 45 | + |
| 46 | + @property |
| 47 | + def valid_value_id(self) -> int: |
| 48 | + """ |
| 49 | + Returns the unique identifier for the reason. |
| 50 | +
|
| 51 | + Returns: |
| 52 | + int: The valid value ID. |
| 53 | + """ |
| 54 | + return self._valid_value_id |
| 55 | + |
| 56 | + @property |
| 57 | + def description(self) -> str: |
| 58 | + """ |
| 59 | + Returns the string description of the reason. |
| 60 | +
|
| 61 | + Returns: |
| 62 | + str: The description. |
| 63 | + """ |
| 64 | + return self._description |
| 65 | + |
| 66 | + @classmethod |
| 67 | + def _descriptions(cls) -> Dict[str, "BowelScopeDDReasonForChangeType"]: |
| 68 | + """ |
| 69 | + Returns a mapping from description to enum member. |
| 70 | +
|
| 71 | + Returns: |
| 72 | + Dict[str, BowelScopeDDReasonForChangeType]: Mapping from description to enum member. |
| 73 | + """ |
| 74 | + return {item.description: item for item in cls} |
| 75 | + |
| 76 | + @classmethod |
| 77 | + def _lowercase_descriptions(cls) -> Dict[str, "BowelScopeDDReasonForChangeType"]: |
| 78 | + """ |
| 79 | + Returns a mapping from lowercase description to enum member. |
| 80 | +
|
| 81 | + Returns: |
| 82 | + Dict[str, BowelScopeDDReasonForChangeType]: Mapping from lowercase description to enum member. |
| 83 | + """ |
| 84 | + return {item.description.lower(): item for item in cls} |
| 85 | + |
| 86 | + @classmethod |
| 87 | + def _valid_value_ids(cls) -> Dict[int, "BowelScopeDDReasonForChangeType"]: |
| 88 | + """ |
| 89 | + Returns a mapping from valid value ID to enum member. |
| 90 | +
|
| 91 | + Returns: |
| 92 | + Dict[int, BowelScopeDDReasonForChangeType]: Mapping from valid value ID to enum member. |
| 93 | + """ |
| 94 | + return {item.valid_value_id: item for item in cls} |
| 95 | + |
| 96 | + @classmethod |
| 97 | + def by_description( |
| 98 | + cls, description: Optional[str] |
| 99 | + ) -> Optional["BowelScopeDDReasonForChangeType"]: |
| 100 | + """ |
| 101 | + Returns the enum member matching the given description (case-insensitive). |
| 102 | +
|
| 103 | + Args: |
| 104 | + description (Optional[str]): The description to search for. |
| 105 | +
|
| 106 | + Returns: |
| 107 | + Optional[BowelScopeDDReasonForChangeType]: The matching enum member, or None if not found. |
| 108 | + """ |
| 109 | + if description is None: |
| 110 | + return None |
| 111 | + return cls._lowercase_descriptions().get(description.lower()) |
| 112 | + |
| 113 | + @classmethod |
| 114 | + def by_valid_value_id( |
| 115 | + cls, valid_value_id: int |
| 116 | + ) -> Optional["BowelScopeDDReasonForChangeType"]: |
| 117 | + """ |
| 118 | + Returns the enum member matching the given valid value ID. |
| 119 | +
|
| 120 | + Args: |
| 121 | + valid_value_id (int): The valid value ID to search for. |
| 122 | +
|
| 123 | + Returns: |
| 124 | + Optional[BowelScopeDDReasonForChangeType]: The matching enum member, or None if not found. |
| 125 | + """ |
| 126 | + return cls._valid_value_ids().get(valid_value_id) |
0 commit comments