Skip to content

Commit

Permalink
manual merge to new folder structure (#378)
Browse files Browse the repository at this point in the history
Co-authored-by: Chandra Y <[email protected]>
  • Loading branch information
davidmtacc and chandra-tacc authored Nov 26, 2024
1 parent 9cd2ed0 commit 9c23884
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
.submission-table td:nth-of-type(4):before { content: "Outcome"; }
.submission-table td:nth-of-type(5):before { content: "Status"; }
.submission-table td:nth-of-type(6):before { content: "Last Updated"; }
.submission-table td:nth-of-type(7):before { content: "Actions"; }
.submission-table td:nth-of-type(7):before { content: "Payor Code"; }
.submission-table td:nth-of-type(8):before { content: "Actions"; }
}
45 changes: 26 additions & 19 deletions apcd_cms/src/apps/submissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ def get(self, request, *args, **kwargs):

status = request.GET.get('status', 'All')
sort = request.GET.get('sort', 'Newest Received')
submitter_id = request.GET.get('submitterId', 'All')
payor_code = request.GET.get('payorCode', 'All')
page_number = int(request.GET.get('page', 1))
items_per_page = int(request.GET.get('limit', 50))

try:
submission_content = get_user_submissions_and_logs(request.user.username)
filtered_submissions = self.filtered_submissions(submission_content, status, sort)
filtered_submissions = self.filtered_submissions(submission_content, status, sort, submitter_id, payor_code)

paginator = Paginator(filtered_submissions, items_per_page)
page_info = paginator.get_page(page_number)
Expand All @@ -44,20 +47,18 @@ def get(self, request, *args, **kwargs):
except Exception as e:
logger.error("Error fetching filtered user data: %s", e)
return JsonResponse({'error': str(e)}, status=500)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update(self.get_view_submissions_json(get_user_submissions_and_logs(self.request.user.username)))
return context

def get_options(self, request):
try:
status_options = ['All', 'In Process', 'Complete']
sort_options = [
{'name': 'Newest Received', 'value': 'newDate'},
{'name': 'Oldest Received', 'value': 'oldDate'},
]

status_options = ['All', 'In Process', 'Complete']
sort_options = [{'name': 'Newest Received', 'value': 'newDate'},
{'name': 'Oldest Received', 'value': 'oldDate'}]

