Skip to content

Commit

Permalink
Fix-bug07-phase2
Browse files Browse the repository at this point in the history
- changed the constant value take_test_at to service_location
- raised an exception while updating the master lab result
  • Loading branch information
MonishaSivanathan committed Jan 13, 2025
1 parent be86c36 commit 9667332
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
PAYMENT_ID = "Payment Id"
PAYMENT_STATUS_TRANSACTION = "Payment Status"
PRICE_IN_DOLLAR = "Price in $"
TEST_TO_BE_TAKEN_AT = "Test To Be Taken At"
SERVICE_LOCATION = "Service Location"
SERVICE_CENTRE_LOCATION = "Service Centre Location"
TEST_NAME = "Test Name"
TRANSACTION_DATE = "Transaction Date"
Expand Down
7 changes: 6 additions & 1 deletion controller/master_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create_master_entries(table_name: str, data: CreateMasterModel):
code_values = MasterClient.get_by_code(MasterClient.table[table_name], data.code)
code_entry = code_values.get("entry", [])
if code_entry:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=f"Code already exists for {table_name}.")
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=f"Code already exists, Please use a unique code")
try:
MasterClient.validate_master_data(data)
master_data = MasterClient.fetch_data(table_name, data)
Expand Down Expand Up @@ -313,6 +313,11 @@ def fetch_data(table_name: str, coding: MasterModel):
def update_master_data(table_name: str, resource_id: str, data: CreateMasterModel):
if table_name not in MasterClient.table:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Kindly, verify the name.")
if data.code:
code_values = MasterClient.get_by_code(MasterClient.table[table_name], data.code)
code_entry = code_values.get("entry", [])
if not code_entry:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=f"Code does not exist, Please use a valid code")
try:
MasterClient.validate_master_data(data)
if data:
Expand Down
4 changes: 2 additions & 2 deletions controller/transaction_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PAYMENT_ID,
PAYMENT_STATUS_TRANSACTION,
PRICE_IN_DOLLAR,
TEST_TO_BE_TAKEN_AT,
SERVICE_LOCATION,
SERVICE_CENTRE_LOCATION,
TEST_NAME,
TRANSACTION_DATE,
Expand Down Expand Up @@ -302,7 +302,7 @@ def generate_and_return_csv(service_category: str, start_date: str, end_date: st
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="provide a valid query to download the file")
data = json_data['data']
df = pd.DataFrame(data)
df.columns = [PATIENT_ID, APPOINTMENT_ID, PATIENT_NAME, PAYMENT_ID, PAYMENT_STATUS_TRANSACTION, PRICE_IN_DOLLAR, TEST_TO_BE_TAKEN_AT,
df.columns = [PATIENT_ID, APPOINTMENT_ID, PATIENT_NAME, PAYMENT_ID, PAYMENT_STATUS_TRANSACTION, PRICE_IN_DOLLAR, SERVICE_LOCATION,
SERVICE_CENTRE_LOCATION, TEST_NAME, TRANSACTION_DATE, TRANSACTION_DATE_TIME, APPOINTMENT_DATE]
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
filename = f"{CSV_FILE_NAME}_{timestamp}.csv"
Expand Down

0 comments on commit 9667332

Please sign in to comment.