Total Complexity | 11 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Coverage | 96.3% |
Changes | 0 |
1 | # ---------------------------------------------------------------------------------------------------------------------- |
||
2 | from typing import Optional, Any |
||
3 | |||
4 | LEN_DIAGNOSE_CODE = 4 |
||
5 | 1 | LEN_SPECIALISME_CODE = 4 |
|
6 | LEN_ZORG_ACTIVITEIT_CODE = 6 |
||
7 | 1 | LEN_ZORG_INSTELLING_CODE = 8 |
|
8 | 1 | LEN_ZORG_PRODUCT_CODE = 9 |
|
9 | 1 | LEN_ZORG_PRODUCT_GROEP_CODE = 6 |
|
10 | 1 | LEN_ZORG_TYPE_CODE = 2 |
|
11 | 1 | LEN_ZORG_VRAAG_CODE = 3 |
|
12 | 1 | ||
13 | 1 | ||
14 | 1 | # ---------------------------------------------------------------------------------------------------------------------- |
|
15 | def clean_bool(x: str) -> bool: |
||
16 | if x == '0': |
||
17 | return False |
||
18 | 1 | ||
19 | 1 | if x == '1': |
|
20 | 1 | return True |
|
21 | |||
22 | 1 | raise RuntimeError("Not a boolean value '%s'." % x) |
|
23 | 1 | ||
24 | |||
25 | # ---------------------------------------------------------------------------------------------------------------------- |
||
26 | def clean_code(code: str, lengte: int) -> str: |
||
27 | """ |
||
28 | Schoont een code van voor- en naloop whitespace en voorziet de code van het juiste aantal voorloop nullen. |
||
29 | 1 | ||
30 | :param str code: De code. |
||
31 | :param int lengte: De gewenste lengte van de code. |
||
32 | |||
33 | :rtype: str |
||
34 | """ |
||
35 | return code.zfill(lengte) |
||
36 | |||
37 | |||
38 | 1 | # ---------------------------------------------------------------------------------------------------------------------- |
|
39 | def clean_date(x: str) -> str: |
||
40 | if x == '': |
||
41 | return '9999-12-31' |
||
42 | 1 | ||
43 | 1 | return str(x) |
|
44 | 1 | ||
45 | |||
46 | 1 | # ---------------------------------------------------------------------------------------------------------------------- |
|
47 | def clean_int(x: Any, leeg: Optional[int] = None) -> Optional[int]: |
||
48 | if x == '' or not x: |
||
49 | return leeg |
||
50 | 1 | ||
51 | 1 | return int(x) |
|
52 | 1 | ||
53 | |||
54 | 1 | # ---------------------------------------------------------------------------------------------------------------------- |
|
55 | def clean_str(x: Any) -> Optional[str]: |
||
56 | if x == '': |
||
57 | return None |
||
58 | 1 | ||
59 | 1 | return str(x) |
|
60 | 1 | ||
62 |