From ef6d6db5cb0dfd1f05da6a72311341e31c3a8c3d Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Mon, 23 Dec 2024 14:59:23 -0300 Subject: [PATCH 01/11] reg: change type --- .../regulation/reg_solicitation_service.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/services/regulation/reg_solicitation_service.py b/services/regulation/reg_solicitation_service.py index 0648508e..ff773170 100644 --- a/services/regulation/reg_solicitation_service.py +++ b/services/regulation/reg_solicitation_service.py @@ -143,6 +143,13 @@ def move(request_data: RegulationMovementRequest, user_context: User): movement.data.get("transportationDate"), "%d/%m/%Y %H:%M" ) + update_reg_type = False + if "reg_type" in movement.data and movement.data.get("reg_type", None) != None: + update_reg_type = True + solicitation.id_reg_solicitation_type = movement.data.get( + "reg_type", {} + ).get("value") + db.session.flush() results.append( @@ -154,6 +161,18 @@ def move(request_data: RegulationMovementRequest, user_context: User): "transportationDate": dateutils.to_iso( solicitation.transportation_date ), + "regType": { + "type": ( + movement.data.get("reg_type", {}).get("label") + if update_reg_type + else None + ), + "idRegSolicitationType": ( + movement.data.get("reg_type", {}).get("value") + if update_reg_type + else None + ), + }, }, "movements": ( _get_movements(solicitation=solicitation) From 9ee4cdb7d65eb35f8ce1b701180e768d3a02c4df Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Mon, 23 Dec 2024 15:40:17 -0300 Subject: [PATCH 02/11] reg: change risk --- services/regulation/reg_solicitation_service.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/regulation/reg_solicitation_service.py b/services/regulation/reg_solicitation_service.py index ff773170..70b07f8c 100644 --- a/services/regulation/reg_solicitation_service.py +++ b/services/regulation/reg_solicitation_service.py @@ -150,12 +150,16 @@ def move(request_data: RegulationMovementRequest, user_context: User): "reg_type", {} ).get("value") + if "reg_risk" in movement.data: + solicitation.risk = movement.data.get("reg_risk") + db.session.flush() results.append( { "id": str(solicitation.id), "stage": solicitation.stage, + "risk": solicitation.risk, "extra": { "scheduleDate": dateutils.to_iso(solicitation.schedule_date), "transportationDate": dateutils.to_iso( From d96827db1b05b75336d676c2de6323f197289b9d Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 09:51:41 -0300 Subject: [PATCH 03/11] search names --- routes/names.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/routes/names.py b/routes/names.py index a6f0fb43..33570f8d 100644 --- a/routes/names.py +++ b/routes/names.py @@ -240,7 +240,14 @@ def search_name(term): data = response.json() results = [] for p in data["results"]: - results.append({"name": p["name"], "idPatient": p["idPatient"]}) + results.append( + { + "name": p["name"], + "idPatient": p["idPatient"], + "birthdate": p["dtnascimento"], + "number": p["cpf"], + } + ) return { "status": "success", From f32207b8183bd7762c666025317b59bce743c832 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 10:43:32 -0300 Subject: [PATCH 04/11] reg: undo schedules --- models/enums.py | 11 +++++++++++ services/regulation/reg_solicitation_service.py | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/models/enums.py b/models/enums.py index fbf3e55a..d845074c 100644 --- a/models/enums.py +++ b/models/enums.py @@ -183,3 +183,14 @@ class FrequencyEnum(Enum): CONT = 55 NOW = 66 UNDEFINED = 99 + + +class RegulationAction(Enum): + UPDATE_STAGE = 1 + SCHEDULE = 2 + SCHEDULE_TRANSPORT = 3 + SCHEDULE_EXTERNAL = 4 + UPDATE_TYPE = 5 + UPDATE_RISK = 6 + UNDO_SCHEDULE = 7 + UNDO_TRANSPORTATION_SCHEDULE = 8 diff --git a/services/regulation/reg_solicitation_service.py b/services/regulation/reg_solicitation_service.py index 70b07f8c..d4dbf40f 100644 --- a/services/regulation/reg_solicitation_service.py +++ b/services/regulation/reg_solicitation_service.py @@ -6,6 +6,7 @@ from models.regulation import RegSolicitation, RegSolicitationType, RegMovement from models.prescription import Patient from models.requests.regulation_movement_request import RegulationMovementRequest +from models.enums import RegulationAction from utils import dateutils, status from exception.validation_error import ValidationError @@ -153,6 +154,13 @@ def move(request_data: RegulationMovementRequest, user_context: User): if "reg_risk" in movement.data: solicitation.risk = movement.data.get("reg_risk") + # undo actions + if movement.action == RegulationAction.UNDO_SCHEDULE.value: + solicitation.schedule_date = None + + if movement.action == RegulationAction.UNDO_TRANSPORTATION_SCHEDULE.value: + solicitation.transportation_date = None + db.session.flush() results.append( From 9e89f4e3887c65d50a5f6266a4880d3f0570b474 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 10:56:09 -0300 Subject: [PATCH 05/11] reg: filter by protocol --- .../regulation_prioritization_request.py | 1 + .../regulation/reg_solicitation_repository.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/models/requests/regulation_prioritization_request.py b/models/requests/regulation_prioritization_request.py index 44d5e887..6c6bb2e9 100644 --- a/models/requests/regulation_prioritization_request.py +++ b/models/requests/regulation_prioritization_request.py @@ -18,6 +18,7 @@ class RegulationPrioritizationRequest(BaseModel): idDepartmentList: Optional[list[int]] = None typeType: Optional[int] = None riskList: Optional[list[int]] = None + idList: Optional[list[int]] = None typeList: Optional[list[str]] = [] stageList: Optional[list[int]] = [] idPatientList: Optional[list[int]] = [] diff --git a/repository/regulation/reg_solicitation_repository.py b/repository/regulation/reg_solicitation_repository.py index 8a8ffcd4..72924e3d 100644 --- a/repository/regulation/reg_solicitation_repository.py +++ b/repository/regulation/reg_solicitation_repository.py @@ -26,14 +26,17 @@ def get_prioritization(request_data: RegulationPrioritizationRequest): .outerjoin(Department, Department.id == RegSolicitation.id_department) ) - if request_data.startDate: - query = query.filter(RegSolicitation.date >= request_data.startDate.date()) - - if request_data.endDate: - query = query.filter( - RegSolicitation.date - <= (request_data.endDate + timedelta(hours=23, minutes=59)) - ) + if request_data.idList: + query = query.filter(RegSolicitation.id.in_(request_data.idList)) + else: + if request_data.startDate: + query = query.filter(RegSolicitation.date >= request_data.startDate.date()) + + if request_data.endDate: + query = query.filter( + RegSolicitation.date + <= (request_data.endDate + timedelta(hours=23, minutes=59)) + ) if request_data.scheduleStartDate: query = query.filter( From 7aa40f0669b2546b4bd3d05617cf4cdf9a31fb75 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 14:30:01 -0300 Subject: [PATCH 06/11] filter following tickets --- services/support_service.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/support_service.py b/services/support_service.py index a4330fd2..42c4e4c7 100644 --- a/services/support_service.py +++ b/services/support_service.py @@ -188,7 +188,7 @@ def list_tickets_v2(user_context: User, user_permissions: list[Permission]): options=options, ) - following = client( + following_all = client( model="helpdesk.ticket", action="search_read", payload=[ @@ -199,6 +199,12 @@ def list_tickets_v2(user_context: User, user_permissions: list[Permission]): options=options, ) + my_tickets_ids = [t.get("id") for t in my_tickets] + following = [] + for f in following_all: + if f.get("id") not in my_tickets_ids: + following.append(f) + if Permission.WRITE_USERS in user_permissions: organization = client( model="helpdesk.ticket", From 30657a1dd296117d5ac27baef988fe92b2af0e7d Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 16:47:43 -0300 Subject: [PATCH 07/11] show intv notes --- services/intervention_outcome_service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/intervention_outcome_service.py b/services/intervention_outcome_service.py index 6c962a67..b1096af1 100644 --- a/services/intervention_outcome_service.py +++ b/services/intervention_outcome_service.py @@ -263,6 +263,7 @@ def get_outcome_data(id_intervention, user_context: User, edit=False): else None ), "outcomeUser": (outcome_user.name if outcome_user != None else None), + "notes": intervention.notes, }, } @@ -391,6 +392,7 @@ def _get_outcome_dict( else None ), "interventionReason": outcome_data.reason, + "notes": intervention.notes, }, } From 1606b9997b3d7aea7e6dac31af3812ddc30691e6 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 16:48:13 -0300 Subject: [PATCH 08/11] v4.21-beta --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 2a33d242..904f30bf 100644 --- a/config.py +++ b/config.py @@ -5,7 +5,7 @@ class Config: - VERSION = "v4.20-beta" + VERSION = "v4.21-beta" FRONTEND_VERSION = "4.0.14" ENV = getenv("ENV") or NoHarmENV.DEVELOPMENT.value SECRET_KEY = getenv("SECRET_KEY") or "secret_key" From 20278765df8a5fecf4781b74212c10fec150f971 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Thu, 26 Dec 2024 16:53:40 -0300 Subject: [PATCH 09/11] intv fix tests --- tests/utils/utils_test_intervention.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/utils/utils_test_intervention.py b/tests/utils/utils_test_intervention.py index d6f64af3..1b8a32db 100644 --- a/tests/utils/utils_test_intervention.py +++ b/tests/utils/utils_test_intervention.py @@ -50,6 +50,7 @@ "readonly": False, "status": "s", "updatedAt": "2024-10-20T10:18:12.925873", + "notes": "teste", }, "idIntervention": 15, "origin": { @@ -258,6 +259,7 @@ "readonly": False, "status": "s", "updatedAt": "2024-10-21T09:14:02.677830", + "notes": "teste", }, "idIntervention": 21, "origin": { From 78e9a92640baf3f0f9ce592a72709098225fe254 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Fri, 27 Dec 2024 14:39:11 -0300 Subject: [PATCH 10/11] fix intg form --- services/admin/admin_integration_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/admin/admin_integration_service.py b/services/admin/admin_integration_service.py index 0e1a13ab..7286a627 100644 --- a/services/admin/admin_integration_service.py +++ b/services/admin/admin_integration_service.py @@ -163,7 +163,7 @@ def _set_new_config(old_config: dict, new_config: dict): elif "proxy" == config["getname"]["type"]: config["getname"]["url"] = new_config["getname"]["url"] config["getname"]["urlDev"] = new_config["getname"]["urlDev"] - config["getname"]["params"] = json.loads(new_config["getname"]["params"]) + config["getname"]["params"] = new_config["getname"]["params"] config["getname"]["token"] = { "url": new_config["getname"]["token"]["url"], "params": { From 0e0d0ead4951d4c594fb88ee7f72e497f88ad992 Mon Sep 17 00:00:00 2001 From: Marcelo Arocha Date: Fri, 27 Dec 2024 15:01:23 -0300 Subject: [PATCH 11/11] add regulator as valid role --- services/user_admin_service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/services/user_admin_service.py b/services/user_admin_service.py index 4f9a4f64..38bc858e 100644 --- a/services/user_admin_service.py +++ b/services/user_admin_service.py @@ -277,6 +277,7 @@ def _has_valid_roles(roles): Role.USER_MANAGER.value, Role.VIEWER.value, Role.DISPENSING_MANAGER.value, + Role.REGULATOR.value, ] for r in roles: