diff --git a/mobile.py b/mobile.py index f070a28c..87d95432 100644 --- a/mobile.py +++ b/mobile.py @@ -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"]) diff --git a/models/prescription.py b/models/prescription.py index e66a8749..06acdc18 100644 --- a/models/prescription.py +++ b/models/prescription.py @@ -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, diff --git a/routes/prescription.py b/routes/prescription.py index 67c36981..88e217d6 100644 --- a/routes/prescription.py +++ b/routes/prescription.py @@ -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 ), @@ -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, + ), } ) ) @@ -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, diff --git a/routes/utils.py b/routes/utils.py index 570d8a40..e8929ec8 100644 --- a/routes/utils.py +++ b/routes/utils.py @@ -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 diff --git a/services/admin/drug_service.py b/services/admin/drug_service.py index 9bc0920c..418dcb72 100644 --- a/services/admin/drug_service.py +++ b/services/admin/drug_service.py @@ -367,6 +367,8 @@ def copy_drug_attributes( "dialisavel", "lactante", "gestante", + "fkunidademedidacusto", + "custo", ] set_attributes = [] for a in attributes: @@ -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) diff --git a/services/admin/segment_service.py b/services/admin/segment_service.py index 65d7feda..5c2f7107 100644 --- a/services/admin/segment_service.py +++ b/services/admin/segment_service.py @@ -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 @@ -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