diff --git a/constants.py b/constants.py index f8b0e2f..8f6f5be 100644 --- a/constants.py +++ b/constants.py @@ -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" diff --git a/controller/master_controller.py b/controller/master_controller.py index 7dcee32..d2207da 100644 --- a/controller/master_controller.py +++ b/controller/master_controller.py @@ -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) @@ -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: diff --git a/controller/transaction_controller.py b/controller/transaction_controller.py index ba3bb32..3017120 100644 --- a/controller/transaction_controller.py +++ b/controller/transaction_controller.py @@ -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, @@ -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"