select d.icd10,d.hn ,p.pname,p.fname,p.lname ,d.vstdate, (select dt.name from opitemrece as op left outer join drugitems as dt on dt.icode = op.icode where op.icode in ('1000112') and vn= d.vn limit 1 ) as drug from ovstdiag as d left OUTER join person as p on p.patient_hn = d.hn where d.vstdate BETWEEN "2017-01-01" and "2017-12-30" and icd10 in ( 'S00','S01','S05','S07','S08','S09','S10','S11','S16','S17','S18','S19','S20','S21','S28','S29','S30','S31','S38','S39','S40','S41','S46','S47','S48','S49','S50','S51', 'S56','S57','S58','S59','S60','S61','S66','S67','S68', 'S69','S70','S71','S76','S77','S78','S78','S79','S80','S81','S86','S87','S88','S89','S90', 'S91','S96','S97','S98', 'S99','T00','T01','T04','T05','T06','T07','T090','T091','T110','T111','T130','T131','T140','T141','T146','T147','T148','T149','T20','T21','T22','T23', 'T24','T25', 'T29','T30','T31','T32','W50','W51,','W52','W53','W54','W55','W56','W57','W58','W59','W60','W61','W62','W63','W64','X00','X01','X02','X03','X04','X05','X06','X07','X08', 'X09','X10','X11','X12','X13','X14','X15','X16','X17',' X18','X19','X20','X21','X22','X23','X24','X25','X26','X27','X28','X29','X30','X31','X32','X33','X34','X35','X36', 'X37','X38','X39' )