GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

kerapu.lbz.Patient.Patient.geslacht_code()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 8
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
class Patient:
2
    """
3
    Klasse voor patiëntenn.
4
    """
5
6 1
    # ------------------------------------------------------------------------------------------------------------------
7
    def __init__(self, geboorte_datum: str, geslacht_code: str):
8
        """
9
        Object constructor.
10
11
        :param str geboorte_datum: De geboortedatum van de patiënt.
12 1
        :param str geslacht_code: Het geslacht van de patiënt.
13
        """
14
        self.__geboorte_datum: str = geboorte_datum
15
        """
16
        De geboortedatum van de patiënt.
17
        """
18
19 1
        self.__geslacht_code: str = Patient.normaliseer_geslacht_code(geslacht_code)
20 1
        """
21
        Het geslacht van de patiënt.
22
        """
23 1
24 1
    # ------------------------------------------------------------------------------------------------------------------
25
    @property
26
    def geslacht_code(self) -> str:
27
        """
28
        Geeft het geslacht van deze patiënt.
29
30 1
        :rtype: str
31
        """
32
        return self.__geslacht_code
33 1
34
    # ------------------------------------------------------------------------------------------------------------------
35
    def leeftijd(self, datum: str) -> int:
36
        """
37
        Geeft de leeftijd van deze patient op een peildatum.
38
39
        :param str datum: De peildatum.
40
41 1
        :rtype: int
42
        """
43
        if not datum:
44 1
            raise RuntimeError("Datum is niet gespecificeerd.")
45
46
        if not self.__geboorte_datum:
47 1
            raise RuntimeError("Geboortedatum is niet gespecificeerd.")
48
49
        if datum < self.__geboorte_datum:
50
            raise RuntimeError("Leeftijd van patient gevraagd op datum (%s) voor geboortedatum (%s)." %
51 1
                               (datum, self.__geboorte_datum))
52 1
53 1
        age = int(datum[0:4]) - int(self.__geboorte_datum[0:4])
54
        if datum[-5:] < self.__geboorte_datum[-5:]:
55 1
            age -= 1
56
57
        return age
58 1
59 1
    # ------------------------------------------------------------------------------------------------------------------
60
    @staticmethod
61
    def normaliseer_geslacht_code(geslacht_code: str) -> str:
62
        """
63
        Normaliseert een geslachtscode naar 1 (man), 2 (vrouw) of 9 (anders).
64
65
        :param str geslacht_code: De geslachtscode.
66
67 1
        :rtype: str
68 1
        """
69
        if geslacht_code.upper() in ('1', 'M'):
70 1
            return '1'
71 1
72
        if geslacht_code.upper() in ('2', 'V', 'F'):
73
            return '2'
74
75
        return '9'
76
77
# ----------------------------------------------------------------------------------------------------------------------
78