Forget the visit. You have to specify the status (condition_status_concept_id). You have primary and secondary right there, with respect to the visit it is linked to. If it is not linked to a visit it is the visit that the patient is in at the date of the Condition (diagnosis). If there is no visit, or there are 2 or more visits, you are out of luck. But a patient can only have one inpatient visit at a time, really.
However, Atlas 2.7 cannot do the status (too new an addition to the CDM). You have to encode that in SQL, @jenwilson521. If you have an older CDM and Vocabulary, you could pull it out of the Condition Type (Atlas has that).