Specific Aim 2: To determine the efficacy and safety of an A1C based discharge algorithm in controlling BG after discharge in patients with T2D. Patients who participate in the in-hospital arm (Aim 1) will be invited to enroll in this open label prospective outpatient study. The total duration of the study is 3 months.