@@ -660,6 +660,8 @@ async def get_matches_for_participant(self, participant_id: UUID) -> MatchListRe
660660 .options (
661661 joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .treatments ),
662662 joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .experiences ),
663+ joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .loved_one_treatments ),
664+ joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .loved_one_experiences ),
663665 joinedload (Match .volunteer ).joinedload (User .volunteer_data ),
664666 joinedload (Match .match_status ),
665667 joinedload (Match .suggested_time_blocks ),
@@ -685,6 +687,46 @@ async def get_matches_for_participant(self, participant_id: UUID) -> MatchListRe
685687 self .logger .error (f"Error fetching matches for participant { participant_id } : { exc } " )
686688 raise HTTPException (status_code = 500 , detail = "Failed to fetch matches" )
687689
690+ async def get_all_matches_for_participant_admin (self , participant_id : UUID ) -> MatchListResponse :
691+ """Get all matches for a participant including those awaiting volunteer acceptance (admin only)."""
692+ try :
693+ # Get participant to check pending request flag
694+ participant : User | None = self .db .get (User , participant_id )
695+ if not participant :
696+ raise HTTPException (404 , f"Participant { participant_id } not found" )
697+
698+ # Get ALL matches including those awaiting volunteer acceptance
699+ matches : List [Match ] = (
700+ self .db .query (Match )
701+ .options (
702+ joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .treatments ),
703+ joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .experiences ),
704+ joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .loved_one_treatments ),
705+ joinedload (Match .volunteer ).joinedload (User .user_data ).joinedload (UserData .loved_one_experiences ),
706+ joinedload (Match .volunteer ).joinedload (User .volunteer_data ),
707+ joinedload (Match .match_status ),
708+ joinedload (Match .suggested_time_blocks ),
709+ joinedload (Match .confirmed_time ),
710+ )
711+ .filter (
712+ Match .participant_id == participant_id ,
713+ Match .deleted_at .is_ (None ),
714+ )
715+ .order_by (Match .created_at .desc ())
716+ .all ()
717+ )
718+
719+ responses = [self ._build_match_detail (match ) for match in matches ]
720+ return MatchListResponse (
721+ matches = responses ,
722+ has_pending_request = participant .pending_volunteer_request or False ,
723+ )
724+ except HTTPException :
725+ raise
726+ except Exception as exc :
727+ self .logger .error (f"Error fetching all matches for participant { participant_id } : { exc } " )
728+ raise HTTPException (status_code = 500 , detail = "Failed to fetch matches" )
729+
688730 async def get_matches_for_volunteer (self , volunteer_id : UUID ) -> MatchListForVolunteerResponse :
689731 """Get all matches for a volunteer, including those awaiting acceptance."""
690732 try :
@@ -699,6 +741,8 @@ async def get_matches_for_volunteer(self, volunteer_id: UUID) -> MatchListForVol
699741 .options (
700742 joinedload (Match .participant ).joinedload (User .user_data ).joinedload (UserData .treatments ),
701743 joinedload (Match .participant ).joinedload (User .user_data ).joinedload (UserData .experiences ),
744+ joinedload (Match .participant ).joinedload (User .user_data ).joinedload (UserData .loved_one_treatments ),
745+ joinedload (Match .participant ).joinedload (User .user_data ).joinedload (UserData .loved_one_experiences ),
702746 joinedload (Match .match_status ),
703747 )
704748 .filter (Match .volunteer_id == volunteer_id , Match .deleted_at .is_ (None ))
@@ -822,6 +866,9 @@ def _build_match_detail_for_volunteer(self, match: Match) -> MatchDetailForVolun
822866 treatments : List [str ] = []
823867 experiences : List [str ] = []
824868 timezone : Optional [str ] = None
869+ loved_one_diagnosis : Optional [str ] = None
870+ loved_one_treatments : List [str ] = []
871+ loved_one_experiences : List [str ] = []
825872
826873 if participant_data :
827874 if participant_data .pronouns :
@@ -839,6 +886,13 @@ def _build_match_detail_for_volunteer(self, match: Match) -> MatchDetailForVolun
839886
840887 timezone = participant_data .timezone
841888
889+ # Add loved one data
890+ loved_one_diagnosis = participant_data .loved_one_diagnosis
891+ if participant_data .loved_one_treatments :
892+ loved_one_treatments = [t .name for t in participant_data .loved_one_treatments if t and t .name ]
893+ if participant_data .loved_one_experiences :
894+ loved_one_experiences = [e .name for e in participant_data .loved_one_experiences if e and e .name ]
895+
842896 participant_summary = MatchParticipantSummary (
843897 id = participant .id ,
844898 first_name = participant .first_name ,
@@ -850,6 +904,9 @@ def _build_match_detail_for_volunteer(self, match: Match) -> MatchDetailForVolun
850904 treatments = treatments ,
851905 experiences = experiences ,
852906 timezone = timezone ,
907+ loved_one_diagnosis = loved_one_diagnosis ,
908+ loved_one_treatments = loved_one_treatments ,
909+ loved_one_experiences = loved_one_experiences ,
853910 )
854911
855912 match_status_name = match .match_status .name if match .match_status else ""
@@ -940,6 +997,9 @@ def _build_match_detail(self, match: Match) -> MatchDetailResponse:
940997 treatments : List [str ] = []
941998 experiences : List [str ] = []
942999 overview : Optional [str ] = None
1000+ loved_one_diagnosis : Optional [str ] = None
1001+ loved_one_treatments : List [str ] = []
1002+ loved_one_experiences : List [str ] = []
9431003
9441004 if volunteer_data :
9451005 if volunteer_data .pronouns :
@@ -957,6 +1017,13 @@ def _build_match_detail(self, match: Match) -> MatchDetailResponse:
9571017 if volunteer_data .experiences :
9581018 experiences = [e .name for e in volunteer_data .experiences if e and e .name ]
9591019
1020+ # Add loved one data
1021+ loved_one_diagnosis = volunteer_data .loved_one_diagnosis
1022+ if volunteer_data .loved_one_treatments :
1023+ loved_one_treatments = [t .name for t in volunteer_data .loved_one_treatments if t and t .name ]
1024+ if volunteer_data .loved_one_experiences :
1025+ loved_one_experiences = [e .name for e in volunteer_data .loved_one_experiences if e and e .name ]
1026+
9601027 # Get overview/experience from volunteer_data table
9611028 if volunteer_data_record and volunteer_data_record .experience :
9621029 overview = volunteer_data_record .experience
@@ -974,6 +1041,9 @@ def _build_match_detail(self, match: Match) -> MatchDetailResponse:
9741041 treatments = treatments ,
9751042 experiences = experiences ,
9761043 overview = overview ,
1044+ loved_one_diagnosis = loved_one_diagnosis ,
1045+ loved_one_treatments = loved_one_treatments ,
1046+ loved_one_experiences = loved_one_experiences ,
9771047 )
9781048
9791049 suggested_blocks = [
0 commit comments