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" 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/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( 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", 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": { 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, }, } diff --git a/services/regulation/reg_solicitation_service.py b/services/regulation/reg_solicitation_service.py index 0648508e..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 @@ -143,17 +144,47 @@ 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") + + 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( { "id": str(solicitation.id), "stage": solicitation.stage, + "risk": solicitation.risk, "extra": { "scheduleDate": dateutils.to_iso(solicitation.schedule_date), "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) 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", 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: 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": {