As both a doctor (surgical attending) and programmer medicine feels not just like debugging a very complex non linear machine. Patient psychology is one of the hardest parts of the job. Is the stomach pain caused by a psychical problem or can it be functional? The use of protocols (part of the science) can help in catching non typical presentations of illnesses, especially if the patient is not adequate in presentation (drunk, very young, old, trauma etc).
But sometimes medicine comes down to an art, when you have the feeling something does not add up, you have to dig. The same with (older) attendings with very attuned diagnostic skills due to lots of experience that can help solve non-obvious cases.