Added diagnosis code to display, fix connection pooling, separated out common parts of visit