I don't think you need a serial number field at all.
and then it will assign details for each visit which are 3 in total
Each record in PatientsVisitDetails should document a separate visit. To count the number of related records in PatientsVistDetails does not require a serial number field.
From Patients, Count ( ParetintsVistitDetails::PatientNo ) will return the total number of visits. From PatientvisitDetails a self join reltionship based on the patientNo field can produce the same count.