mbu-dev-shared-components 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. mbu_dev_shared_components-0.3.0/PKG-INFO +45 -0
  2. mbu_dev_shared_components-0.3.0/README.md +26 -0
  3. mbu_dev_shared_components-0.3.0/mbu_dev_shared_components/solteqtand/db_handler.py +303 -0
  4. mbu_dev_shared_components-0.3.0/mbu_dev_shared_components.egg-info/PKG-INFO +45 -0
  5. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/pyproject.toml +1 -1
  6. mbu_dev_shared_components-0.2.0/PKG-INFO +0 -94
  7. mbu_dev_shared_components-0.2.0/README.md +0 -75
  8. mbu_dev_shared_components-0.2.0/mbu_dev_shared_components/solteqtand/db_handler.py +0 -251
  9. mbu_dev_shared_components-0.2.0/mbu_dev_shared_components.egg-info/PKG-INFO +0 -94
  10. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/LICENSE +0 -0
  11. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/getorganized/__init__.py +0 -0
  12. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/getorganized/auth.py +0 -0
  13. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/getorganized/cases.py +0 -0
  14. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/getorganized/contacts.py +0 -0
  15. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/getorganized/documents.py +0 -0
  16. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/getorganized/objects.py +0 -0
  17. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/google/__init__.py +0 -0
  18. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/google/api/__init__.py +0 -0
  19. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/google/api/auth.py +0 -0
  20. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/google/workspace/__init__.py +0 -0
  21. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/google/workspace/alerts.py +0 -0
  22. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/msoffice365/__init__.py +0 -0
  23. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/msoffice365/excel/__init__.py +0 -0
  24. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/msoffice365/excel/excel_reader.py +0 -0
  25. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/msoffice365/sharepoint_api/__init__.py +0 -0
  26. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/msoffice365/sharepoint_api/files.py +0 -0
  27. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/os2forms/__init__.py +0 -0
  28. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/os2forms/documents.py +0 -0
  29. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/os2forms/forms.py +0 -0
  30. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/sap/__init__.py +0 -0
  31. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/sap/create_invoice.py +0 -0
  32. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/solteqtand/__init__.py +0 -0
  33. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/solteqtand/app_handler.py +0 -0
  34. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/utils/__init__.py +0 -0
  35. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/utils/db_stored_procedure_executor.py +0 -0
  36. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/utils/fernet_encryptor.py +0 -0
  37. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/utils/file_handler.py +0 -0
  38. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components/utils/json_handler.py +0 -0
  39. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components.egg-info/SOURCES.txt +0 -0
  40. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components.egg-info/dependency_links.txt +0 -0
  41. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components.egg-info/requires.txt +0 -0
  42. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/mbu_dev_shared_components.egg-info/top_level.txt +0 -0
  43. {mbu_dev_shared_components-0.2.0 → mbu_dev_shared_components-0.3.0}/setup.cfg +0 -0
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.2
2
+ Name: mbu_dev_shared_components
3
+ Version: 0.3.0
4
+ Summary: Shared components to use in RPA projects
5
+ Author-email: MBU <rpa@mbu.aarhus.dk>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: openpyxl>=3.1.2
13
+ Requires-Dist: pyodbc>=5.1.0
14
+ Requires-Dist: requests_ntlm>=1.2.0
15
+ Requires-Dist: python-dateutil==2.9.*
16
+ Requires-Dist: cryptography>=43.0.0
17
+ Requires-Dist: office365-rest-python-client
18
+ Requires-Dist: uiautomation
19
+
20
+ # MBU Dev Shared Components
21
+
22
+ [![PyPI version](https://badge.fury.io/py/mbu-dev-shared-components.svg)](https://badge.fury.io/py/mbu-dev-shared-components)
23
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
24
+
25
+ ## Overview
26
+
27
+ MBU Dev Shared Components is a Python library that provides helper modules to streamline Robotic Process Automation (RPA) development.
28
+
29
+ ## Features
30
+
31
+ - **Office365 Integration**:
32
+ - SharePoint
33
+ - Excel
34
+ - **SAP Integration**
35
+ - **Solteq Tand Integration**
36
+ - **Utility Modules**:
37
+ - JSON handling
38
+ - Fernet encryption
39
+
40
+ ## Installation
41
+
42
+ Install the package using pip:
43
+
44
+ ```bash
45
+ pip install mbu-dev-shared-components
@@ -0,0 +1,26 @@
1
+ # MBU Dev Shared Components
2
+
3
+ [![PyPI version](https://badge.fury.io/py/mbu-dev-shared-components.svg)](https://badge.fury.io/py/mbu-dev-shared-components)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ ## Overview
7
+
8
+ MBU Dev Shared Components is a Python library that provides helper modules to streamline Robotic Process Automation (RPA) development.
9
+
10
+ ## Features
11
+
12
+ - **Office365 Integration**:
13
+ - SharePoint
14
+ - Excel
15
+ - **SAP Integration**
16
+ - **Solteq Tand Integration**
17
+ - **Utility Modules**:
18
+ - JSON handling
19
+ - Fernet encryption
20
+
21
+ ## Installation
22
+
23
+ Install the package using pip:
24
+
25
+ ```bash
26
+ pip install mbu-dev-shared-components
@@ -0,0 +1,303 @@
1
+ """
2
+ This module defines the SolteqTandDatabase class, which provides
3
+ an interface to interact with the Solteq Tand database.
4
+ """
5
+ import pyodbc
6
+
7
+
8
+ class SolteqTandDatabase:
9
+ """Handles database operations related to the Solteq Tand system."""
10
+
11
+ def __init__(self, conn_str: str):
12
+ """
13
+ Initializes the SolteqTandDatabase instance.
14
+
15
+ Args:
16
+ conn_str (str): Connection string to the Solteq Tand database.
17
+ """
18
+ self.connection_string = conn_str
19
+
20
+ def _execute_query(self, query: str, params: tuple):
21
+ """
22
+ Executes a SQL query with parameters and returns the results as a list of dictionaries.
23
+
24
+ Args:
25
+ query (str): The SQL query to execute.
26
+ params (tuple): The parameters for the SQL query.
27
+
28
+ Returns:
29
+ list: A list of dictionaries, where each dictionary represents a row from the query result.
30
+ """
31
+ conn = pyodbc.connect(self.connection_string)
32
+ cursor = conn.cursor()
33
+ cursor.execute(query, params)
34
+ rows = cursor.fetchall()
35
+ columns = [column[0] for column in cursor.description]
36
+
37
+ result = [dict(zip(columns, row)) for row in rows]
38
+
39
+ return result
40
+
41
+ def _construct_sql_statement(self, base_query, filters=None, or_filters=None): # noqa
42
+ """
43
+ Dynamically constructs a SQL query by applying filters.
44
+
45
+ Args:
46
+ base_query (str): The base SQL query with a WHERE clause.
47
+ filters (dict, optional): Key-value pairs for AND conditions.
48
+ or_filters (list of dict, optional): List of OR condition dictionaries.
49
+
50
+ Returns:
51
+ tuple: The final SQL query and the corresponding parameters.
52
+ """
53
+ params = []
54
+ where_clauses = []
55
+
56
+ # Handling AND filters
57
+ if filters:
58
+ for key, value in filters.items():
59
+ if isinstance(value, tuple) and len(value) == 2: # BETWEEN filtering
60
+ where_clauses.append(f"{key} BETWEEN ? AND ?")
61
+ params.extend(value)
62
+ elif isinstance(value, list): # IN filtering
63
+ placeholders = ", ".join("?" for _ in value)
64
+ where_clauses.append(f"{key} IN ({placeholders})")
65
+ params.extend(value)
66
+ elif isinstance(value, str) and "%" in value: # LIKE filtering
67
+ where_clauses.append(f"{key} LIKE ?")
68
+ params.append(value)
69
+ else: # Default equality filtering
70
+ where_clauses.append(f"{key} = ?")
71
+ params.append(value)
72
+
73
+ # Handling OR filters
74
+ or_clauses = []
75
+ if or_filters:
76
+ for or_filter in or_filters:
77
+ sub_clauses = []
78
+ sub_params = []
79
+ for key, value in or_filter.items():
80
+ if isinstance(value, list):
81
+ placeholders = ", ".join("?" for _ in value)
82
+ sub_clauses.append(f"{key} IN ({placeholders})")
83
+ sub_params.extend(value)
84
+ elif isinstance(value, str) and "%" in value:
85
+ sub_clauses.append(f"{key} LIKE ?")
86
+ sub_params.append(value)
87
+ else:
88
+ sub_clauses.append(f"{key} = ?")
89
+ sub_params.append(value)
90
+
91
+ if sub_clauses:
92
+ or_clauses.append(f"({' OR '.join(sub_clauses)})")
93
+ params.extend(sub_params)
94
+
95
+ # Adding AND filters
96
+ if where_clauses:
97
+ base_query += " AND " + " AND ".join(where_clauses)
98
+
99
+ # Adding OR filters
100
+ if or_clauses:
101
+ base_query += " AND (" + " OR ".join(or_clauses) + ")"
102
+
103
+ return base_query, params
104
+
105
+ def get_list_of_documents(self, filters=None, or_filters=None):
106
+ """
107
+ Retrieves a list of documents based on the specified filters.
108
+
109
+ Args:
110
+ filters (dict, optional): Filtering criteria for document retrieval.
111
+ or_filters (list of dict, optional): OR conditions for filtering.
112
+
113
+ Returns:
114
+ list: A list of document records matching the criteria.
115
+ """
116
+ base_query = """
117
+ WITH LatestActiveDocuments AS (
118
+ SELECT
119
+ ds.DocumentId,
120
+ ds.entityId,
121
+ ds.OriginalFilename,
122
+ ds.UniqueFilename,
123
+ ds.DocumentType,
124
+ ds.DocumentDescription,
125
+ ds.Priviledged,
126
+ ds.ContentType,
127
+ dss.Document_HistoryId,
128
+ dss.DocumentStoreStatusId,
129
+ dss.SentToNemSMS,
130
+ dss.Documented AS [DocumentCreatedDate],
131
+ dss.Decided AS [DocumentLastEditedDate],
132
+ ROW_NUMBER() OVER (
133
+ PARTITION BY ds.DocumentId
134
+ ORDER BY dss.Document_HistoryId DESC
135
+ ) AS rn
136
+ FROM [tmtdata_prod].[dbo].[DocumentStore] ds
137
+ JOIN DocumentStoreStatus dss ON ds.DocumentId = dss.DocumentId
138
+ )
139
+ SELECT
140
+ ds.DocumentId,
141
+ ds.entityId,
142
+ ds.OriginalFilename,
143
+ ds.UniqueFilename,
144
+ ds.DocumentType,
145
+ ds.DocumentDescription,
146
+ ds.DocumentCreatedDate,
147
+ ds.DocumentLastEditedDate,
148
+ ds.SentToNemSMS,
149
+ p.cpr
150
+ FROM [tmtdata_prod].[dbo].[PATIENT] p
151
+ JOIN LatestActiveDocuments ds ON ds.entityId = p.patientId
152
+ WHERE 1=1
153
+ """
154
+ final_query, params = self._construct_sql_statement(base_query, filters, or_filters)
155
+ return self._execute_query(final_query, params)
156
+
157
+ def get_list_of_extern_dentist(self, filters=None, or_filters=None):
158
+ """
159
+ Retrieves a list of external dentists associated with the patient.
160
+
161
+ Args:
162
+ filters (dict, optional): Filtering criteria for external dentists.
163
+ or_filters (list of dict, optional): OR conditions for filtering.
164
+
165
+ Returns:
166
+ list: A list of external dentist records.
167
+ """
168
+ base_query = """
169
+ SELECT [patientId]
170
+ ,[cpr]
171
+ ,[privateClinicId]
172
+ ,[c.contractorId]
173
+ ,[c.isPrimary]
174
+ ,[c.name]
175
+ ,[c.streetAddress]
176
+ ,[c.zip]
177
+ ,[c.phoneNumber]
178
+ FROM [tmtdata_prod].[dbo].[PATIENT] p
179
+ JOIN [CLINIC] c on c.clinicId = p.privateClinicId
180
+ WHERE 1=1
181
+ """
182
+ final_query, params = self._construct_sql_statement(base_query, filters, or_filters)
183
+ return self._execute_query(final_query, params)
184
+
185
+ def get_list_of_bookings(self, filters=None, or_filters=None):
186
+ """
187
+ Retrieves a list of bookings for the specified patient.
188
+
189
+ Args:
190
+ filters (dict, optional): Filtering criteria for booking retrieval.
191
+ or_filters (list of dict, optional): OR conditions for filtering.
192
+
193
+ Returns:
194
+ list: A list of booking records.
195
+ """
196
+ base_query = """
197
+ SELECT b.StartTime,
198
+ b.EndTime,
199
+ b.PatientNotified,
200
+ b.PatientNotifiedVia,
201
+ b.BookingText,
202
+ b.Warnings,
203
+ b.CreatedDateTime,
204
+ b.LastModifiedDateTime,
205
+ bt.Description,
206
+ bt.PrinterFriendlyText
207
+ FROM [tmtdata_prod].[dbo].[BOOKING] b
208
+ JOIN PATIENT p on p.patientId = b.patientId
209
+ JOIN BOOKINGTYPE bt on bt.BookingTypeID = b.BookingTypeID
210
+ WHERE 1=1
211
+ """
212
+ final_query, params = self._construct_sql_statement(base_query, filters, or_filters)
213
+ return self._execute_query(final_query, params)
214
+
215
+ def get_list_of_events(self, filters=None, or_filters=None):
216
+ """
217
+ Retrieves a list of events related to the patient.
218
+
219
+ Args:
220
+ filters (dict, optional): Filtering criteria for event retrieval.
221
+ or_filters (list of dict, optional): OR conditions for filtering.
222
+
223
+ Returns:
224
+ list: A list of event records matching the criteria.
225
+ """
226
+ base_query = """
227
+ SELECT e.[eventId],
228
+ e.[type],
229
+ e.[currentStateText],
230
+ e.[currentStateDate],
231
+ e.[timestamp],
232
+ e.[clinicId],
233
+ c.name,
234
+ e.[entityId],
235
+ e.[eventTriggerDate],
236
+ p.cpr,
237
+ e.archived
238
+ FROM [EVENT] e
239
+ JOIN [PATIENT] p ON p.patientId = e.entityId
240
+ JOIN [CLINIC] c ON c.clinicId = e.clinicId
241
+ WHERE 1=1
242
+ """
243
+ final_query, params = self._construct_sql_statement(base_query, filters, or_filters)
244
+ return self._execute_query(final_query, params)
245
+
246
+ def get_list_of_primary_dental_clinics(self, filters=None, or_filters=None):
247
+ """
248
+ Retrieves details of the primary dental clinics associated with the patient.
249
+
250
+ Args:
251
+ filters (dict, optional): Filtering criteria for clinic retrieval.
252
+ or_filters (list of dict, optional): OR conditions for filtering.
253
+
254
+ Returns:
255
+ list: A list of primary dental clinic details.
256
+ """
257
+ base_query = """
258
+ SELECT p.cpr,
259
+ p.patientId,
260
+ p.firstName,
261
+ p.lastName,
262
+ p.preferredDentalClinicId,
263
+ p.isPreferredDentalClinicLocked,
264
+ c.name AS preferredDentalClinicName
265
+ FROM [tmtdata_prod].[dbo].[PATIENT] p
266
+ JOIN [CLINIC] c ON c.clinicId = p.preferredDentalClinicId
267
+ WHERE 1=1
268
+ """
269
+ final_query, params = self._construct_sql_statement(base_query, filters, or_filters)
270
+ return self._execute_query(final_query, params)
271
+
272
+ def get_list_of_journal_notes(self, filters=None, or_filters=None):
273
+ """
274
+ Retrieves journal notes associated with the specified patient.
275
+
276
+ Args:
277
+ filters (dict, optional): Filtering criteria for journal note retrieval.
278
+ or_filters (list of dict, optional): OR conditions for filtering.
279
+
280
+ Returns:
281
+ list: A list of journal notes matching the criteria.
282
+ """
283
+ base_query = """
284
+ SELECT
285
+ dn.Beskrivelse,
286
+ ds.Dokumenteret,
287
+ ds.Besluttet,
288
+ ds.Art,
289
+ ds.EjerArt
290
+ FROM
291
+ [tmtdata_prod].[dbo].[Forloeb] f
292
+ JOIN
293
+ ForloebSymbolisering fs ON fs.ForloebID = f.ForloebID
294
+ JOIN
295
+ DiagnoseStatus ds ON ds.GEpjID = fs.DiagnoseID
296
+ JOIN
297
+ DiagnostikNotat dn ON dn.KontekstID = ds.KontekstID
298
+ JOIN
299
+ PATIENT p ON p.patientId = f.patientId
300
+ WHERE 1=1
301
+ """
302
+ final_query, params = self._construct_sql_statement(base_query, filters, or_filters)
303
+ return self._execute_query(final_query, params)
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.2
2
+ Name: mbu_dev_shared_components
3
+ Version: 0.3.0
4
+ Summary: Shared components to use in RPA projects
5
+ Author-email: MBU <rpa@mbu.aarhus.dk>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: openpyxl>=3.1.2
13
+ Requires-Dist: pyodbc>=5.1.0
14
+ Requires-Dist: requests_ntlm>=1.2.0
15
+ Requires-Dist: python-dateutil==2.9.*
16
+ Requires-Dist: cryptography>=43.0.0
17
+ Requires-Dist: office365-rest-python-client
18
+ Requires-Dist: uiautomation
19
+
20
+ # MBU Dev Shared Components
21
+
22
+ [![PyPI version](https://badge.fury.io/py/mbu-dev-shared-components.svg)](https://badge.fury.io/py/mbu-dev-shared-components)
23
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
24
+
25
+ ## Overview
26
+
27
+ MBU Dev Shared Components is a Python library that provides helper modules to streamline Robotic Process Automation (RPA) development.
28
+
29
+ ## Features
30
+
31
+ - **Office365 Integration**:
32
+ - SharePoint
33
+ - Excel
34
+ - **SAP Integration**
35
+ - **Solteq Tand Integration**
36
+ - **Utility Modules**:
37
+ - JSON handling
38
+ - Fernet encryption
39
+
40
+ ## Installation
41
+
42
+ Install the package using pip:
43
+
44
+ ```bash
45
+ pip install mbu-dev-shared-components
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mbu_dev_shared_components"
7
- version = "0.2.0" # Specify the version manually here
7
+ version = "0.3.0" # Specify the version manually here
8
8
  authors = [
9
9
  { name="MBU", email="rpa@mbu.aarhus.dk" },
10
10
  ]
@@ -1,94 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: mbu_dev_shared_components
3
- Version: 0.2.0
4
- Summary: Shared components to use in RPA projects
5
- Author-email: MBU <rpa@mbu.aarhus.dk>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Operating System :: Microsoft :: Windows
9
- Requires-Python: >=3.7
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: openpyxl>=3.1.2
13
- Requires-Dist: pyodbc>=5.1.0
14
- Requires-Dist: requests_ntlm>=1.2.0
15
- Requires-Dist: python-dateutil==2.9.*
16
- Requires-Dist: cryptography>=43.0.0
17
- Requires-Dist: office365-rest-python-client
18
- Requires-Dist: uiautomation
19
-
20
- # mbu-dev-shared-components
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install mbu-dev-shared-components
26
- ```
27
-
28
- ## Intro
29
-
30
- This python library contains helper modules for RPA development.
31
- It's based on the need of MBU, but it has been
32
- generalized to be useful for others as well.
33
-
34
- ## Integrations
35
-
36
- ### Office365
37
- #### - SharePoint
38
-
39
- Helper functions for using SharePoint api. A few examples include:
40
-
41
- - Authentication.
42
- - Get list of files from a specified folder.
43
- - Get file from folder.
44
- - Get files from folder.
45
-
46
-
47
- #### - Excel
48
-
49
- This module provides the ExcelReader class to read data from Excel files with .xlsx format.
50
-
51
- The ExcelReader class offers methods to read specific cells, rows, and convert the row data to JSON format.
52
- Additionally, it provides functionalities to count the total number of rows and nodes in the JSON data.
53
-
54
- - Read cell
55
- - Read cells
56
- - Read rows
57
- - Get row count
58
-
59
-
60
- ### SAP
61
- #### - Invoices
62
-
63
- This module provides the InvoiceCreator class to create invoices in SAP.
64
- The InvoiceCreator class offers methods to open a specified business partner, and creat an invoice.
65
-
66
- - Open business partner
67
- - Create invoice
68
-
69
-
70
- ### Solteq Tand
71
- #### - Application
72
- #### - Database
73
-
74
- This module provides the SolteqTandApp and SolteqTandDatabase class to handle patients data in Solteq Tand.
75
-
76
-
77
- ### Utils
78
- #### - JSON
79
- This module provides a class for manipulating JSON objects by transforming lists
80
- within the JSON into dictionaries with specified keys.
81
-
82
- The primary class in this module is JSONManipulator, which contains methods for
83
- converting lists associated with keys in a JSON object into dictionaries.
84
-
85
- - Transform all lists
86
- - Insert key value pairs
87
-
88
-
89
- #### - Fernet Encryptor
90
- This module provides a class for encrypting and decrypting data using the
91
- Fernet symmetric encryption algorithm.
92
-
93
- - Encrypts
94
- - Decrypts
@@ -1,75 +0,0 @@
1
- # mbu-dev-shared-components
2
-
3
- ## Installation
4
-
5
- ```bash
6
- pip install mbu-dev-shared-components
7
- ```
8
-
9
- ## Intro
10
-
11
- This python library contains helper modules for RPA development.
12
- It's based on the need of MBU, but it has been
13
- generalized to be useful for others as well.
14
-
15
- ## Integrations
16
-
17
- ### Office365
18
- #### - SharePoint
19
-
20
- Helper functions for using SharePoint api. A few examples include:
21
-
22
- - Authentication.
23
- - Get list of files from a specified folder.
24
- - Get file from folder.
25
- - Get files from folder.
26
-
27
-
28
- #### - Excel
29
-
30
- This module provides the ExcelReader class to read data from Excel files with .xlsx format.
31
-
32
- The ExcelReader class offers methods to read specific cells, rows, and convert the row data to JSON format.
33
- Additionally, it provides functionalities to count the total number of rows and nodes in the JSON data.
34
-
35
- - Read cell
36
- - Read cells
37
- - Read rows
38
- - Get row count
39
-
40
-
41
- ### SAP
42
- #### - Invoices
43
-
44
- This module provides the InvoiceCreator class to create invoices in SAP.
45
- The InvoiceCreator class offers methods to open a specified business partner, and creat an invoice.
46
-
47
- - Open business partner
48
- - Create invoice
49
-
50
-
51
- ### Solteq Tand
52
- #### - Application
53
- #### - Database
54
-
55
- This module provides the SolteqTandApp and SolteqTandDatabase class to handle patients data in Solteq Tand.
56
-
57
-
58
- ### Utils
59
- #### - JSON
60
- This module provides a class for manipulating JSON objects by transforming lists
61
- within the JSON into dictionaries with specified keys.
62
-
63
- The primary class in this module is JSONManipulator, which contains methods for
64
- converting lists associated with keys in a JSON object into dictionaries.
65
-
66
- - Transform all lists
67
- - Insert key value pairs
68
-
69
-
70
- #### - Fernet Encryptor
71
- This module provides a class for encrypting and decrypting data using the
72
- Fernet symmetric encryption algorithm.
73
-
74
- - Encrypts
75
- - Decrypts
@@ -1,251 +0,0 @@
1
- """
2
- This module defines the SolteqTandDatabase class, which provides
3
- an interface to interact with the Solteq Tand database.
4
- """
5
- import pyodbc
6
-
7
-
8
- class SolteqTandDatabase:
9
- """Handles database operations related to the Solteq Tand system."""
10
-
11
- def __init__(self, conn_str: str, ssn: str):
12
- """
13
- Initializes the SolteqTandDatabase instance.
14
-
15
- Args:
16
- conn_str (str): Connection string to the Solteq Tand database.
17
- ssn (str): Social Security Number (CPR) for identifying the patient.
18
- """
19
- self.connection_string = conn_str
20
- self.ssn = ssn
21
-
22
- def _execute_query(self, query: str, params: tuple):
23
- """
24
- Executes a query with the provided parameters and returns the result.
25
-
26
- Args:
27
- query (str): SQL query to execute.
28
- params (tuple): Parameters to include in the SQL query.
29
-
30
- Returns:
31
- list: A list of rows returned by the query, where each row is a dictionary.
32
- """
33
- conn = pyodbc.connect(self.connection_string)
34
- cursor = conn.cursor()
35
- cursor.execute(query, params)
36
- rows = cursor.fetchall()
37
- columns = [column[0] for column in cursor.description]
38
- result = {'data': dict(zip(columns, row)) for row in rows}
39
- return result
40
-
41
- def check_if_document_exists(self, filename: str, documenttype: str = None, form_id: str = None):
42
- """
43
- Checks if a document with the given filename exists for the specified patient,
44
- optionally filtering by document type and form ID.
45
-
46
- Args:
47
- filename (str): Name of the file to search for.
48
- documenttype (str, optional): Type of the document to filter by.
49
- form_id (str, optional): Form ID to filter by.
50
-
51
- Returns:
52
- list: A list of matching document records.
53
- """
54
- query = """
55
- WITH LatestActiveDocuments AS (
56
- SELECT
57
- ds.DocumentId,
58
- ds.entityId,
59
- ds.OriginalFilename,
60
- ds.UniqueFilename,
61
- ds.DocumentType,
62
- ds.DocumentDescription,
63
- ds.Priviledged,
64
- ds.ContentType,
65
- dss.Document_HistoryId,
66
- dss.DocumentStoreStatusId,
67
- dss.SentToNemSMS,
68
- dss.Documented AS [DocumentCreatedDate],
69
- dss.Decided AS [DocumentLastEditedDate],
70
- ROW_NUMBER() OVER (
71
- PARTITION BY ds.DocumentId
72
- ORDER BY dss.Document_HistoryId DESC
73
- ) AS rn
74
- FROM [tmtdata_prod].[dbo].[DocumentStore] ds
75
- JOIN DocumentStoreStatus dss ON ds.DocumentId = dss.DocumentId
76
- )
77
- SELECT
78
- ds.DocumentId,
79
- ds.entityId,
80
- ds.OriginalFilename,
81
- ds.UniqueFilename,
82
- ds.DocumentType,
83
- ds.DocumentDescription,
84
- ds.DocumentCreatedDate,
85
- ds.DocumentLastEditedDate,
86
- ds.SentToNemSMS,
87
- p.cpr
88
- FROM [tmtdata_prod].[dbo].[PATIENT] p
89
- JOIN LatestActiveDocuments ds ON ds.entityId = p.patientId
90
- WHERE ds.rn = 1
91
- AND ds.DocumentStoreStatusId = 1
92
- AND p.cpr = ?
93
- AND ds.OriginalFilename = ?
94
- """
95
-
96
- params = [self.ssn, filename]
97
-
98
- if documenttype:
99
- query += " AND ds.DocumentType = ?"
100
- params.append(documenttype)
101
-
102
- if form_id:
103
- query += " AND ds.DocumentDescription = ?"
104
- params.append(form_id)
105
-
106
- params = tuple(params)
107
-
108
- return self._execute_query(query, params)
109
-
110
- def check_extern_dentist(self):
111
- """
112
- Checks if the patient is associated with an external dentist.
113
- (This method is a placeholder and needs to be implemented based on specific requirements.)
114
- """
115
- query = """
116
- SELECT [patientId]
117
- ,[cpr]
118
- ,[privateClinicId]
119
- ,[c.contractorId]
120
- ,[c.isPrimary]
121
- ,[c.name]
122
- ,[c.streetAddress]
123
- ,[c.zip]
124
- ,[c.phoneNumber]
125
- FROM [tmtdata_prod].[dbo].[PATIENT] p
126
- JOIN [CLINIC] c on c.clinicId = p.privateClinicId
127
- WHERE cpr = ?
128
- """
129
- return self._execute_query(query, (self.ssn))
130
-
131
- def check_if_booking_exists(self):
132
- """
133
- Checks if any booking exists for the specified patient.
134
-
135
- Returns:
136
- list: A list of booking records for the patient.
137
- """
138
- query = """
139
- SELECT b.StartTime,
140
- b.EndTime,
141
- b.PatientNotified,
142
- b.PatientNotifiedVia,
143
- b.BookingText,
144
- b.Warnings,
145
- b.CreatedDateTime,
146
- b.LastModifiedDateTime,
147
- bt.Description,
148
- bt.PrinterFriendlyText
149
- FROM [tmtdata_prod].[dbo].[BOOKING] b
150
- JOIN PATIENT p on p.patientId = b.patientId
151
- JOIN BOOKINGTYPE bt on bt.BookingTypeID = b.BookingTypeID
152
- WHERE p.cpr = ?
153
- """
154
- return self._execute_query(query, (self.ssn,))
155
-
156
- def check_if_event_exists(self, event_name: str, event_message: str, is_archived: int = None):
157
- """
158
- Checks if a specific event exists for the patient based on the event name and message.
159
-
160
- Args:
161
- event_name (str): The name of the event (clinic name).
162
- event_message (str): The event message or state.
163
-
164
- Returns:
165
- list: A list of matching event records for the patient.
166
- """
167
- query = """
168
- SELECT e.[eventId],
169
- e.[type],
170
- e.[currentStateText],
171
- e.[currentStateDate],
172
- e.[timestamp],
173
- e.[clinicId],
174
- c.name,
175
- e.[entityId],
176
- e.[eventTriggerDate],
177
- p.cpr,
178
- e.archived
179
- FROM [EVENT] e
180
- JOIN [PATIENT] p ON p.patientId = e.entityId
181
- JOIN [CLINIC] c ON c.clinicId = e.clinicId
182
- WHERE p.cpr = ?
183
- AND c.name = ?
184
- AND e.currentStateText = ?
185
- """
186
- params = [self.ssn, event_name, event_message]
187
-
188
- if is_archived is not None:
189
- query += " AND e.archived = ?"
190
- params.append(is_archived)
191
-
192
- return self._execute_query(query, (params))
193
-
194
- def get_primary_dental_clinic(self):
195
- """
196
- Fetches the primary dental clinic details for the specified patient.
197
-
198
- Returns:
199
- dict: A dictionary containing patient and clinic details.
200
- """
201
- query = """
202
- SELECT p.cpr,
203
- p.patientId,
204
- p.firstName,
205
- p.lastName,
206
- p.preferredDentalClinicId,
207
- p.isPreferredDentalClinicLocked,
208
- c.name AS preferredDentalClinicName
209
- FROM [tmtdata_prod].[dbo].[PATIENT] p
210
- JOIN [CLINIC] c ON c.clinicId = p.preferredDentalClinicId
211
- WHERE p.cpr = ?
212
- """
213
- return self._execute_query(query, (self.ssn,))
214
-
215
- def get_journal_notes(self, note_message: str = None):
216
- """
217
- Fetches the journal notes for the specified patient.
218
-
219
- Returns:
220
- dict: A dictionary containing the journal notes.
221
- """
222
- query = """
223
- SELECT
224
- dn.Beskrivelse,
225
- ds.Dokumenteret,
226
- ds.Besluttet,
227
- ds.Art,
228
- ds.EjerArt
229
- FROM
230
- [tmtdata_prod].[dbo].[Forloeb] f
231
- JOIN
232
- ForloebSymbolisering fs ON fs.ForloebID = f.ForloebID
233
- JOIN
234
- DiagnoseStatus ds ON ds.GEpjID = fs.DiagnoseID
235
- JOIN
236
- DiagnostikNotat dn ON dn.KontekstID = ds.KontekstID
237
- JOIN
238
- PATIENT p ON p.patientId = f.patientId
239
- WHERE
240
- p.cpr = ?
241
- """
242
- params = [self.ssn]
243
-
244
- if note_message:
245
- query += " AND dn.Beskrivelse = ?"
246
- params.append(note_message)
247
-
248
- query += " ORDER BY ds.Dokumenteret DESC"
249
- params = tuple(params)
250
-
251
- return self._execute_query(query, params)
@@ -1,94 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: mbu_dev_shared_components
3
- Version: 0.2.0
4
- Summary: Shared components to use in RPA projects
5
- Author-email: MBU <rpa@mbu.aarhus.dk>
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Operating System :: Microsoft :: Windows
9
- Requires-Python: >=3.7
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: openpyxl>=3.1.2
13
- Requires-Dist: pyodbc>=5.1.0
14
- Requires-Dist: requests_ntlm>=1.2.0
15
- Requires-Dist: python-dateutil==2.9.*
16
- Requires-Dist: cryptography>=43.0.0
17
- Requires-Dist: office365-rest-python-client
18
- Requires-Dist: uiautomation
19
-
20
- # mbu-dev-shared-components
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install mbu-dev-shared-components
26
- ```
27
-
28
- ## Intro
29
-
30
- This python library contains helper modules for RPA development.
31
- It's based on the need of MBU, but it has been
32
- generalized to be useful for others as well.
33
-
34
- ## Integrations
35
-
36
- ### Office365
37
- #### - SharePoint
38
-
39
- Helper functions for using SharePoint api. A few examples include:
40
-
41
- - Authentication.
42
- - Get list of files from a specified folder.
43
- - Get file from folder.
44
- - Get files from folder.
45
-
46
-
47
- #### - Excel
48
-
49
- This module provides the ExcelReader class to read data from Excel files with .xlsx format.
50
-
51
- The ExcelReader class offers methods to read specific cells, rows, and convert the row data to JSON format.
52
- Additionally, it provides functionalities to count the total number of rows and nodes in the JSON data.
53
-
54
- - Read cell
55
- - Read cells
56
- - Read rows
57
- - Get row count
58
-
59
-
60
- ### SAP
61
- #### - Invoices
62
-
63
- This module provides the InvoiceCreator class to create invoices in SAP.
64
- The InvoiceCreator class offers methods to open a specified business partner, and creat an invoice.
65
-
66
- - Open business partner
67
- - Create invoice
68
-
69
-
70
- ### Solteq Tand
71
- #### - Application
72
- #### - Database
73
-
74
- This module provides the SolteqTandApp and SolteqTandDatabase class to handle patients data in Solteq Tand.
75
-
76
-
77
- ### Utils
78
- #### - JSON
79
- This module provides a class for manipulating JSON objects by transforming lists
80
- within the JSON into dictionaries with specified keys.
81
-
82
- The primary class in this module is JSONManipulator, which contains methods for
83
- converting lists associated with keys in a JSON object into dictionaries.
84
-
85
- - Transform all lists
86
- - Insert key value pairs
87
-
88
-
89
- #### - Fernet Encryptor
90
- This module provides a class for encrypting and decrypting data using the
91
- Fernet symmetric encryption algorithm.
92
-
93
- - Encrypts
94
- - Decrypts