-
Notifications
You must be signed in to change notification settings - Fork 1
Visitation Flow #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rodrigotiscareno
wants to merge
25
commits into
main
Choose a base branch
from
rt/visit-backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Visitation Flow #247
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
534cb89
routing
rodrigotiscareno d0d0d14
tweak
rodrigotiscareno d8a01e9
Link and Integrate PUT Case Submission Pt. 1 (#237)
JennyVong df593f7
checkpoint
rodrigotiscareno 1c259f8
checkpoint
rodrigotiscareno c75a85d
Add CreateVisitDTO class
helioshe4 25f7de8
database insertion work
rodrigotiscareno 2ba274f
Revert "Link and Integrate PUT Case Submission Pt. 1 (#237)"
rodrigotiscareno 30a3cac
ui tweaks
rodrigotiscareno be9d469
fixes for placeholders
rodrigotiscareno e036585
Merge branch 'main' into rt/visit-backend
7ebeb1f
Bug fixes on frontend about visitation data handling
d61cbcd
refresh validations to be less restrictive
rodrigotiscareno 53b4409
install cancel logic
rodrigotiscareno 6a9661e
fix visitation notes UI
rodrigotiscareno 323be11
fix child and family support worker ui and functionality
rodrigotiscareno 77ce02a
re-direct to home after submission
rodrigotiscareno 90c9b38
Merge branch 'main' into rt/visit-backend
04c946a
Fixed visit data collection (Transportaion and Attendance mainly)
173ecdd
Added POST and GET requests
vaaranan-y 215593a
fix buggy test
rodrigotiscareno d481cdd
visitation workflow tweaks
rodrigotiscareno 732aaf9
make duration ui integer-based
rodrigotiscareno 60ac3b1
fix enums for front-end
rodrigotiscareno 83d3662
support transport and visiting member backend functionality
rodrigotiscareno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
44 changes: 42 additions & 2 deletions
44
backend/python/app/services/implementations/visit_service.py
This file contains hidden or 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,10 +1,50 @@ | ||
| from ...models import db | ||
| from ..interfaces.visit_service import IVisitService | ||
| from ...resources.visit_dto import VisitDTO | ||
| from ...models.attendance_sheets import AttendanceSheets | ||
| from ...models.attendance_records import AttendanceRecords | ||
| from ...models.transportation_method import TransportationMethod | ||
|
|
||
|
|
||
| class VisitService(IVisitService): | ||
| def __init__(self, logger): | ||
| self.logger = logger | ||
|
|
||
| def create_visit(): | ||
| pass | ||
| def create_visit(self, visit: VisitDTO): | ||
| print(visit.__dict__, "visit") | ||
| try: | ||
| attendance_sheet = AttendanceSheets( | ||
| family_name=visit.childInformation["family_name"], | ||
| csw=visit.childInformation["child_service_worker"], | ||
| cpw=visit.childInformation["child_protection_worker"], | ||
| fcc=visit.childInformation["foster_care_coordinator"], | ||
| ) | ||
| db.session.add(attendance_sheet) | ||
| db.session.flush() | ||
|
|
||
| attendance_record = AttendanceRecords( | ||
| attendance_sheet_id=attendance_sheet.id, | ||
| visit_date=visit.visitTimestamp, | ||
| visit_day="visit_day_placeholder", | ||
| visit_supervision="PARTIAL", | ||
| start_time="start_time_placeholder", | ||
| end_time="end_time_placeholder", | ||
| location=visit.notes, | ||
| notes=visit.notes, | ||
| ) | ||
| db.session.add(attendance_record) | ||
|
|
||
| # TODO: Add a reference key to transportation method for the visit | ||
| transportation_entry = visit.transportation["entries"][0] | ||
| transportation_method_name = transportation_entry["name"] | ||
| attendance_record.notes += ( | ||
| f" Transportation Method: {transportation_method_name}" | ||
| ) | ||
|
|
||
| db.session.commit() | ||
|
|
||
| return {"message": "Visit created successfully"} | ||
| except Exception as error: | ||
| db.session.rollback() | ||
| self.logger.error(f"Error creating visit: {error}") | ||
| raise error |
This file contains hidden or 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 hidden or 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,80 @@ | ||
| import baseAPIClient from "./BaseAPIClient"; | ||
| import AUTHENTICATED_USER_KEY from "../constants/AuthConstants"; | ||
| import { getLocalStorageObjProperty } from "../utils/LocalStorageUtils"; | ||
| import { Case } from "../types/CasesContextTypes"; | ||
|
|
||
| interface Visit { | ||
| user_id: number; | ||
| case_id: number; | ||
| childDetails: { | ||
| familyName: string; | ||
| children: string[]; | ||
| childServiceWorker: string; | ||
| childProtectionWorker: string; | ||
| fosterCareCoordinator: string; | ||
| }; | ||
| visitDetails: { | ||
| visitDate: string; | ||
| visitDay: string; | ||
| visitSupervision: string; | ||
| startTime: string; | ||
| endTime: string; | ||
| location: string; | ||
| }; | ||
| attendanceEntries: { | ||
| visitingMembers: string; | ||
| visitorRelationship: string; | ||
| description: string; | ||
| visitingMemberName: string; | ||
| visitAttendance: string; | ||
| absenceReason: string; | ||
| }[]; | ||
| transportationEntries: { | ||
| gaurdian: string; | ||
| name: string; | ||
| duration: string; | ||
| }[]; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any | ||
| const post = async (formData: any): Promise<Case> => { | ||
| const bearerToken = `Bearer ${getLocalStorageObjProperty( | ||
| AUTHENTICATED_USER_KEY, | ||
| "access_token", | ||
| )}`; | ||
| try { | ||
| const { data } = await baseAPIClient.post("/visits", formData, { | ||
| headers: { Authorization: bearerToken }, | ||
| }); | ||
| return data; | ||
| } catch (error) { | ||
| return error; | ||
| } | ||
| }; | ||
|
|
||
| const put = async ({ | ||
| changedData, | ||
| intakeID, | ||
| }: { | ||
| changedData: Record<string, string>; | ||
| intakeID: number; | ||
| }): Promise<Case> => { | ||
| const bearerToken = `Bearer ${getLocalStorageObjProperty( | ||
| AUTHENTICATED_USER_KEY, | ||
| "access_token", | ||
| )}`; | ||
| try { | ||
| const { data } = await baseAPIClient.put( | ||
| `/visit/${intakeID}`, | ||
| changedData, | ||
| { | ||
| headers: { Authorization: bearerToken }, | ||
| }, | ||
| ); | ||
| return data; | ||
| } catch (error) { | ||
| return error; | ||
| } | ||
| }; | ||
|
|
||
| export default { post, put }; |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.