Skip to content

Commit

Permalink
Merge pull request #435 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v4.29-beta
  • Loading branch information
marceloarocha authored Feb 3, 2025
2 parents feb8c9e + b8555fa commit 4a455ca
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 20 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.28-beta"
VERSION = "v4.29-beta"
FRONTEND_VERSION = "4.0.21"
ENV = getenv("ENV") or NoHarmENV.DEVELOPMENT.value
SECRET_KEY = getenv("SECRET_KEY") or "secret_key"
Expand Down
1 change: 1 addition & 0 deletions models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class NifiQueueActionTypeEnum(Enum):
CUSTOM_CALLBACK = "CUSTOM_CALLBACK"
REFRESH_TEMPLATE = "REFRESH_TEMPLATE"
UPDATE_PROPERTY = "UPDATE_PROPERTY"
VIEW_PROVENANCE = "VIEW_PROVENANCE"


class DrugAlertTypeEnum(Enum):
Expand Down
19 changes: 15 additions & 4 deletions routes/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,26 @@ def proxy_multiple():
ids_list = data.get("patients", [])
config = _get_config(user)
token = _get_token(config)
is_internal = config["getname"].get("internal", False)
auth_prefix = config["getname"].get("authPrefix", "")

CHUNK_SIZE = 200
chunks = [ids_list[i : i + CHUNK_SIZE] for i in range(0, len(ids_list), CHUNK_SIZE)]
names = []

for chunk in chunks:
names += _getname_multiple_iteration(config=config, ids_list=chunk, token=token)

return names, status.HTTP_200_OK


def _getname_multiple_iteration(config: dict, ids_list: list, token: str):
url = (
config["getname"]["urlDev"]
if Config.ENV == NoHarmENV.DEVELOPMENT.value
else config["getname"]["url"]
)
is_internal = config["getname"].get("internal", False)
auth_prefix = config["getname"].get("authPrefix", "")
names = []

try:
if is_internal:
Expand Down Expand Up @@ -137,7 +149,6 @@ def proxy_multiple():
)

found = []
names = []
if response.status_code == status.HTTP_200_OK:
data = response.json()
results = data if is_internal else data["data"]
Expand Down Expand Up @@ -178,7 +189,7 @@ def proxy_multiple():
}
)

return names, status.HTTP_200_OK
return names


@app_names.route("/names/auth-token", methods=["GET"])
Expand Down
1 change: 0 additions & 1 deletion services/admin/admin_ai_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import boto3
import tempfile
import numpy
import re
import gc
import logging
from typing import List
Expand Down
6 changes: 1 addition & 5 deletions services/admin/admin_drug_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,7 @@ def calculate_dosemax_uniq(id_drug: int, id_segment: int):
conversions = drugs_repository.get_conversions(id_drug=id_drug)

if not drug_attributes:
raise ValidationError(
"Registro inválido/inconsistente",
"errors.businessRules",
status.HTTP_400_BAD_REQUEST,
)
return None

attributes: DrugAttributes = drug_attributes[0].DrugAttributes
segment: Segment = drug_attributes[0].Segment
Expand Down
41 changes: 32 additions & 9 deletions services/admin/admin_integration_remote_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,21 @@ def _get_new_queue(id_processor: str, action_type: str, data: dict):
"config": {"properties": data["properties"]},
}
}
elif NifiQueueActionTypeEnum.VIEW_PROVENANCE.value == action_type:
queue.url = f"nifi-api/provenance"
queue.method = "POST"
queue.body = {
"provenance": {
"request": {
"maxResults": 100,
"summarize": True,
"incrementalResults": False,
"searchTerms": {
"ProcessorID": {"value": escape(id_processor), "inverse": False}
},
}
}
}

return queue

Expand Down Expand Up @@ -370,18 +385,26 @@ def get_errors(user_context: User):


def _validate_custom_endpoint(endpoint: str):
pattern1 = re.compile(
"^nifi-api\/flowfile-queues\/[\w-]{36}\/flowfiles\/[\w-]{36}\/content$"
patterns = []
patterns.append(
re.compile(
"^nifi-api\/flowfile-queues\/[\w-]{36}\/flowfiles\/[\w-]{36}\/content$"
)
)
patterns.append(
re.compile(
"^nifi-api\/flowfile-queues\/[\w-]{36}\/listing-requests\/[\w-]{36}$"
)
)
pattern2 = re.compile(
"^nifi-api\/flowfile-queues\/[\w-]{36}\/listing-requests\/[\w-]{36}$"
patterns.append(
re.compile("^nifi-api\/flowfile-queues\/[\w-]{36}\/flowfiles\/[\w-]{36}$")
)
patterns.append(re.compile("^nifi-api\/provenance-events\/\d*$"))
patterns.append(re.compile("^nifi-api\/provenance-events\/\d*\/content\/output$"))

if pattern1.match(endpoint):
return True

if pattern2.match(endpoint):
return True
for p in patterns:
if p.match(endpoint):
return True

raise ValidationError(
"Endpoint custom inválido",
Expand Down

0 comments on commit 4a455ca

Please sign in to comment.