return JsonResponse({
'status_options': status_options,
'sort_options': sort_options,
Expand All @@ -66,40 +67,46 @@ def get_options(self, request):
logger.error("Error fetching options data: %s", e)
return JsonResponse({'error': str(e)}, status=500)

def filtered_submissions(self, submission_content, status, sort):
def filtered_submissions(self, submission_content, status, sort, submitter_id, payor_code):
def getDate(submission):
date = submission['received_timestamp']
return parser.parse(date) if date is not None else parser.parse('1-1-3005')

if status != 'All':
submission_content = [submission for submission in submission_content
if submission['status'].lower() == status.lower()]

submission_content = [submission for submission in submission_content
if submission['status'].lower() == status.lower()]

if submitter_id != 'All':
submission_content = [submission for submission in submission_content
if submission['submitter_id'] == int(submitter_id)]
if payor_code != 'All':
submission_content = [submission for submission in submission_content
if submission['payor_code'] == int(payor_code)]
submission_content = sorted(
submission_content,
key=lambda row: getDate(row),
reverse=(sort == 'Newest Received')
)
return submission_content

def get_view_submissions_json(self, submission_content, selected_status='All', selected_sort='Newest Received'):
def get_view_submissions_json(self, submission_content, selected_status='All', selected_sort='Newest Received', submission_id='All', payor_code='All'):
context = {
'page': [],
'selected_status': selected_status,
'selected_sort': selected_sort,
'pagination_url_namespaces':'submissions:list_submissions'
}

def _set_submissions(submission):
return {
'submission_id': submission['submission_id'],
'submitter_id': submission['submitter_id'],
'entity_name': submission['entity_name'],
'file_name': submission['file_name'],
'status': submission['status'],
'outcome': title_case(submission['outcome']) if submission['outcome'] else None,
'received_timestamp': submission['received_timestamp'],
'updated_at': submission['updated_at'],
'payor_code': submission['payor_code'],
'view_modal_content': submission['view_modal_content'],
}
for submission in submission_content:
Expand All @@ -112,4 +119,4 @@ def _set_submissions(submission):
def check_submitter_role(request):
logger.info("Checking submitter access for user: %s", request.user.username)

return JsonResponse({"is_submitter": has_apcd_group(request.user)})
return JsonResponse({"is_submitter": has_apcd_group(request.user)})
1 change: 1 addition & 0 deletions apcd_cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ def get_user_submissions_and_logs(user):
'outcome', submissions.outcome,
'received_timestamp', submissions.received_timestamp,
'updated_at', submissions.updated_at,
'payor_code', submissions.payor_code,
'view_modal_content', (
SELECT COALESCE(json_agg(json_build_object(
'log_id', submission_logs.log_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import * as Yup from 'yup';
import { ExtensionRow } from 'hooks/admin';
import { useEntities } from 'hooks/entities';
import QueryWrapper from 'core-wrappers/QueryWrapper';
import { convertPeriodLabelToApiValue, convertApiValueToPeriodLabel } from 'utils/dateUtil';
import {
convertPeriodLabelToApiValue,
convertApiValueToPeriodLabel,
} from 'utils/dateUtil';
import styles from './EditExtensionModal.module.css';
import FieldWrapper from 'core-wrappers/FieldWrapperFormik';
import Button from 'core-components/Button';
Expand Down Expand Up @@ -103,8 +106,10 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
const { ext_id } = values;
const api_values = {
...values,
'applicable_data_period': convertPeriodLabelToApiValue(values['applicable_data_period']),
}
applicable_data_period: convertPeriodLabelToApiValue(
values['applicable_data_period']
),
};
const url = `administration/update-extension/${ext_id}/`;

try {
Expand All @@ -120,7 +125,9 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
setUserFields([
{
label: 'Applicable Data Period',
value: convertApiValueToPeriodLabel(values.applicable_data_period) || 'None',
value:
convertApiValueToPeriodLabel(values.applicable_data_period) ||
'None',
},
{
label: 'Approved Expiration Date',
Expand Down Expand Up @@ -190,11 +197,11 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
<form onSubmit={formik.handleSubmit}>
<Row>
<Col md={3}>
<FieldWrapper
name="applicable_data_period"
label="Applicable Data Period"
required={false}
>
<FieldWrapper
name="applicable_data_period"
label="Applicable Data Period"
required={false}
>
<Field
as="select"
name="applicable_data_period"
Expand All @@ -219,17 +226,17 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
</option>
))}
</Field>
<div
className="help-text">
Current:{' '}{(extension.applicable_data_period)}
<div className="help-text">
Current: {extension.applicable_data_period}
</div>
</FieldWrapper>
</FieldWrapper>
</Col>
<Col md={3}>
<FieldWrapper
name="approved_expiration_date"
label="Approved Expiration Date"
required={false}>
required={false}
>
<Field
type="date"
name="approved_expiration_date"
Expand All @@ -242,22 +249,22 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
onChange={formik.handleChange}
onBlur={formik.handleBlur}
/>
<div
className="help-text"
>
<div className="help-text">
Current:{' '}
{extension.approved_expiration_date
? new Date(
extension.approved_expiration_date
).toLocaleDateString()
: 'None'}
</div>
</FieldWrapper>
</FieldWrapper>
</Col>
<Col md={3}>
<FieldWrapper name = "ext_status"
label="Exception Status"
required={false}>
<FieldWrapper
name="ext_status"
label="Exception Status"
required={false}
>
<Field
as="select"
name="ext_status"
Expand All @@ -279,11 +286,14 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
)
)}
</Field>
</FieldWrapper>
</FieldWrapper>
</Col>
<Col md={3}>
<FieldWrapper name="ext_outcome" label="Extension Outcome"
required={false}>
<FieldWrapper
name="ext_outcome"
label="Extension Outcome"
required={false}
>
<Field
as="select"
name="ext_outcome"
Expand All @@ -305,7 +315,7 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
</FieldWrapper>
</Col>
<Col md={6}>
<FieldWrapper name ="notes" label="Notes" required={false}>
<FieldWrapper name="notes" label="Notes" required={false}>
<Field
as="textarea"
name="notes"
Expand All @@ -315,21 +325,14 @@ const EditExtensionModal: React.FC<EditExtensionModalProps> = ({
onChange={formik.handleChange}
onBlur={formik.handleBlur}
/>
<div
className="help-text"
>
2000 character limit
</div>
<div className="help-text">2000 character limit</div>
</FieldWrapper>
</Col>
</Row>
<br />
<Alert
color="success"
isOpen={showSuccessMessage}
>
Success: The exception data has been successfully updated.
</Alert>
<Alert color="success" isOpen={showSuccessMessage}>
Success: The exception data has been successfully updated.
</Alert>
<Alert color="danger" isOpen={showErrorMessage}>
Error: {errorMessage}
</Alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useSubmissionFilters,
FileSubmissionLogsModalContent,
} from 'hooks/submissions';
import { Entities, useEntities } from 'hooks/entities';
import LoadingSpinner from 'core-components/LoadingSpinner';
import Button from 'core-components/Button';
import SectionMessage from 'core-components/SectionMessage';
Expand All @@ -23,6 +24,7 @@ export const ViewFileSubmissions: React.FC = () => {
'Outcome',
'Status',
'Last Updated',
'Payor Code',
'Actions',
];
const {
Expand All @@ -34,6 +36,9 @@ export const ViewFileSubmissions: React.FC = () => {
const [status, setStatus] = useState<string>('All');
const [sort, setSort] = useState<string>('Newest Received');
const [page, setPage] = useState<number>(1);
const [submitterId, setSubmitterId] = useState<string>('All');
const [payorCode, setPayorCode] = useState<string>('All');
const [submitterPayorCode, setSubmitterPayorCode] = useState<string>('All');
const [viewModalOpen, setViewModalOpen] = useState(false);
const [selectedSubmission, setSelectedSubmission] =
useState<FileSubmissionRow | null>(null);
Expand All @@ -51,12 +56,26 @@ export const ViewFileSubmissions: React.FC = () => {
isLoading: isSubmissionLoading,
isError: isSubmissionError,
refetch,
} = useListSubmissions(status, sort, page);
} = useListSubmissions(status, sort, submitterId, payorCode, page);

useEffect(() => {
if (submitterId && payorCode) {
setSubmitterPayorCode(`${submitterId},${payorCode}`);
} else {
setSubmitterPayorCode('All');
}
}, [submitterId, payorCode]);

useEffect(() => {
refetch();
}, [status, sort, page]);

const {
data: submitterData,
isLoading: entitiesLoading,
error: entitiesError,
} = useEntities();

if (isSubmissionLoading) {
return <LoadingSpinner />;
}
Expand All @@ -75,6 +94,8 @@ export const ViewFileSubmissions: React.FC = () => {
const clearSelections = () => {
setStatus('All');
setSort('Newest Received');
setSubmitterId('All');
setPayorCode('All');
setPage(1);
};

Expand Down Expand Up @@ -113,7 +134,38 @@ export const ViewFileSubmissions: React.FC = () => {
</option>
))}
</select>
{status !== 'All' || sort !== 'Newest Received' ? (
<span>
<b>Payor Code: </b>
</span>
<select
id="payorFilter"
className="status-filter"
value={submitterPayorCode}
onChange={(e) => {
if (e.target.value === 'All') {
setSubmitterId('All');
setPayorCode('All');
} else {
const [submitterId, payorCode] = e.target.value.split(',');
setSubmitterId(submitterId);
setPayorCode(payorCode);
}
}}
>
<option>All</option>
{submitterData?.submitters?.map((submitter: Entities) => (
<option
value={`${submitter.submitter_id},${submitter.payor_code}`}
key={`${submitter.submitter_id},${submitter.payor_code}`}
>
{submitter.entity_name} - Payor Code: {submitter.payor_code}
</option>
))}
</select>
{status !== 'All' ||
sort !== 'Newest Received' ||
submitterId !== 'All' ||
payorCode !== 'All' ? (
<button onClick={clearSelections}>Clear Options</button>
) : null}
</div>
Expand All @@ -137,6 +189,7 @@ export const ViewFileSubmissions: React.FC = () => {
<td>{titleCase(row.outcome)}</td>
<td>{titleCase(row.status)}</td>
<td>{formatDate(row.updated_at)}</td>
<td>{row.payor_code}</td>
<td>
<Button
type="link"
Expand Down
Loading

0 comments on commit 9c23884

Please sign in to comment.