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.
Completed
Push — master ( be813a...3d8811 )
by P.R.
06:43 queued 46s
created

Patient.normaliseer_geslacht_code()   A

Complexity

Conditions 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

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