-
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 #259 from noharm-ai/develop
v2.00-beta
- Loading branch information
Showing
8 changed files
with
456 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
def search_results(prescriptions): | ||
list = [] | ||
|
||
for p in prescriptions: | ||
list.append({ | ||
'idPrescription': p[0].id, | ||
'admissionNumber': p[0].admissionNumber, | ||
'date': p[0].date.isoformat() if p[0].date else None, | ||
'status': p[0].status, | ||
'agg': p[0].agg, | ||
'birthdate': p[1].isoformat() if p[1] else None, | ||
'gender': p[2], | ||
'department': p[3] | ||
}) | ||
list.append( | ||
{ | ||
"idPrescription": p[0].id, | ||
"admissionNumber": p[0].admissionNumber, | ||
"date": p[0].date.isoformat() if p[0].date else None, | ||
"status": p[0].status, | ||
"agg": p[0].agg, | ||
"concilia": p[0].concilia, | ||
"birthdate": p[1].isoformat() if p[1] else None, | ||
"gender": p[2], | ||
"department": p[3], | ||
"admissionDate": p[4].isoformat() if p[4] else None, | ||
} | ||
) | ||
|
||
return list | ||
|
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,119 @@ | ||
import os | ||
from flask import Blueprint, request | ||
from flask_jwt_extended import jwt_required, get_jwt_identity | ||
|
||
from flask_api import status | ||
from models.main import * | ||
from models.appendix import * | ||
from models.segment import * | ||
from models.prescription import * | ||
from services.admin import drug_service | ||
from exception.validation_error import ValidationError | ||
|
||
app_admin_drug = Blueprint("app_admin_drug", __name__) | ||
|
||
|
||
@app_admin_drug.route("/admin/drug/attributes-list", methods=["POST"]) | ||
@jwt_required() | ||
def get_drug_list(): | ||
user = User.find(get_jwt_identity()) | ||
dbSession.setSchema(user.schema) | ||
request_data = request.get_json() | ||
|
||
list = drug_service.get_drug_list( | ||
has_price_conversion=request_data.get("hasPriceConversion", None), | ||
has_substance=request_data.get("hasSubstance", None), | ||
has_default_unit=request_data.get("hasDefaultUnit", None), | ||
has_prescription=request_data.get("hasPrescription", None), | ||
term=request_data.get("term", None), | ||
id_segment_list=request_data.get("idSegmentList", None), | ||
limit=request_data.get("limit", 10), | ||
offset=request_data.get("offset", 0), | ||
) | ||
|
||
result = [] | ||
for i in list: | ||
result.append( | ||
{ | ||
"idDrug": i[0], | ||
"name": i[1], | ||
"idSegment": i[2], | ||
"segment": i[3], | ||
"idMeasureUnitDefault": i[4], | ||
"idMeasureUnitPrice": i[5], | ||
"measureUnitPriceFactor": i[8], | ||
"price": i[6], | ||
"sctid": i[7], | ||
"substance": i[10], | ||
} | ||
) | ||
|
||
count = 0 | ||
if len(list) > 0: | ||
count = list[0][9] | ||
|
||
return { | ||
"status": "success", | ||
"count": count, | ||
"data": result, | ||
}, status.HTTP_200_OK | ||
|
||
|
||
@app_admin_drug.route("/admin/drug/price-factor", methods=["POST"]) | ||
@jwt_required() | ||
def update_price_factor(): | ||
data = request.get_json() | ||
user = User.find(get_jwt_identity()) | ||
dbSession.setSchema(user.schema) | ||
os.environ["TZ"] = "America/Sao_Paulo" | ||
|
||
id_drug = data.get("idDrug", None) | ||
id_segment = data.get("idSegment", None) | ||
factor = data.get("factor", None) | ||
|
||
try: | ||
drug_service.update_price_factor( | ||
id_drug=id_drug, | ||
id_segment=id_segment, | ||
factor=factor, | ||
user=user, | ||
) | ||
except ValidationError as e: | ||
return {"status": "error", "message": str(e), "code": e.code}, e.httpStatus | ||
|
||
return tryCommit(db, {"idSegment": id_segment, "idDrug": id_drug, "factor": factor}) | ||
|
||
|
||
@app_admin_drug.route("/admin/drug/add-default-units", methods=["POST"]) | ||
@jwt_required() | ||
def add_default_units(): | ||
user = User.find(get_jwt_identity()) | ||
dbSession.setSchema(user.schema) | ||
os.environ["TZ"] = "America/Sao_Paulo" | ||
|
||
try: | ||
result = drug_service.add_default_units(user=user) | ||
except ValidationError as e: | ||
return {"status": "error", "message": str(e), "code": e.code}, e.httpStatus | ||
|
||
return tryCommit(db, result.rowcount) | ||
|
||
|
||
@app_admin_drug.route("/admin/drug/copy-unit-conversion", methods=["POST"]) | ||
@jwt_required() | ||
def copy_unit_conversion(): | ||
data = request.get_json() | ||
user = User.find(get_jwt_identity()) | ||
dbSession.setSchema(user.schema) | ||
os.environ["TZ"] = "America/Sao_Paulo" | ||
|
||
try: | ||
result = drug_service.copy_unit_conversion( | ||
user=user, | ||
id_segment_origin=data.get("idSegmentOrigin", None), | ||
id_segment_destiny=data.get("idSegmentDestiny", None), | ||
) | ||
except ValidationError as e: | ||
return {"status": "error", "message": str(e), "code": e.code}, e.httpStatus | ||
|
||
return tryCommit(db, result.rowcount) |
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
Oops, something went wrong.