Pilot on training flight with Instructor reported NMAC with another aircraft while entering airport traffic pattern for landing.
Synopsis
Pilot on training flight with Instructor reported NMAC with another aircraft while entering airport traffic pattern for landing.
Narrative
I'm a student pilot with PPL and IR training for a commercial pilot certificate. Was flying a practice medical diversion into ZZZ with my instructor in preparation for an upcoming FAA checkride. Was on CTAF on COMM 1 and monitoring ZZZ Departure in the COMM 2; and I was making radio calls as normal to join the 45 degree entry to the left downwind to Runway XX. Instructor was scanning; and while I was paying as much attention outside as possible; I was preoccupied with the diversion and focusing on finding the airport; making calls; scanning the traffic pattern for other aircraft; etc. My instructor suddenly exclaimed; and I looked up to see another aircraft (a GA aircraft that might have been a Cessna of some sort) heading toward us straight on and probably 200-300 feet above us. I instinctively banked right to avoid them since they were coming from the left (my side of the aircraft in the left seat); but they had passed over us within 2-3 seconds. I continued the practice diversion to a landing and tried transmitting on guard after departing again but could not get ahold of any ATC.
Source: NASA Aviation Safety Reporting System (public domain). Reports are voluntary submissions and are not verified by NASA.