Skip to content

Commit

Permalink
Merge pull request #426 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v4.21-beta
  • Loading branch information
marceloarocha authored Dec 29, 2024
2 parents a985103 + 0e0d0ea commit 9e21a97
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions models/requests/regulation_prioritization_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = []
Expand Down
19 changes: 11 additions & 8 deletions repository/regulation/reg_solicitation_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 8 additions & 1 deletion routes/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion services/admin/admin_integration_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions services/intervention_outcome_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand Down Expand Up @@ -391,6 +392,7 @@ def _get_outcome_dict(
else None
),
"interventionReason": outcome_data.reason,
"notes": intervention.notes,
},
}

Expand Down
31 changes: 31 additions & 0 deletions services/regulation/reg_solicitation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion services/support_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions services/user_admin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/utils_test_intervention.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"readonly": False,
"status": "s",
"updatedAt": "2024-10-20T10:18:12.925873",
"notes": "teste",
},
"idIntervention": 15,
"origin": {
Expand Down Expand Up @@ -258,6 +259,7 @@
"readonly": False,
"status": "s",
"updatedAt": "2024-10-21T09:14:02.677830",
"notes": "teste",
},
"idIntervention": 21,
"origin": {
Expand Down

0 comments on commit 9e21a97

Please sign in to comment.