update QualityMonitoringDefinition set handleDepart = (select case when departNames like '%;%' then ';' else departNames end from FormDefinition where id = QualityMonitoringDefinition.id), handleDepartCoding = (select case when departCodes like '%;%' then ';' else departCodes end from FormDefinition where id = QualityMonitoringDefinition.id) where handleDepartCoding is null or handleDepart is null;
update QualityMonitoringDefinition set handleDepart = (select orgUnitName from SupplyRoomConfig where supplyRoomType = 1), handleDepartCoding = (select orgUnitCoding from SupplyRoomConfig where supplyRoomType = 1) where (handleDepart = ';' and handleDepartCoding = ';') or (handleDepartCoding not in (select orgUnitCoding from SupplyRoomConfig where supplyRoomType in (1,2)));