Skip to content

Commit

Permalink
Merge pull request #322 from noharm-ai/develop
Browse files Browse the repository at this point in the history
v3.07-beta
  • Loading branch information
marceloarocha authored Jun 5, 2024
2 parents 296767b + df3c225 commit c8cc74a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

@app.route("/version", methods=["GET"])
def getVersion():
return {"status": "success", "data": "v3.06-beta"}, status.HTTP_200_OK
return {"status": "success", "data": "v3.07-beta"}, status.HTTP_200_OK


@app.route("/exc", methods=["GET"])
Expand Down
7 changes: 6 additions & 1 deletion models/prescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,12 @@ def getPatients(
drugAttributes=[],
):
q = (
db.session.query(Prescription, Patient, Department.name.label("department"))
db.session.query(
Prescription,
Patient,
Department.name.label("department"),
func.count().over(),
)
.outerjoin(Patient, Patient.admissionNumber == Prescription.admissionNumber)
.outerjoin(
Department,
Expand Down
14 changes: 14 additions & 0 deletions routes/prescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def getPrescriptions():
"idPatient": str(p[0].idPatient),
"name": patient.admissionNumber,
"admissionNumber": patient.admissionNumber,
"idSegment": p[0].idSegment,
"birthdate": (
patient.birthdate.isoformat() if patient.birthdate else None
),
Expand All @@ -177,7 +178,15 @@ def getPrescriptions():
"isBeingEvaluated": prescription_service.is_being_evaluated(
p[0].features
),
"reviewType": p[0].reviewType,
"observation": observation,
"totalRecords": p[3],
"agg": p[0].agg,
"prescriptionAggId": gen_agg_id(
admission_number=p[0].admissionNumber,
id_segment=p[0].idSegment,
pdate=p[0].date,
),
}
)
)
Expand Down Expand Up @@ -514,6 +523,11 @@ def getPrescription(
"idHospital": prescription[0].idHospital,
"name": prescription[0].admissionNumber,
"agg": prescription[0].agg,
"prescriptionAggId": gen_agg_id(
admission_number=prescription[0].admissionNumber,
id_segment=prescription[0].idSegment,
pdate=prescription[0].date,
),
"concilia": prescription[0].concilia,
"conciliaList": conciliaList,
"admissionNumber": prescription[0].admissionNumber,
Expand Down
3 changes: 3 additions & 0 deletions routes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@ def get_period_filter(query, model, agg_date, is_pmc, is_cpoe):


def gen_agg_id(admission_number, id_segment, pdate):
if admission_number == None or id_segment == None or pdate == None:
return None

id = (pdate.year - 2000) * 100000000000000
id += pdate.month * 1000000000000
id += pdate.day * 10000000000
Expand Down
6 changes: 5 additions & 1 deletion services/admin/drug_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ def copy_drug_attributes(
"dialisavel",
"lactante",
"gestante",
"fkunidademedidacusto",
"custo",
]
set_attributes = []
for a in attributes:
Expand All @@ -393,7 +395,9 @@ def copy_drug_attributes(
coalesce(ma.sonda, false) as sonda,
coalesce(ma.naopadronizado, false) as naopadronizado,
coalesce(ma.linhabranca, false) as linhabranca,
coalesce(ma.dialisavel, false) as dialisavel
coalesce(ma.dialisavel, false) as dialisavel,
ma.fkunidademedidacusto,
ma.custo
from
{origin_schema}.medatributos ma
inner join {origin_schema}.medicamento m on (ma.fkmedicamento = m.fkmedicamento)
Expand Down
13 changes: 12 additions & 1 deletion services/admin/segment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from models.main import *
from models.appendix import *
from models.segment import *
from models.enums import RoleEnum
from models.enums import RoleEnum, IntegrationStatusEnum
from services.admin import integration_status_service

from exception.validation_error import ValidationError

Expand All @@ -26,6 +27,16 @@ def upsert_segment(id_segment, description, active, user):
status.HTTP_400_BAD_REQUEST,
)
else:
if (
integration_status_service.get_integration_status(user.schema)
== IntegrationStatusEnum.PRODUCTION.value
):
raise ValidationError(
"O processo de criação de segmentos foi desativado para integrações em Produção. Solicite criação manual.",
"errors.businessRules",
status.HTTP_400_BAD_REQUEST,
)

segment = Segment()

segment.description = description
Expand Down

0 comments on commit c8cc74a

Please sign in to comment.