-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #429 from noharm-ai/develop
v4.24-beta
- Loading branch information
Showing
23 changed files
with
872 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class SetFactorRequest(BaseModel): | ||
idDrug: int | ||
idSegment: int | ||
factor: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from sqlalchemy import text | ||
|
||
from models.main import db | ||
|
||
|
||
def update_dose_max(update_list: list[dict], schema: str): | ||
update_table = [] | ||
|
||
for item in update_list: | ||
update_table.append( | ||
f"""({item.get("idDrug")}, {item.get("idSegment")}, {item.get("dosemax", "null")}, {item.get("dosemaxWeight", "null")})""" | ||
) | ||
|
||
query = text( | ||
f""" | ||
with update_table as ( | ||
select * from (values {",".join(update_table)}) AS t (fkmedicamento, idsegmento, ref_dosemaxima, ref_dosemaxima_peso) | ||
) | ||
update | ||
{schema}.medatributos | ||
set | ||
ref_dosemaxima = update_table.ref_dosemaxima::float, | ||
ref_dosemaxima_peso = update_table.ref_dosemaxima_peso::float | ||
from | ||
update_table | ||
where | ||
update_table.fkmedicamento = {schema}.medatributos.fkmedicamento | ||
and update_table.idsegmento = {schema}.medatributos.idsegmento | ||
""" | ||
) | ||
|
||
db.session.execute(query) | ||
|
||
|
||
def copy_dose_max_from_ref(schema: str): | ||
query = text( | ||
f""" | ||
with update_table as ( | ||
select | ||
m.fkmedicamento, | ||
m.idsegmento, | ||
case | ||
when m.usapeso then m.ref_dosemaxima_peso | ||
else m.ref_dosemaxima | ||
end as dosemaxima | ||
from | ||
{schema}.medatributos m | ||
where | ||
m.dosemaxima is null | ||
and ( | ||
(m.usapeso = true and m.ref_dosemaxima_peso is not null) | ||
or | ||
((m.usapeso = false or m.usapeso is null) and m.ref_dosemaxima is not null) | ||
) | ||
) | ||
update | ||
{schema}.medatributos | ||
set | ||
dosemaxima = update_table.dosemaxima::float | ||
from | ||
update_table | ||
where | ||
update_table.fkmedicamento = {schema}.medatributos.fkmedicamento | ||
and update_table.idsegmento = {schema}.medatributos.idsegmento | ||
""" | ||
) | ||
|
||
return db.session.execute(query) |
Oops, something went wrong.